diff --git a/agreement_legal_sale/models/sale_order.py b/agreement_legal_sale/models/sale_order.py index 8a3e308bd..dd07f6e83 100644 --- a/agreement_legal_sale/models/sale_order.py +++ b/agreement_legal_sale/models/sale_order.py @@ -69,7 +69,6 @@ class SaleOrder(models.Model): # we create the Agreement. # To work around that, we check if that is the case, # and make sure the SO Analytic Account is copied to the Agreement. - res = super(SaleOrder, self).action_confirm() for order in self: agreement = order.agreement_id if ( @@ -78,4 +77,4 @@ class SaleOrder(models.Model): and not agreement.analytic_account_id ): agreement.analytic_account_id = order.analytic_account_id - return res + return super(SaleOrder, self).action_confirm() diff --git a/agreement_legal_sale/tests/test_sale_order.py b/agreement_legal_sale/tests/test_sale_order.py index 87696a9e1..46da72808 100644 --- a/agreement_legal_sale/tests/test_sale_order.py +++ b/agreement_legal_sale/tests/test_sale_order.py @@ -84,6 +84,26 @@ class TestSaleOrder(TransactionCase): ], } ) + self.test_agreement = self.env["agreement"].create( + { + "name": "TestAgreement A", + "description": "Test Agreement A", + "special_terms": "TestAgreement A", + "start_date": fields.Date.today(), + "end_date": fields.Date.today() + timedelta(days=365), + } + ) + self.test_sale_order_account_analytic_account = self.env["sale.order"].create( + { + "partner_id": self.test_customer.id, + "agreement_template_id": self.test_agreement_template_no_analytic_account_id.id, + "date_order": fields.Date.today(), + "agreement_id": self.test_agreement.id, + "order_line": [ + (0, 0, {"product_id": self.test_product.id, "product_uom_qty": 1.0}) + ], + } + ) # TEST 01: Test _action_confirm method def test_action_confirm(self): @@ -105,3 +125,8 @@ class TestSaleOrder(TransactionCase): agreement.sale_id.id, is_serviceprofile_so.id, ) + # Test 03: Test action_confirm method + self.test_sale_order_account_analytic_account.write( + {"analytic_account_id": self.test_account_analytic_account.id} + ) + self.test_sale_order_account_analytic_account.action_confirm()