changes
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2026 Nexa Systems Inc.
|
||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class FpJurisdiction(models.Model):
|
||||
_name = 'fusion.plating.jurisdiction'
|
||||
_description = 'Fusion Plating - Jurisdiction'
|
||||
_parent_store = True
|
||||
_parent_name = 'parent_id'
|
||||
_order = 'parent_path, name'
|
||||
_rec_name = 'display_name'
|
||||
|
||||
name = fields.Char(string='Name', required=True, translate=True)
|
||||
code = fields.Char(string='Code', required=True)
|
||||
parent_id = fields.Many2one('fusion.plating.jurisdiction', string='Parent', ondelete='restrict', index=True)
|
||||
parent_path = fields.Char(index=True, unaccent=False)
|
||||
child_ids = fields.One2many('fusion.plating.jurisdiction', 'parent_id', string='Children')
|
||||
level = fields.Selection(
|
||||
[('country', 'Country'), ('province', 'Province / State'), ('municipality', 'Municipality')],
|
||||
string='Level', required=True, default='country',
|
||||
)
|
||||
active = fields.Boolean(string='Active', default=True)
|
||||
display_name = fields.Char(compute='_compute_display_name', store=True, recursive=True)
|
||||
|
||||
_sql_constraints = [
|
||||
('fp_jurisdiction_code_uniq', 'unique(code)', 'Jurisdiction code must be unique.'),
|
||||
]
|
||||
|
||||
@api.depends('name', 'code', 'parent_id.display_name')
|
||||
def _compute_display_name(self):
|
||||
for rec in self:
|
||||
if rec.parent_id:
|
||||
rec.display_name = f'{rec.parent_id.display_name} / {rec.name}'
|
||||
else:
|
||||
rec.display_name = rec.name or ''
|
||||
Reference in New Issue
Block a user