Skip to content
Snippets Groups Projects
Commit c1bcf20a authored by Florent de Labarre's avatar Florent de Labarre Committed by GitHub
Browse files

[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#111184

Signed-off-by: default avatarNicolas Viseur (vin) <vin@odoo.com>
parent a7de35fd
No related branches found
No related tags found
No related merge requests found
......@@ -451,8 +451,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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment