[FIX] account: prevent change restrict mode hash

In case of an user can edit account.journal and have no access of all account.move of this journal, the user can set to false this field : restrict_mode_hash_table.

closes odoo/odoo#112028

X-original-commit: c1bcf20a4c58516e484417885f47e32a8c192dc1
Signed-off-by: Nicolas Viseur (vin) <vin@odoo.com>
This commit is contained in:
Florent de Labarre
2023-02-07 08:40:49 +01:00
committed by GitHub
parent 30926d94e8
commit fdaae9f101
+2 -2
View File
@@ -546,8 +546,8 @@ class AccountJournal(models.Model):
if bank_account.partner_id != company.partner_id:
raise UserError(_("The partners of the journal's company and the related bank account mismatch."))
if 'restrict_mode_hash_table' in vals and not vals.get('restrict_mode_hash_table'):
journal_entry = self.env['account.move'].search([('journal_id', '=', self.id), ('state', '=', 'posted'), ('secure_sequence_number', '!=', 0)], limit=1)
if len(journal_entry) > 0:
journal_entry = self.env['account.move'].sudo().search([('journal_id', '=', self.id), ('state', '=', 'posted'), ('secure_sequence_number', '!=', 0)], limit=1)
if journal_entry:
field_string = self._fields['restrict_mode_hash_table'].get_description(self.env)['string']
raise UserError(_("You cannot modify the field %s of a journal that already has accounting entries.", field_string))
result = super(AccountJournal, self).write(vals)