From b42313474e696f594fefdc9bdde0bde2b41b6dfc Mon Sep 17 00:00:00 2001 From: wan Date: Fri, 4 Jun 2021 14:47:56 +0000 Subject: [PATCH] [FIX] account: do not override accounting date for vendor bills MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The accounting date must be today by default and changing the bill date must not affect that. Kind of followup after this change of behavior fcaa54939e9a4f0dd5e47cd0ccffe7aa24bd451c task-2550985 closes odoo/odoo#71977 X-original-commit: c63af09774414a004ef34644b4f38b4fdb1d12bd Signed-off-by: Quentin De Paoli (qdp) Signed-off-by: William André (wan) --- addons/account/models/account_move.py | 7 +++++-- addons/account/tests/common.py | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 05979e25191..c9fa41290c8 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -381,9 +381,12 @@ class AccountMove(models.Model): if self.invoice_date: if not self.invoice_payment_term_id and (not self.invoice_date_due or self.invoice_date_due < self.invoice_date): self.invoice_date_due = self.invoice_date - if self.date != self.invoice_date: # Don't flag date as dirty if not needed + if ( + self.is_sale_document() and self.date != self.invoice_date + or self.is_purchase_document() and not self.date + ): self.date = self.invoice_date - self._onchange_currency() + self._onchange_currency() @api.onchange('journal_id') def _onchange_journal(self): diff --git a/addons/account/tests/common.py b/addons/account/tests/common.py index 6cbecc6ddcf..90f2df8702f 100644 --- a/addons/account/tests/common.py +++ b/addons/account/tests/common.py @@ -373,6 +373,7 @@ class AccountTestInvoicingCommon(TransactionCase): .with_company(company or cls.env.company) \ .with_context(default_move_type=move_type, account_predictive_bills_disable_prediction=True)) move_form.invoice_date = invoice_date or fields.Date.from_string('2019-01-01') + move_form.date = move_form.invoice_date move_form.partner_id = partner or cls.partner_a for product in (products or []):