File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212from . import ir_http_patch
1313from . import res_partner_mobile
1414from . import res_partner_system_id
15+ from . import spp_registry_id_system
Original file line number Diff line number Diff line change 1+ # Part of OpenSPP. See LICENSE file for full copyright and licensing details.
2+ """Protect system_id registry entries from manual edits."""
3+
4+ from odoo import _ , api , models
5+ from odoo .exceptions import UserError
6+
7+
8+ class SPPRegistryIdSystem (models .Model ):
9+ _inherit = "spp.registry.id"
10+
11+ @api .ondelete (at_uninstall = False )
12+ def _prevent_system_id_delete (self ):
13+ """Prevent deletion of system_id entries."""
14+ for rec in self :
15+ if rec .id_type_id and rec .id_type_id .code == "system_id" :
16+ raise UserError (_ ("System ID is auto-generated and cannot be deleted." ))
17+
18+ def write (self , vals ):
19+ """Prevent editing value of system_id entries."""
20+ if "value" in vals :
21+ for rec in self :
22+ if rec .id_type_id and rec .id_type_id .code == "system_id" :
23+ raise UserError (_ ("System ID is auto-generated and cannot be modified." ))
24+ return super ().write (vals )
You can’t perform that action at this time.
0 commit comments