[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 <smetl@users.noreply.github.com>
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user