[FIX] account: prevent resequence of an invoice if it's in a locked period
Currently, the user can resequence invoices that are in a locked period. This is not desirable, this commit fixes this. closes odoo/odoo#102469 X-original-commit: b1009e4aa514215054de44544a8914c16932f55e Related: odoo/enterprise#32423 Signed-off-by: Quentin De Paoli <qdp@odoo.com> Signed-off-by: Ricardo Gomes Rodrigues (rigr) <rigr@odoo.com>
This commit is contained in:
@@ -2179,8 +2179,11 @@ class AccountMove(models.Model):
|
||||
if (move.name and move.name != '/' and move.sequence_number not in (0, 1) and 'journal_id' in vals and move.journal_id.id != vals['journal_id']):
|
||||
raise UserError(_('You cannot edit the journal of an account move if it already has a sequence number assigned.'))
|
||||
|
||||
# You can't change the date of a move being inside a locked period.
|
||||
if move.state == "posted" and 'date' in vals and move.date != vals['date']:
|
||||
# You can't change the date or name of a move being inside a locked period.
|
||||
if move.state == "posted" and (
|
||||
('name' in vals and move.name != vals['name'])
|
||||
or ('date' in vals and move.date != vals['date'])
|
||||
):
|
||||
move._check_fiscalyear_lock_date()
|
||||
move.line_ids._check_tax_lock_date()
|
||||
|
||||
|
||||
@@ -197,6 +197,9 @@ class TestAccountMove(AccountTestInvoicingCommon):
|
||||
with self.assertRaises(UserError), self.cr.savepoint():
|
||||
self.test_move.date = fields.Date.from_string('2018-01-01')
|
||||
|
||||
with self.assertRaises(UserError), self.cr.savepoint():
|
||||
self.test_move.name = "Othername"
|
||||
|
||||
with self.assertRaises(UserError), self.cr.savepoint():
|
||||
self.test_move.unlink()
|
||||
|
||||
@@ -304,6 +307,9 @@ class TestAccountMove(AccountTestInvoicingCommon):
|
||||
with self.assertRaises(UserError), self.cr.savepoint():
|
||||
self.test_move.date = fields.Date.from_string('2018-01-01')
|
||||
|
||||
with self.assertRaises(UserError), self.cr.savepoint():
|
||||
self.test_move.name = "Othername"
|
||||
|
||||
with self.assertRaises(UserError), self.cr.savepoint():
|
||||
self.test_move.unlink()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user