[FIX] sale: group invoices by partner as expected
Steps to reproduce the problem: - Create 2 partners A and B. - Create sales orders in this order: Order Partner A + Order Partner B + Order Partner B + Order Partner A + Order Partner B - Select all that orders. - Invoice them. Current behavior: 4 invoices are created. Expected behavior: Only 2 invoices are created: Invoice Partner A + Invoice Partner B This is because itertools.groupby expects elements to be pre-sorted by the grouping key, so we sort them accordingly. closes odoo/odoo#73559 X-original-commit: 3b0bd35c6c9e54b7b0c21cc28f55f520c884d9ad Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
This commit is contained in:
committed by
Victor Feyens
parent
cc5ff7ac8c
commit
5e6fe19455
@@ -742,6 +742,12 @@ Reason(s) of this behavior could be:
|
||||
if not grouped:
|
||||
new_invoice_vals_list = []
|
||||
invoice_grouping_keys = self._get_invoice_grouping_keys()
|
||||
invoice_vals_list = sorted(
|
||||
invoice_vals_list,
|
||||
key=lambda x: [
|
||||
x.get(grouping_key) for grouping_key in invoice_grouping_keys
|
||||
]
|
||||
)
|
||||
for grouping_keys, invoices in groupby(invoice_vals_list, key=lambda x: [x.get(grouping_key) for grouping_key in invoice_grouping_keys]):
|
||||
origins = set()
|
||||
payment_refs = set()
|
||||
|
||||
Reference in New Issue
Block a user