[tryton-debian-vcs] tryton-modules-sale-supply-drop-shipment branch upstream updated. upstream/3.2.0-1-gca3be01

Mathias Behrle tryton-debian-vcs at alioth.debian.org
Thu Oct 23 12:18:21 UTC 2014


The following commit has been merged in the upstream branch:
https://alioth.debian.org/plugins/scmgit/cgi-bin/gitweb.cgi/?p=tryton/tryton-modules-sale-supply-drop-shipment.git;a=commitdiff;h=upstream/3.2.0-1-gca3be01

commit ca3be011e9ee4abc67472744e15e5d442f1375a9
Author: Mathias Behrle <mathiasb at m9s.biz>
Date:   Tue Oct 21 11:29:21 2014 +0200

    Adding upstream version 3.4.0.
    
    Signed-off-by: Mathias Behrle <mathiasb at m9s.biz>

diff --git a/CHANGELOG b/CHANGELOG
index aeba0cd..4683f19 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+Version 3.4.0 - 2014-10-20
+* Bug fixes (see mercurial logs for details)
+* Propagate exception handling from sale to purchase
+
 Version 3.2.0 - 2014-04-21
 * Bug fixes (see mercurial logs for details)
 
diff --git a/PKG-INFO b/PKG-INFO
index d86a4f9..ee4fdbd 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,12 +1,12 @@
 Metadata-Version: 1.1
 Name: trytond_sale_supply_drop_shipment
-Version: 3.2.0
+Version: 3.4.0
 Summary: Tryton module for sale supply drop shipment
 Home-page: http://www.tryton.org/
 Author: Tryton
 Author-email: issue_tracker at tryton.org
 License: GPL-3
-Download-URL: http://downloads.tryton.org/3.2/
+Download-URL: http://downloads.tryton.org/3.4/
 Description: sale_supply_drop_shipment
         =========================
         
diff --git a/__init__.py b/__init__.py
index 4169055..2b173b1 100644
--- a/__init__.py
+++ b/__init__.py
@@ -21,4 +21,6 @@ def register():
         module='sale_supply_drop_shipment', type_='model')
     Pool.register(
         CreatePurchase,
+        PurchaseHandleShipmentException,
+        SaleHandleShipmentException,
         module='sale_supply_drop_shipment', type_='wizard')
diff --git a/locale/ca_ES.po b/locale/ca_ES.po
index 6f1873f..8282ab6 100644
--- a/locale/ca_ES.po
+++ b/locale/ca_ES.po
@@ -209,11 +209,3 @@ msgstr "Cancel·la"
 msgctxt "wizard_button:purchase.request.create_purchase,ask_party,start:"
 msgid "Continue"
 msgstr "Continua"
-
-msgctxt "wizard_button:purchase.request.create_purchase,ask_term,end:"
-msgid "Cancel"
-msgstr "Cancel·la"
-
-msgctxt "wizard_button:purchase.request.create_purchase,ask_term,start:"
-msgid "Continue"
-msgstr "Continua"
diff --git a/locale/de_DE.po b/locale/de_DE.po
index f86811d..bd07def 100644
--- a/locale/de_DE.po
+++ b/locale/de_DE.po
@@ -18,7 +18,7 @@ msgstr ""
 
 msgctxt "field:purchase.product_supplier,drop_shipment:"
 msgid "Drop Shipment"
-msgstr "Direktlieferung"
+msgstr "Direkter Lieferposten"
 
 msgctxt "field:purchase.purchase,customer:"
 msgid "Customer"
@@ -30,7 +30,7 @@ msgstr "Lieferadresse"
 
 msgctxt "field:purchase.purchase,drop_shipments:"
 msgid "Drop Shipments"
-msgstr "Direktlieferungen"
+msgstr "Direkte Lieferposten"
 
 msgctxt "field:purchase.request,customer:"
 msgid "Customer"
@@ -42,11 +42,11 @@ msgstr "Lieferadresse"
 
 msgctxt "field:sale.sale,drop_shipments:"
 msgid "Drop Shipments"
-msgstr "Direktlieferungen"
+msgstr "Direkte Lieferposten"
 
 msgctxt "field:stock.configuration,shipment_drop_sequence:"
 msgid "Drop Shipment Sequence"
-msgstr "Nummernkreis Direktlieferung"
+msgstr "Nummernkreis Direkte Lieferposten"
 
 msgctxt "field:stock.move,customer_drop:"
 msgid "Drop Customer"
@@ -122,15 +122,15 @@ msgstr "Letzte Änderung durch"
 
 msgctxt "model:ir.action,name:act_purchase_drop_shipment_form"
 msgid "Drop Shipments"
-msgstr "Direktlieferungen"
+msgstr "Direkte Lieferposten"
 
 msgctxt "model:ir.action,name:act_sale_drop_shipment_form"
 msgid "Drop Shipments"
