From 3405ca4d0b0a023fefb67da497e5b228f1183000 Mon Sep 17 00:00:00 2001 From: Olivier Colson Date: Fri, 30 Aug 2019 14:44:04 +0000 Subject: [PATCH] [FIX] account: tax lock date: check constraint when saving instead of posting Makes 12.4 compatible with these changes, from 12.3: https://github.com/odoo/odoo/pull/36289 closes odoo/odoo#36318 Signed-off-by: Laurent Smet --- addons/account/models/account_move.py | 22 ------------------- .../account/tests/test_account_move_entry.py | 3 --- 2 files changed, 25 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 2f5d405b224..0aece001627 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -1334,27 +1334,6 @@ class AccountMove(models.Model): raise UserError(message) return True - @api.multi - def _check_tax_lock_date(self): - if not self: - return - - self._cr.execute(''' - SELECT move.id, company.tax_lock_date - FROM account_move move - JOIN account_journal journal ON journal.id = move.journal_id - JOIN res_company company ON company.id = journal.company_id - WHERE move.id IN %s - AND move.date < company.tax_lock_date - ''', [tuple(self.ids)]) - - query_res = self._cr.fetchone() - if query_res: - raise UserError(_(''' - The operation is refused as it would impact an already issued tax statement. - Please change the journal entry date or the tax lock date set in the settings (%s) to proceed - ''' % query_res[1])) - @api.multi def _check_move_consistency(self): for move in self: @@ -1916,7 +1895,6 @@ class AccountMove(models.Model): move.invoice_date = fields.Date.context_today(self) move.with_context(check_move_validity=False)._onchange_invoice_date() - self._check_tax_lock_date() self._check_move_consistency() # Create the analytic lines in batch is faster as it leads to less cache invalidation. self.mapped('line_ids').create_analytic_lines() diff --git a/addons/account/tests/test_account_move_entry.py b/addons/account/tests/test_account_move_entry.py index 82df20e3e0b..98f0f70a6e5 100644 --- a/addons/account/tests/test_account_move_entry.py +++ b/addons/account/tests/test_account_move_entry.py @@ -108,9 +108,6 @@ class TestAccountMove(InvoiceTestCommon): self.cr.execute('ROLLBACK TO SAVEPOINT test_misc_tax_lock_date_1') - with self.assertRaises(UserError): - self.test_move.post() - def test_misc_unique_sequence_number(self): ''' Ensure two journal entries can't share the same name when using the same sequence. ''' self.test_move.post()