From 5437a794bf138e8e5bcf3ba75a96e3179de5257a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Didderen?= Date: Sun, 5 Feb 2023 23:11:19 +0100 Subject: [PATCH] [13.0] split method create_account_payment_line for inheratibiliy --- account_payment_order/models/account_move.py | 25 +++++++++++--------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/account_payment_order/models/account_move.py b/account_payment_order/models/account_move.py index bdecae718..aac8bb324 100644 --- a/account_payment_order/models/account_move.py +++ b/account_payment_order/models/account_move.py @@ -48,6 +48,19 @@ class AccountMove(models.Model): # in account_payment_order.py return vals + def _get_applicable_lines(self, move): + return move.line_ids.filtered( + lambda x: ( + not x.reconciled + and x.payment_mode_id.payment_order_ok + and x.account_id.internal_type in ("receivable", "payable") + and not any( + p_state in ("draft", "open", "generated") + for p_state in x.payment_line_ids.mapped("state") + ) + ) + ) + def create_account_payment_line(self): apoo = self.env["account.payment.order"] result_payorder_ids = set() @@ -55,17 +68,7 @@ class AccountMove(models.Model): for move in self: if move.state != "posted": raise UserError(_("The invoice %s is not in Posted state") % move.name) - applicable_lines = move.line_ids.filtered( - lambda x: ( - not x.reconciled - and x.payment_mode_id.payment_order_ok - and x.account_id.internal_type in ("receivable", "payable") - and not any( - p_state in ("draft", "open", "generated") - for p_state in x.payment_line_ids.mapped("state") - ) - ) - ) + applicable_lines = self._get_applicable_lines(move) if not applicable_lines: raise UserError( _(