-msgstr "Direktlieferungen"
+msgstr "Direkte Lieferposten"
 
 msgctxt "model:ir.action,name:act_shipment_drop_form"
 msgid "Drop Shipments"
-msgstr "Direktlieferungen"
+msgstr "Direkte Lieferposten"
 
 msgctxt ""
 "model:ir.action.act_window.domain,name:act_shipment_drop_form_domain_all"
@@ -149,19 +149,19 @@ msgstr "Wartend"
 
 msgctxt "model:ir.sequence,name:sequence_shipment_drop"
 msgid "Drop Shipment"
-msgstr "Direktlieferung"
+msgstr "Direkter Lieferposten"
 
 msgctxt "model:ir.sequence.type,name:sequence_type_shipment_drop"
 msgid "Drop Shipment"
-msgstr "Direktlieferung"
+msgstr "Direkter Lieferposten"
 
 msgctxt "model:ir.ui.menu,name:menu_shipment_drop_form"
 msgid "Drop Shipments"
-msgstr "Direktlieferungen"
+msgstr "Direkte Lieferposten"
 
 msgctxt "model:stock.shipment.drop,name:"
 msgid "Drop Shipment"
-msgstr "Direktlieferung"
+msgstr "Direkter Lieferposten"
 
 msgctxt "selection:stock.shipment.drop,state:"
 msgid "Canceled"
@@ -181,7 +181,7 @@ msgstr "Wartend"
 
 msgctxt "view:stock.shipment.drop:"
 msgid "Cancel"
-msgstr "Abbrechen"
+msgstr "Annullieren"
 
 msgctxt "view:stock.shipment.drop:"
 msgid "Done"
@@ -193,11 +193,11 @@ msgstr "Entwurf"
 
 msgctxt "view:stock.shipment.drop:"
 msgid "Drop Shipment"
-msgstr "Direktlieferung"
+msgstr "Direkter Lieferposten"
 
 msgctxt "view:stock.shipment.drop:"
 msgid "Drop Shipments"
-msgstr "Direktlieferungen"
+msgstr "Direkte Lieferposten"
 
 msgctxt "view:stock.shipment.drop:"
 msgid "Wait"
@@ -210,11 +210,3 @@ msgstr "Abbrechen"
 msgctxt "wizard_button:purchase.request.create_purchase,ask_party,start:"
 msgid "Continue"
 msgstr "Fortfahren"
-
-msgctxt "wizard_button:purchase.request.create_purchase,ask_term,end:"
-msgid "Cancel"
-msgstr "Abbrechen"
-
-msgctxt "wizard_button:purchase.request.create_purchase,ask_term,start:"
-msgid "Continue"
-msgstr "Fortfahren"
diff --git a/locale/es_AR.po b/locale/es_AR.po
index d9efbfc..b74b93c 100644
--- a/locale/es_AR.po
+++ b/locale/es_AR.po
@@ -201,7 +201,7 @@ msgstr "Remitos directos"
 
 msgctxt "view:stock.shipment.drop:"
 msgid "Wait"
-msgstr "Esperando"
+msgstr "Espera"
 
 msgctxt "wizard_button:purchase.request.create_purchase,ask_party,end:"
 msgid "Cancel"
@@ -210,11 +210,3 @@ msgstr "Cancelar"
 msgctxt "wizard_button:purchase.request.create_purchase,ask_party,start:"
 msgid "Continue"
 msgstr "Continuar"
-
-msgctxt "wizard_button:purchase.request.create_purchase,ask_term,end:"
-msgid "Cancel"
-msgstr "Cancelar"
-
-msgctxt "wizard_button:purchase.request.create_purchase,ask_term,start:"
-msgid "Continue"
-msgstr "Continuar"
diff --git a/locale/es_ES.po b/locale/es_EC.po
similarity index 74%
copy from locale/es_ES.po
copy to locale/es_EC.po
index 5a1a7be..49312e7 100644
--- a/locale/es_ES.po
+++ b/locale/es_EC.po
@@ -5,7 +5,7 @@ msgstr "Content-Type: text/plain; charset=utf-8\n"
 msgctxt "error:purchase.purchase:"
 msgid "A delivery address must be defined for quotation of purchase \"%s\"."
 msgstr ""
-"Se debe definir una dirección de envío para el presupuesto de la compra "
+"Se debe definir una dirección de entrega para la cotización de la compra "
 "\"%s\"."
 
 msgctxt "error:stock.shipment.drop:"
@@ -13,12 +13,12 @@ msgid ""
 "You cannot reset to draft move \"%s\" which was generated by a sale or a "
 "purchase."
 msgstr ""
