Update re_unit.py
This commit is contained in:
parent
3dd4c57c7d
commit
b6d9961bf2
|
|
@ -72,7 +72,25 @@ class Unit(models.Model):
|
|||
_sql_constraints = [
|
||||
('name', 'unique(name)', _('Name must be unique.')),
|
||||
]
|
||||
# Smart button to count related maintenance records
|
||||
maintenance_count = fields.Integer(string="Maintenance Count", compute='_compute_maintenance_count')
|
||||
|
||||
def _compute_maintenance_count(self):
|
||||
for record in self:
|
||||
record.maintenance_count = self.env['property.management.maintenance'].search_count([
|
||||
('unit_ids', 'in', record.id)
|
||||
])
|
||||
|
||||
def action_view_maintenance(self):
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'name': 'Maintenance',
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'property.management.maintenance',
|
||||
'domain': [('unit_ids', 'in', self.id)],
|
||||
'context': dict(self.env.context),
|
||||
}
|
||||
|
||||
@api.depends('state')
|
||||
def set_color(self):
|
||||
for record in self:
|
||||
|
|
|
|||
Loading…
Reference in New Issue