Update statement lines amount from invoice when changing origins

2b9a72775e4c made the change for on_change_lines but forgot to also update
on_change_origins.

Closes #12672
This commit is contained in:
Cédric Krier committed 2023-10-26 17:58:18 +02:00
1 parent 70dcf79404
commit 35cff3c11c
1 file changed
+3 -15
+3 -15
View File
@@ -231,21 +231,9 @@ class Statement(Workflow, ModelSQL, ModelView):
@fields.depends('origins', 'lines', 'journal', 'company')
def on_change_origins(self):
if not self.journal or not self.origins or not self.company:
return
if self.journal.currency != self.company.currency:
return
invoices = set()
for line in self.lines:
if (line.invoice
and line.invoice.currency == self.company.currency):
invoices.add(line.invoice)
for origin in self.origins:
for line in origin.lines:
if (line.invoice
and line.invoice.currency == self.company.currency):
invoices.add(line.invoice)
invoices = {l.invoice for l in self.lines if l.invoice}
invoices.update(
l.invoice for o in self.origins for l in o.lines if l.invoice)
invoice_id2amount_to_pay = {}
for invoice in invoices:
if invoice.type == 'out':