-"No puede restaurar a borrador el movimiento \"%s\" generado por una venta o "
-"una compra."
+"No puede restaurar a borrador el movimiento \"%s\" que fue generado por una "
+"venta o compra."
 
 msgctxt "field:purchase.product_supplier,drop_shipment:"
 msgid "Drop Shipment"
-msgstr "Envío directo"
+msgstr "Envío Directo"
 
 msgctxt "field:purchase.purchase,customer:"
 msgid "Customer"
@@ -26,11 +26,11 @@ msgstr "Cliente"
 
 msgctxt "field:purchase.purchase,delivery_address:"
 msgid "Delivery Address"
-msgstr "Dirección envío"
+msgstr "Dirección de Envío"
 
 msgctxt "field:purchase.purchase,drop_shipments:"
 msgid "Drop Shipments"
-msgstr "Envíos directos"
+msgstr "Envíos Directos"
 
 msgctxt "field:purchase.request,customer:"
 msgid "Customer"
@@ -38,19 +38,19 @@ msgstr "Cliente"
 
 msgctxt "field:purchase.request,delivery_address:"
 msgid "Delivery Address"
-msgstr "Dirección envío"
+msgstr "Dirección de Envío"
 
 msgctxt "field:sale.sale,drop_shipments:"
 msgid "Drop Shipments"
-msgstr "Envíos directos"
+msgstr "Envíos Directos"
 
 msgctxt "field:stock.configuration,shipment_drop_sequence:"
 msgid "Drop Shipment Sequence"
-msgstr "Secuencia de envío directo"
+msgstr "Secuencia de Envío Directo"
 
 msgctxt "field:stock.move,customer_drop:"
 msgid "Drop Customer"
-msgstr "Cliente de envío directo"
+msgstr "Cliente de Envío Directo"
 
 msgctxt "field:stock.shipment.drop,code:"
 msgid "Code"
@@ -62,15 +62,15 @@ msgstr "Empresa"
 
 msgctxt "field:stock.shipment.drop,contact_address:"
 msgid "Contact Address"
-msgstr "Dirección de contacto"
+msgstr "Dirección de Contacto"
 
 msgctxt "field:stock.shipment.drop,create_date:"
 msgid "Create Date"
-msgstr "Fecha creación"
+msgstr "Fecha de Creación"
 
 msgctxt "field:stock.shipment.drop,create_uid:"
 msgid "Create User"
-msgstr "Usuario creación"
+msgstr "Creado por Usuario"
 
 msgctxt "field:stock.shipment.drop,customer:"
 msgid "Customer"
@@ -78,11 +78,11 @@ msgstr "Cliente"
 
 msgctxt "field:stock.shipment.drop,delivery_address:"
 msgid "Delivery Address"
-msgstr "Dirección envío"
+msgstr "Dirección de Envío"
 
 msgctxt "field:stock.shipment.drop,effective_date:"
 msgid "Effective Date"
-msgstr "Fecha efectiva"
+msgstr "Fecha Efectiva"
 
 msgctxt "field:stock.shipment.drop,id:"
 msgid "ID"
@@ -94,7 +94,7 @@ msgstr "Movimientos"
 
 msgctxt "field:stock.shipment.drop,planned_date:"
 msgid "Planned Date"
-msgstr "Fecha estimada"
+msgstr "Fecha Planificada"
 
 msgctxt "field:stock.shipment.drop,rec_name:"
 msgid "Name"
@@ -114,23 +114,23 @@ msgstr "Proveedor"
 
 msgctxt "field:stock.shipment.drop,write_date:"
 msgid "Write Date"
-msgstr "Fecha modificación"
+msgstr "Fecha de Modificación"
 
 msgctxt "field:stock.shipment.drop,write_uid:"
 msgid "Write User"
-msgstr "Usuario modificación"
+msgstr "Modificado por Usuario"
 
 msgctxt "model:ir.action,name:act_purchase_drop_shipment_form"
 msgid "Drop Shipments"
-msgstr "Envíos directos"
+msgstr "Envíos Directos"
 
 msgctxt "model:ir.action,name:act_sale_drop_shipment_form"
 msgid "Drop Shipments"
-msgstr "Envíos directos"
+msgstr "Envíos Directos"
 
 msgctxt "model:ir.action,name:act_shipment_drop_form"
 msgid "Drop Shipments"
-msgstr "Envíos directos"
+msgstr "Envíos Directos"
 
 msgctxt ""
 "model:ir.action.act_window.domain,name:act_shipment_drop_form_domain_all"
@@ -145,23 +145,23 @@ msgstr "Borrador"
 msgctxt ""
 "model:ir.action.act_window.domain,name:act_shipment_drop_form_domain_waiting"
 msgid "Waiting"
-msgstr "En espera"
+msgstr "En Espera"
 
 msgctxt "model:ir.sequence,name:sequence_shipment_drop"
 msgid "Drop Shipment"
