From 009f3b49266d564c8c7bb0badd15a80657d8ec97 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Mon, 2 Sep 2024 15:04:21 +0200 Subject: [PATCH] [IMP] account_payment_order_grouped_output: Maturity date in grouped moves For propagating maturity dates from the individual payment moves to the grouped ones, 2 actions are taken: - For the counterpart that will neutralize each payment, we put the maturity date according to the same logic as the payment one. - For the grouped AR/AP, we put the first payment date of all the grouped payments, as all of them should be the same after grouping by this criterium in _prepare_trf_moves. TT50671 --- .../models/account_payment_order.py | 4 ++++ .../tests/test_payment_order_inbound_grouped.py | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/account_payment_order_grouped_output/models/account_payment_order.py b/account_payment_order_grouped_output/models/account_payment_order.py index baedb49d5..b8b78f65f 100644 --- a/account_payment_order_grouped_output/models/account_payment_order.py +++ b/account_payment_order_grouped_output/models/account_payment_order.py @@ -149,6 +149,8 @@ class AccountPaymentOrder(models.Model): ), "currency_id": payment.currency_id.id, "amount_currency": payment.amount * sign, + # Same logic as the individual payments + "date_maturity": payment.payment_line_ids[0].date, } return vals @@ -181,6 +183,8 @@ class AccountPaymentOrder(models.Model): ), "currency_id": payments[0].currency_id.id, "amount_currency": amount_payment_currency * sign, + # All the lines should have the same date following _prepare_trf_moves + "date_maturity": payments.payment_line_ids[:1].date, } return vals diff --git a/account_payment_order_grouped_output/tests/test_payment_order_inbound_grouped.py b/account_payment_order_grouped_output/tests/test_payment_order_inbound_grouped.py index 409146c24..a99a0898b 100644 --- a/account_payment_order_grouped_output/tests/test_payment_order_inbound_grouped.py +++ b/account_payment_order_grouped_output/tests/test_payment_order_inbound_grouped.py @@ -1,6 +1,9 @@ # Copyright 2022 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from freezegun import freeze_time + +from odoo import fields from odoo.tests.common import tagged from odoo.addons.account_payment_order.tests.test_payment_order_inbound import ( @@ -10,9 +13,12 @@ from odoo.addons.account_payment_order.tests.test_payment_order_inbound import ( @tagged("post_install", "-at_install") class TestPaymentOrderInbound(TestPaymentOrderInboundBase): + @freeze_time("2024-04-01") def test_grouped_output(self): self.inbound_mode.generate_move = True self.inbound_mode.post_move = True + self.inbound_order.date_prefered = "fixed" + self.inbound_order.date_scheduled = "2024-08-01" self.inbound_order.draft2open() self.inbound_order.open2generated() self.inbound_order.generated2uploaded() @@ -35,3 +41,9 @@ class TestPaymentOrderInbound(TestPaymentOrderInboundBase): grouped_moves = self.inbound_order.grouped_move_ids self.assertTrue(grouped_moves) self.assertTrue(grouped_moves.line_ids[0].reconciled) + self.assertTrue( + all( + x.date_maturity == fields.Date.from_string("2024-08-01") + for x in grouped_moves.line_ids + ) + )