changeset d35fb4d82cc8 in modules/sale_shipment_cost:default
details: 
https://hg.tryton.org/modules/sale_shipment_cost?cmd=changeset&node=d35fb4d82cc8
description:
        Split process method to avoid create/write in loop

        issue10801
        review372071002
diffstat:

 sale.py |  9 ++-------
 1 files changed, 2 insertions(+), 7 deletions(-)

diffs (36 lines):

diff -r 5f9eb01ead91 -r d35fb4d82cc8 sale.py
--- a/sale.py   Wed Sep 29 10:42:56 2021 +0200
+++ b/sale.py   Fri Oct 08 19:21:06 2021 +0200
@@ -289,14 +289,10 @@
         return cost
 
     def create_shipment(self, shipment_type):
-        pool = Pool()
-        Shipment = pool.get('stock.shipment.out')
-
-        shipments = super(Sale, self).create_shipment(shipment_type)
+        shipments = super().create_shipment(shipment_type)
         if shipment_type == 'out' and shipments and self.carrier:
             for shipment in shipments:
                 shipment.carrier = self.carrier
-        Shipment.save(shipments)
         return shipments
 
     def create_invoice(self):
@@ -304,7 +300,7 @@
         InvoiceLine = pool.get('account.invoice.line')
         Shipment = pool.get('stock.shipment.out')
 
-        invoice = super(Sale, self).create_invoice()
+        invoice = super().create_invoice()
         if invoice and self.shipment_cost_method == 'shipment':
             invoice_lines = []
             # Copy shipments to avoid losing changes as the cache is cleared
@@ -322,7 +318,6 @@
                     shipment.cost_invoice_line = invoice_line
             InvoiceLine.save(invoice_lines)
             Shipment.save(shipments)
-            invoice.update_taxes()
         return invoice
 
 

Reply via email to