-msgstr "Envío directo"
+msgstr "Envío Directo"
 
 msgctxt "model:ir.sequence.type,name:sequence_type_shipment_drop"
 msgid "Drop Shipment"
-msgstr "Envío directo"
+msgstr "Envío Directo"
 
 msgctxt "model:ir.ui.menu,name:menu_shipment_drop_form"
 msgid "Drop Shipments"
-msgstr "Envíos directos"
+msgstr "Envíos Directos"
 
 msgctxt "model:stock.shipment.drop,name:"
 msgid "Drop Shipment"
-msgstr "Envío directo"
+msgstr "Envío Directo"
 
 msgctxt "selection:stock.shipment.drop,state:"
 msgid "Canceled"
@@ -177,7 +177,7 @@ msgstr "Borrador"
 
 msgctxt "selection:stock.shipment.drop,state:"
 msgid "Waiting"
-msgstr "En espera"
+msgstr "En Espera"
 
 msgctxt "view:stock.shipment.drop:"
 msgid "Cancel"
@@ -193,28 +193,12 @@ msgstr "Borrador"
 
 msgctxt "view:stock.shipment.drop:"
 msgid "Drop Shipment"
-msgstr "Envío directo"
+msgstr "Envío Directo"
 
 msgctxt "view:stock.shipment.drop:"
 msgid "Drop Shipments"
-msgstr "Envíos directos"
+msgstr "Envíos Directos"
 
 msgctxt "view:stock.shipment.drop:"
 msgid "Wait"
-msgstr "En espera"
-
-msgctxt "wizard_button:purchase.request.create_purchase,ask_party,end:"
-msgid "Cancel"
-msgstr "Cancelar"
-
-msgctxt "wizard_button:purchase.request.create_purchase,ask_party,start:"
-msgid "Continue"
-msgstr "Continuar"
-
-msgctxt "wizard_button:purchase.request.create_purchase,ask_term,end:"
-msgid "Cancel"
-msgstr "Cancelar"
-
-msgctxt "wizard_button:purchase.request.create_purchase,ask_term,start:"
-msgid "Continue"
-msgstr "Continuar"
+msgstr "Espera"
diff --git a/locale/es_ES.po b/locale/es_ES.po
index 5a1a7be..649decb 100644
--- a/locale/es_ES.po
+++ b/locale/es_ES.po
@@ -210,11 +210,3 @@ msgstr "Cancelar"
 msgctxt "wizard_button:purchase.request.create_purchase,ask_party,start:"
 msgid "Continue"
 msgstr "Continuar"
-
-msgctxt "wizard_button:purchase.request.create_purchase,ask_term,end:"
-msgid "Cancel"
-msgstr "Cancelar"
-
-msgctxt "wizard_button:purchase.request.create_purchase,ask_term,start:"
-msgid "Continue"
-msgstr "Continuar"
diff --git a/locale/fr_FR.po b/locale/fr_FR.po
index 71b0a38..a1f5dce 100644
--- a/locale/fr_FR.po
+++ b/locale/fr_FR.po
@@ -4,14 +4,15 @@ msgstr "Content-Type: text/plain; charset=utf-8\n"
 
 msgctxt "error:purchase.purchase:"
 msgid "A delivery address must be defined for quotation of purchase \"%s\"."
-msgstr "L'adresse de livraison doit être définie pour le devis de l'achat \"%s\"."
+msgstr ""
+"L'adresse de livraison doit être définie pour le devis de l'achat « %s »."
 
 msgctxt "error:stock.shipment.drop:"
 msgid ""
 "You cannot reset to draft move \"%s\" which was generated by a sale or a "
 "purchase."
 msgstr ""
-"Vous ne pouvez remettre en brouillon le mouvement \"%s\" car il a été généré"
+"Vous ne pouvez remettre en brouillon le mouvement « %s » car il a été généré"
 " par une vente ou un achat."
 
 msgctxt "field:purchase.product_supplier,drop_shipment:"
@@ -208,11 +209,3 @@ msgstr "Annuler"
 msgctxt "wizard_button:purchase.request.create_purchase,ask_party,start:"
 msgid "Continue"
 msgstr "Continuer"
-
-msgctxt "wizard_button:purchase.request.create_purchase,ask_term,end:"
-msgid "Cancel"
-msgstr "Annuler"
-
-msgctxt "wizard_button:purchase.request.create_purchase,ask_term,start:"
-msgid "Continue"
-msgstr "Continuer"
diff --git a/locale/sl_SI.po b/locale/sl_SI.po
index 24e1acb..7533eb5 100644
--- a/locale/sl_SI.po
+++ b/locale/sl_SI.po
@@ -64,11 +64,11 @@ msgstr "Kontakt"
 
 msgctxt "field:stock.shipment.drop,create_date:"
 msgid "Create Date"
