diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index f64791e1e20..2f9bba28fe7 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -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() diff --git a/addons/account/tests/test_account_move_entry.py b/addons/account/tests/test_account_move_entry.py index eafc065d0ce..f0ece9ccfa4 100644 --- a/addons/account/tests/test_account_move_entry.py +++ b/addons/account/tests/test_account_move_entry.py @@ -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()