changeset 793387502c52 in modules/sale_invoice_grouping:6.2 details: https://hg.tryton.org/modules/sale_invoice_grouping?cmd=changeset&node=793387502c52 description: Process invoices one by one when grouping
issue11685 review435841003 (grafted from b783324efce5b7261cec77f0ce34feea0feeeec2) diffstat: sale.py | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diffs (26 lines): diff -r 50790f33481e -r 793387502c52 sale.py --- a/sale.py Mon Nov 01 17:24:14 2021 +0100 +++ 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))