From eb6dcd96ed12cc1af83e4b580b1cd2570609e428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 11 Sep 2022 17:46:09 +0200 Subject: [PATCH] Support alternative payees on invoice issue11646 review435641003 --- statement.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/statement.py b/statement.py index 9ec41a7f1a..ad913f3f74 100644 --- a/statement.py +++ b/statement.py @@ -748,8 +748,11 @@ class Line(origin_mixin(_states), sequence_ordered(), ModelSQL, ModelView): 'account.invoice': [ ('company', '=', Eval('company', -1)), If(Bool(Eval('party')), - ('party', '=', Eval('party')), - ()), + ['OR', + ('party', '=', Eval('party', -1)), + ('alternative_payees', '=', Eval('party', -1)), + ], + []), If(Bool(Eval('account')), ('account', '=', Eval('account')), ()), @@ -855,7 +858,8 @@ class Line(origin_mixin(_states), sequence_ordered(), ModelSQL, ModelView): if self.invoice: if self.party: - if self.invoice.party != self.party: + if (self.invoice.party != self.party + or self.party not in self.invoice.alternative_payees): self.invoice = None else: self.invoice = None @@ -903,7 +907,13 @@ class Line(origin_mixin(_states), sequence_ordered(), ModelSQL, ModelView): def on_change_related_to(self): if self.invoice: if not self.party: - self.party = self.invoice.party + if not self.invoice.alternative_payees: + self.party = self.invoice.party + else: + try: + self.party, = self.invoice.alternative_payees + except ValueError: + pass if not self.account: self.account = self.invoice.account @@ -985,7 +995,7 @@ class Line(origin_mixin(_states), sequence_ordered(), ModelSQL, ModelView): to_reconcile.clear() reconcile_lines = line.invoice.get_reconcile_lines_for_amount( - move_line.credit - move_line.debit) + move_line.credit - move_line.debit, party=line.party) assert move_line.account == line.invoice.account