{"record":{"id":"34e0818aef995553","repo":"odoo/odoo","slug":"you-cannot-modify-the-field-s-of-a-journal-that-a","errorCode":null,"errorMessage":"You cannot modify the field %s of a journal that already has accounting entries.","messagePattern":"You cannot modify the field (.+?) of a journal that already has accounting entries\\.","errorType":"exception","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"addons/account/models/account_journal.py","lineNumber":801,"sourceCode":"                        'company_id': company.id,\n                        'partner_id': company.partner_id.id,\n                    })\n            if 'currency_id' in vals:\n                if journal.bank_account_id:\n                    journal.bank_account_id.currency_id = vals['currency_id']\n            if 'bank_account_id' in vals:\n                if vals.get('bank_account_id'):\n                    bank_account = self.env['res.partner.bank'].browse(vals['bank_account_id'])\n                    if bank_account.partner_id != company.partner_id:\n                        raise UserError(_(\"The partners of the journal's company and the related bank account mismatch.\"))\n            if 'restrict_mode_hash_table' in vals and not vals.get('restrict_mode_hash_table'):\n                domain = self.env['account.move']._get_move_hash_domain(\n                    common_domain=[('journal_id', '=', journal.id), ('inalterable_hash', '!=', False)]\n                )\n                journal_entry = self.env['account.move'].sudo().search_count(domain, limit=1)\n                if journal_entry:\n                    field_string = self._fields['restrict_mode_hash_table'].get_description(self.env)['string']\n                    raise UserError(_(\"You cannot modify the field %s of a journal that already has accounting entries.\", field_string))\n        result = super(AccountJournal, self).write(vals)\n\n        # Ensure alias coherency when changing type\n        if 'type' in vals and not self.env.context.get('account_journal_skip_alias_sync'):\n            for journal in self:\n                alias_vals = journal._alias_get_creation_values()\n                alias_vals = {\n                    'alias_defaults': alias_vals['alias_defaults'],\n                    'alias_name': alias_vals['alias_name'],\n                }\n                journal.update(alias_vals)\n\n        # Ensure the liquidity accounts are sharing the same foreign currency.\n        if 'currency_id' in vals:\n            for journal in self.filtered(lambda journal: journal.type in ('bank', 'cash', 'credit')):\n                journal.default_account_id.currency_id = journal.currency_id\n\n        # Create the bank_account_id if necessary","sourceCodeStart":783,"sourceCodeEnd":819,"githubUrl":"https://github.com/odoo/odoo/blob/1e661df964b1b264c9cef3ab28430d4785be3fda/addons/account/models/account_journal.py#L783-L819","documentation":"In write(), if 'restrict_mode_hash_table' is being turned off and the journal already has account.move rows matching _get_move_hash_domain (entries with inalterable_hash set), Odoo refuses with this UserError naming the field. Hashed (inalterable) entries were signed while locking was on, so disabling it retroactively would break the audit guarantee.","triggerScenarios":"journal.write({'restrict_mode_hash_table': False}) on a journal that has at least one entry with ('inalterable_hash', '!=', False); toggling 'Lock Hash Entries' off in the accounting lock settings after entries were hashed.","commonSituations":"Trying to relax fiscal-lock settings after enabling hashing; test databases that enabled hashing then wanted to edit entries; scripted setup flipping lock flags.","solutions":["Leave restrict_mode_hash_table enabled on journals that already produced hashed entries.","Create a new journal without hashing for editable entries and keep the hashed journal frozen.","In a disposable test database only, remove/RESET the hashed entries first (never in production — legal requirement in many jurisdictions)."],"exampleFix":"# before\njournal.write({'restrict_mode_hash_table': False})  # UserError: hashed entries exist\n\n# after\nhashed = env['account.move'].sudo().search_count(journal._get_move_hash_domain(\n    common_domain=[('journal_id', '=', journal.id), ('inalterable_hash', '!=', False)]), limit=1)\nif not hashed:\n    journal.write({'restrict_mode_hash_table': False})","handlingStrategy":"validation","validationCode":"hashed = env['account.move'].sudo().search_count(\n    env['account.move']._get_move_hash_domain(\n        common_domain=[('journal_id', '=', journal.id), ('inalterable_hash', '!=', False)]),\n    limit=1)\nif not hashed:\n    journal.write({'restrict_mode_hash_table': False})","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Decide hashing policy at journal setup, before entries exist.","Never attempt to disable hashing on journals with inalterable_hash entries in production.","Use a separate non-hashed journal if editable entries are required."],"tags":["odoo","accounting","hash-lock","audit","write-guard"],"backgroundTag":null,"analyzedSha":"1e661df964b1b264c9cef3ab28430d4785be3fda","analyzedAt":"2026-08-15T05:22:16.142Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}