-msgstr "Ustvarjeno"
+msgstr "Izdelano"
 
 msgctxt "field:stock.shipment.drop,create_uid:"
 msgid "Create User"
-msgstr "Ustvaril"
+msgstr "Izdelal"
 
 msgctxt "field:stock.shipment.drop,customer:"
 msgid "Customer"
diff --git a/purchase.py b/purchase.py
index 907d60a..e567c62 100644
--- a/purchase.py
+++ b/purchase.py
@@ -3,10 +3,11 @@
 from trytond.model import fields
 from trytond.pyson import Eval
 from trytond.pool import Pool, PoolMeta
+from trytond.transaction import Transaction
 
 
 __all__ = ['PurchaseRequest', 'Purchase', 'PurchaseLine', 'ProductSupplier',
-    'CreatePurchase']
+    'CreatePurchase', 'PurchaseHandleShipmentException']
 __metaclass__ = PoolMeta
 
 
@@ -119,3 +120,45 @@ class CreatePurchase:
                 if request.delivery_address else None),
             )
         return result
+
+
+class PurchaseHandleShipmentException:
+    __name__ = 'purchase.handle.shipment.exception'
+
+    def transition_handle(self):
+        pool = Pool()
+        Sale = pool.get('sale.sale')
+        SaleLine = pool.get('sale.line')
+
+        super(PurchaseHandleShipmentException, self).transition_handle()
+
+        to_recreate = self.ask.recreate_moves
+        domain_moves = self.ask.domain_moves
+        sales, saleline_write = set(), []
+        sale_lines = SaleLine.search([
+                ('purchase_request.purchase_line.purchase', '=',
+                    Transaction().context['active_id']),
+                ])
+        saleline_write = []
+        for sale_line in sale_lines:
+            moves_ignored = []
+            moves_recreated = []
+            skip = set(sale_line.moves_ignored)
+            skip.update(sale_line.moves_recreated)
+            for move in sale_line.moves:
+                if move not in domain_moves or move in skip:
+                    continue
+                if move in to_recreate:
+                    moves_recreated.append(move.id)
+                else:
+                    moves_ignored.append(move.id)
+                sales.add(sale_line.sale)
+            saleline_write.append([sale_line])
+            saleline_write.append({
+                    'moves_ignored': [('add', moves_ignored)],
+                    'moves_recreated': [('add', moves_recreated)],
+                    })
+
+            SaleLine.write(*saleline_write)
+            Sale.process(list(sales))
+        return 'end'
diff --git a/sale.py b/sale.py
index 2021bf7..fb448aa 100644
--- a/sale.py
+++ b/sale.py
@@ -1,6 +1,6 @@
 #This file is part of Tryton.  The COPYRIGHT file at the top level of
 #this repository contains the full copyright notices and license terms.
-from itertools import groupby
+from itertools import groupby, chain
 from functools import partial
 from trytond.model import fields
 from trytond.pyson import Eval
@@ -8,7 +8,7 @@ from trytond.pool import Pool, PoolMeta
 from trytond.transaction import Transaction
 from trytond.const import OPERATORS
 
-__all__ = ['Sale', 'SaleLine']
+__all__ = ['Sale', 'SaleLine', 'SaleHandleShipmentException']
 __metaclass__ = PoolMeta
 
 
@@ -74,13 +74,11 @@ class Sale:
                 'company': self.company.id,
                 }
             values.update(dict(key))
-            with Transaction().set_user(0, set_context=True):
-                shipment = Shipment(**values)
-                shipment.moves = [m for m in grouped_moves]
-                shipment.save()
-                shipments.append(shipment)
-        with Transaction().set_user(0, set_context=True):
-            Shipment.wait(shipments)
+            shipment = Shipment(**values)
+            shipment.moves = [m for m in grouped_moves]
+            shipment.save()
+            shipments.append(shipment)
+        Shipment.wait(shipments)
         return shipments
 
 
@@ -91,12 +89,9 @@ class SaleLine:
         result = super(SaleLine, self).get_move(shipment_type)
         if (shipment_type == 'out'
                 and self.supply_on_sale):
-            with Transaction().set_user(0, set_context=True):
-                # TODO make it works in bunch
-                line = self.__class__(self.id)
-                if (line.purchase_request and line.purchase_request.customer
-                        and self.purchase_request_state != 'cancel'):
-                    return {}
+            if (self.purchase_request and self.purchase_request.customer
+                    and self.purchase_request_state != 'cancel'):
+                return {}
         return result
 
     def get_purchase_request(self):
@@ -120,14 +115,11 @@ class SaleLine:
                 or not self.product):
             return []
         moves = []
