From d3df2b2c3a9dd9af1c36a597decfd27f4cb3e4cd Mon Sep 17 00:00:00 2001 From: "Andrea Grazioso (agr-odoo)" Date: Thu, 11 Aug 2022 15:46:24 +0000 Subject: [PATCH] [FIX] account: cash basis entry date MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Create an invoice in date1 with a tax due based on payment (cash basis) Create a credit note in date2 for the invoice (with date2 > date1) Set tax lock date in date3 (with today > date3 > date2 > date1) In the invoice add the credit note as payment The system will block the action, because the created cash basis entry would use as date the most recent between invoice and credit note, which is previous to the lock date. opw-2730106 closes odoo/odoo#98425 X-original-commit: 087e967f6ebf6e5829ec1d72a672841f8d543d4a Signed-off-by: William André (wan) --- addons/account/models/account_partial_reconcile.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_partial_reconcile.py b/addons/account/models/account_partial_reconcile.py index c18b76d756a..b449c745401 100644 --- a/addons/account/models/account_partial_reconcile.py +++ b/addons/account/models/account_partial_reconcile.py @@ -383,6 +383,7 @@ class AccountPartialReconcile(models.Model): :return: The newly created journal entries. ''' tax_cash_basis_values_per_move = self._collect_tax_cash_basis_values() + today = fields.Date.context_today(self) moves_to_create = [] to_reconcile_after = [] @@ -394,9 +395,10 @@ class AccountPartialReconcile(models.Model): partial = partial_values['partial'] # Init the journal entry. + move_date = partial.max_date if partial.max_date > (move.company_id.period_lock_date or date.min) else today move_vals = { 'move_type': 'entry', - 'date': partial.max_date, + 'date': move_date, 'ref': move.name, 'journal_id': partial.company_id.tax_cash_basis_journal_id.id, 'line_ids': [],