From 2b75096e78cc133d72bc3bc25eaa9f27e23aa31a Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Tue, 9 Jul 2024 20:21:09 +0200 Subject: [PATCH] [FIX] account_payment_order: add missing option "structured" to payment line ref type The payment line reference type takes its value from the invoice reference type, and both fields must have the same options. The missing option "structured" causes a bug during payment creation. the test is modified to be able to reproduce the problem. --- account_payment_order/models/account_move.py | 4 +--- account_payment_order/models/account_payment_line.py | 4 +++- account_payment_order/tests/test_payment_order_inbound.py | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/account_payment_order/models/account_move.py b/account_payment_order/models/account_move.py index 46478cc84..9ce61841d 100644 --- a/account_payment_order/models/account_move.py +++ b/account_payment_order/models/account_move.py @@ -51,9 +51,7 @@ class AccountMove(models.Model): """Retrieve the communication string for this direct item.""" communication = self.payment_reference or self.ref or self.name if self.is_invoice(): - if (self.reference_type or "none") != "none": - communication = self.ref - elif self.is_purchase_document(): + if self.is_purchase_document(): communication = self.ref or self.payment_reference else: communication = self.payment_reference or self.name diff --git a/account_payment_order/models/account_payment_line.py b/account_payment_order/models/account_payment_line.py index 8a4b9ce09..c41e7409c 100644 --- a/account_payment_order/models/account_payment_line.py +++ b/account_payment_order/models/account_payment_line.py @@ -78,7 +78,9 @@ class AccountPaymentLine(models.Model): required=False, help="Label of the payment that will be seen by the destinee" ) communication_type = fields.Selection( - selection=[("normal", "Free")], required=True, default="normal" + selection=[("normal", "Free"), ("structured", "Structured")], + required=True, + default="normal", ) payment_ids = fields.Many2many( comodel_name="account.payment", diff --git a/account_payment_order/tests/test_payment_order_inbound.py b/account_payment_order/tests/test_payment_order_inbound.py index 1c3cec3f0..179d8ee87 100644 --- a/account_payment_order/tests/test_payment_order_inbound.py +++ b/account_payment_order/tests/test_payment_order_inbound.py @@ -77,6 +77,7 @@ class TestPaymentOrderInboundBase(AccountTestInvoicingCommon): invoice_line_form.price_unit = 100.0 invoice_line_form.account_id = self.invoice_line_account invoice_line_form.tax_ids.clear() + invoice_form.reference_type = "structured" invoice = invoice_form.save() invoice_form = Form(invoice) invoice_form.payment_mode_id = self.inbound_mode