-        with Transaction().set_user(0, set_context=True):
-            # TODO make it work in bunch
-            line = self.__class__(self.id)
-            if line.purchase_request and line.purchase_request.customer:
-                if line.purchase_request.purchase_line:
-                    moves = [m
-                        for m in line.purchase_request.purchase_line.moves
-                        if m.state == 'draft' and not m.shipment]
+        if self.purchase_request and self.purchase_request.customer:
+            if self.purchase_request.purchase_line:
+                moves = [m
+                    for m in self.purchase_request.purchase_line.moves
+                    if m.state == 'draft' and not m.shipment]
         return moves
 
     @classmethod
@@ -142,7 +134,7 @@ class SaleLine:
                 added = True
         values = super(SaleLine, cls).read(ids, fields_names=fields_names)
         if 'moves' in fields_names or []:
-            with Transaction().set_user(0, set_context=True):
+            with Transaction().set_context(_check_access=False):
                 purchase_requests = PurchaseRequest.browse(
                     list(set(v['purchase_request']
                             for v in values if v['purchase_request'])))
@@ -189,3 +181,47 @@ class SaleLine:
                 i += 1
             return domain
         return super(SaleLine, cls).search(process(domain), *args, **kwargs)
+
+
+class SaleHandleShipmentException:
+    __name__ = 'sale.handle.shipment.exception'
+
+    def transition_handle(self):
+        pool = Pool()
+        Purchase = pool.get('purchase.purchase')
+        PurchaseLine = pool.get('purchase.line')
+        Sale = pool.get('sale.sale')
+
+        super(SaleHandleShipmentException, self).transition_handle()
+
+        to_recreate = self.ask.recreate_moves
+        domain_moves = self.ask.domain_moves
+        purchases, purchaseline_write = set(), []
+        sale = Sale(Transaction().context['active_id'])
+        for line in sale.lines:
+            if not line.purchase_request:
+                continue
+            purchase_line = line.purchase_request.purchase_line
+            if not purchase_line:
+                continue
+
+            moves_ignored = []
+            moves_recreated = []
+            skip = set(purchase_line.moves_ignored)
+            skip.update(purchase_line.moves_recreated)
+            for move in purchase_line.moves:
+                if move not in domain_moves or move in skip:
+                    continue
+                if move in to_recreate:
+                    moves_recreated.append(move.id)
+                else:
+                    moves_ignored.append(move.id)
+                purchases.add(purchase_line.purchase)
+            purchaseline_write.append(([purchase_line], {
+                        'moves_ignored': [('add', moves_ignored)],
+                        'moves_recreated': [('add', moves_recreated)],
+                        }))
+
+            PurchaseLine.write(*chain(*purchaseline_write))
+            Purchase.process(list(purchases))
+        return 'end'
diff --git a/stock.py b/stock.py
index 47eb6ad..4848e4d 100644
--- a/stock.py
+++ b/stock.py
@@ -199,7 +199,7 @@ class ShipmentDrop(Workflow, ModelSQL, ModelView):
         for shipments, values in zip(actions, actions):
             if values.get('state', '') not in ('done', 'cancel'):
                 continue
