changeset b783324efce5 in modules/sale_invoice_grouping:default
details: 
https://hg.tryton.org/modules/sale_invoice_grouping?cmd=changeset&node=b783324efce5
description:
        Process invoices one by one when grouping

        issue11685
        review435841003
diffstat:

 sale.py |  12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diffs (26 lines):

diff -r 778c1204cf36 -r b783324efce5 sale.py
--- a/sale.py   Sun Oct 16 14:14:11 2022 +0200
+++ b/sale.py   Fri Oct 28 00:29:06 2022 +0200
@@ -1,6 +1,8 @@
 # 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 trytond.pool import PoolMeta
 from trytond.transaction import Transaction
 
@@ -51,3 +53,13 @@
             if grouped_invoices:
                 invoice, = grouped_invoices
         return invoice
+
+    @classmethod
+    def _process_invoice(cls, sales):
+        for method, sales in groupby(
+                sales, lambda s: s.invoice_grouping_method):
+            if method:
+                for sale in sales:
+                    super()._process_invoice([sale])
+            else:
+                super()._process_invoice(list(sales))

Reply via email to