-            with Transaction().set_user(0, set_context=True):
+            with Transaction().set_context(_check_access=False):
                 purchases = set()
                 move_ids = [m.id for s in shipments for m in s.moves]
                 purchase_lines = PurchaseLine.search([
diff --git a/stock.xml b/stock.xml
index e6fa67f..6415b9b 100644
--- a/stock.xml
+++ b/stock.xml
@@ -120,6 +120,16 @@ this repository contains the full copyright notices and license terms. -->
             <field name="perm_create" eval="False"/>
             <field name="perm_delete" eval="False"/>
         </record>
+        <record model="ir.model.access"
+            id="access_shipment_drop_group_purchase">
+            <field name="model"
+                search="[('model', '=', 'stock.shipment.drop')]"/>
+            <field name="group" ref="purchase.group_purchase"/>
+            <field name="perm_read" eval="True"/>
+            <field name="perm_write" eval="False"/>
+            <field name="perm_create" eval="False"/>
+            <field name="perm_delete" eval="False"/>
+        </record>
 
         <record model="ir.model.button" id="shipment_drop_cancel_button">
             <field name="name">cancel</field>
@@ -165,5 +175,15 @@ this repository contains the full copyright notices and license terms. -->
             <field name="group" ref="stock.group_stock"/>
         </record>
 
+        <record model="ir.rule.group" id="rule_group_shipment_drop">
+            <field name="model"
+                search="[('model', '=', 'stock.shipment.drop')]"/>
+            <field name="global_p" eval="True"/>
+        </record>
+        <record model="ir.rule" id="rule_shipment_drop">
+            <field name="domain">[('company', '=', user.company.id if user.company else None)]</field>
+            <field name="rule_group" ref="rule_group_shipment_drop"/>
+        </record>
+
     </data>
 </tryton>
diff --git a/tests/scenario_sale_supply_drop_shipment.rst b/tests/scenario_sale_supply_drop_shipment.rst
index f730ff5..220dd04 100644
--- a/tests/scenario_sale_supply_drop_shipment.rst
+++ b/tests/scenario_sale_supply_drop_shipment.rst
@@ -17,6 +17,7 @@ Imports::
 Create database::
 
     >>> config = config.set_trytond()
+    >>> config.pool.test = True
 
 Install sale_supply, sale, purchase::
 
@@ -240,18 +241,17 @@ Create Purchase from Request::
     250.0
     >>> create_purchase = Wizard('purchase.request.create_purchase',
     ...     [purchase_request])
-    >>> create_purchase.form.payment_term = payment_term
-    >>> create_purchase.execute('start')
     >>> purchase, = Purchase.find()
     >>> purchase.customer == customer
     True
     >>> purchase.delivery_address == sale.shipment_address
     True
-    >>> Purchase.quote([purchase.id], config.context)
-    >>> Purchase.confirm([purchase.id], config.context)
-    >>> purchase.reload()
+    >>> purchase.payment_term = payment_term
+    >>> purchase.click('quote')
+    >>> purchase.click('confirm')
+    >>> purchase.click('process')
     >>> purchase.state
-    u'confirmed'
+    u'processing'
     >>> config.user = sale_user.id
     >>> sale.reload()
     >>> sale.shipments
@@ -288,7 +288,8 @@ The purchase is now waiting for this new drop shipment::
     >>> purchase.shipment_state
     u'waiting'
 
-Let's cancel it and handle the problem from the sale order::
+Let's cancel the shipment and handle the issue from the purchase.
+As a consequence the sale order is over::
 
     >>> config.user = stock_user.id
     >>> shipment.click('cancel')
@@ -306,20 +307,9 @@ Let's cancel it and handle the problem from the sale order::
     u'received'
 
     >>> config.user = sale_user.id
-    >>> sale.shipment_state
-    u'exception'
-    >>> handle_exception = Wizard('sale.handle.shipment.exception', [sale])
-    >>> handle_exception.execute('handle')
     >>> sale.reload()
     >>> sale.shipment_state
-    u'waiting'
-
-The sale has created a new outgoing shipment::
-
-    >>> shipment, = sale.shipments
-    >>> move, = shipment.outgoing_moves
-    >>> move.quantity
-    150.0
+    u'sent'
 
 Cancelling the workflow on the purchase step::
 
@@ -403,3 +393,51 @@ If we opt not to cancel the shipment and deliver from stock::
     >>> config.user = sale_user.id
     >>> sale.shipment_state
     u'sent'
+
+Now let's handle the exception on the sale side::
+
+    >>> config.user = sale_user.id
+    >>> sale = Sale()
+    >>> sale.party = customer
+    >>> sale.payment_term = payment_term
+    >>> sale_line = sale.lines.new()
+    >>> sale_line.product = product
+    >>> sale_line.quantity = 375
+    >>> sale.save()
+    >>> sale.click('quote')
+    >>> sale.click('confirm')
+    >>> sale.click('process')
+
+    >>> config.user = purchase_user.id
+    >>> purchase_request, = PurchaseRequest.find([('purchase_line', '=', None)])
+    >>> purchase_request.quantity
+    375.0
+    >>> create_purchase = Wizard('purchase.request.create_purchase',
+    ...     [purchase_request])
+    >>> purchase, = Purchase.find([('state', '=', 'draft')])
+    >>> purchase.payment_term = payment_term
+    >>> purchase.click('quote')
+    >>> purchase.click('confirm')
+    >>> purchase.click('process')
+    >>> purchase.shipment_state
+    u'waiting'
+    >>> config.user = sale_user.id
+    >>> sale.reload()
+    >>> shipment, = sale.drop_shipments
+    >>> config.user = stock_user.id
+    >>> shipment.click('cancel')
+
+    >>> config.user = sale_user.id
+    >>> sale.shipment_state
+    u'exception'
+    >>> handle_exception = Wizard('sale.handle.shipment.exception', [sale])
+    >>> _ = handle_exception.form.recreate_moves.pop()
+    >>> handle_exception.execute('handle')
+    >>> sale.reload()
+    >>> sale.shipment_state
+    u'sent'
+
+    >>> config.user = purchase_user.id
+    >>> purchase.reload()
+    >>> purchase.shipment_state
+    u'received'
diff --git a/tests/test_sale_supply_drop_shipment.py b/tests/test_sale_supply_drop_shipment.py
index d016a75..abc49d3 100644
--- a/tests/test_sale_supply_drop_shipment.py
+++ b/tests/test_sale_supply_drop_shipment.py
@@ -3,7 +3,8 @@
 import unittest
 import doctest
 import trytond.tests.test_tryton
-from trytond.tests.test_tryton import test_view, test_depends, doctest_dropdb
+from trytond.tests.test_tryton import test_view, test_depends
+from trytond.tests.test_tryton import doctest_setup, doctest_teardown
 
 
 class SaleSupplyDropShipmentTestCase(unittest.TestCase):
@@ -27,6 +28,6 @@ def suite():
             SaleSupplyDropShipmentTestCase))
     suite.addTests(doctest.DocFileSuite(
             'scenario_sale_supply_drop_shipment.rst',
-            setUp=doctest_dropdb, tearDown=doctest_dropdb, encoding='utf-8',
+            setUp=doctest_setup, tearDown=doctest_teardown, encoding='utf-8',
             optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
     return suite
diff --git a/tryton.cfg b/tryton.cfg
index 9f5e064..1b56780 100644
--- a/tryton.cfg
+++ b/tryton.cfg
@@ -1,5 +1,5 @@
 [tryton]
-version=3.2.0
+version=3.4.0
 depends:
     company
     ir
diff --git a/trytond_sale_supply_drop_shipment.egg-info/PKG-INFO b/trytond_sale_supply_drop_shipment.egg-info/PKG-INFO
index 1d3f960..c29bac3 100644
--- a/trytond_sale_supply_drop_shipment.egg-info/PKG-INFO
+++ b/trytond_sale_supply_drop_shipment.egg-info/PKG-INFO
@@ -1,12 +1,12 @@
 Metadata-Version: 1.1
 Name: trytond-sale-supply-drop-shipment
-Version: 3.2.0
+Version: 3.4.0
 Summary: Tryton module for sale supply drop shipment
 Home-page: http://www.tryton.org/
 Author: Tryton
 Author-email: issue_tracker at tryton.org
 License: GPL-3
-Download-URL: http://downloads.tryton.org/3.2/
+Download-URL: http://downloads.tryton.org/3.4/
 Description: sale_supply_drop_shipment
         =========================
         
diff --git a/trytond_sale_supply_drop_shipment.egg-info/SOURCES.txt b/trytond_sale_supply_drop_shipment.egg-info/SOURCES.txt
index 8a2f8e5..09bd2ff 100644
--- a/trytond_sale_supply_drop_shipment.egg-info/SOURCES.txt
+++ b/trytond_sale_supply_drop_shipment.egg-info/SOURCES.txt
@@ -11,15 +11,37 @@ stock.xml
 tryton.cfg
 ./__init__.py
 ./purchase.py
+./purchase.xml
 ./sale.py
+./sale.xml
 ./stock.py
+./stock.xml
+./tryton.cfg
+./locale/ca_ES.po
+./locale/de_DE.po
+./locale/es_AR.po
+./locale/es_CO.po
+./locale/es_EC.po
+./locale/es_ES.po
+./locale/fr_FR.po
+./locale/sl_SI.po
 ./tests/__init__.py
+./tests/scenario_sale_supply_drop_shipment.rst
 ./tests/test_sale_supply_drop_shipment.py
+./view/product_supplier_form.xml
+./view/purchase_form.xml
+./view/purchase_request_form.xml
+./view/purchase_request_tree.xml
+./view/sale_form.xml
+./view/shipment_drop_form.xml
+./view/shipment_drop_tree.xml
+./view/stock_configuration_form.xml
 doc/index.rst
 locale/ca_ES.po
 locale/de_DE.po
 locale/es_AR.po
 locale/es_CO.po
+locale/es_EC.po
 locale/es_ES.po
 locale/fr_FR.po
 locale/sl_SI.po
diff --git a/trytond_sale_supply_drop_shipment.egg-info/requires.txt b/trytond_sale_supply_drop_shipment.egg-info/requires.txt
index 83ecc0b..f4e7e60 100644
--- a/trytond_sale_supply_drop_shipment.egg-info/requires.txt
+++ b/trytond_sale_supply_drop_shipment.egg-info/requires.txt
@@ -1,6 +1,6 @@
-trytond_company >= 3.2, < 3.3
-trytond_purchase >= 3.2, < 3.3
-trytond_sale >= 3.2, < 3.3
-trytond_sale_supply >= 3.2, < 3.3
-trytond_stock >= 3.2, < 3.3
-trytond >= 3.2, < 3.3
\ No newline at end of file
+trytond_company >= 3.4, < 3.5
+trytond_purchase >= 3.4, < 3.5
+trytond_sale >= 3.4, < 3.5
+trytond_sale_supply >= 3.4, < 3.5
+trytond_stock >= 3.4, < 3.5
+trytond >= 3.4, < 3.5
\ No newline at end of file
-- 
tryton-modules-sale-supply-drop-shipment



More information about the tryton-debian-vcs mailing list