Update internal_property.py
This commit is contained in:
parent
1b1c0665a8
commit
3dd4c57c7d
|
|
@ -18,6 +18,27 @@ class Property(models.Model):
|
|||
_inherit = ['mail.thread', 'mail.activity.mixin']
|
||||
_order = "id desc"
|
||||
|
||||
# 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([
|
||||
('property_id', '=', 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': [('property_id', '=', self.id)],
|
||||
'context': dict(self.env.context),
|
||||
}
|
||||
|
||||
# Inherit the form view and add the button
|
||||
|
||||
@api.model
|
||||
def _default_image(self):
|
||||
image_path = get_module_resource('real_estate', 'static/src/img', 'default_logo.png')
|
||||
|
|
|
|||
Loading…
Reference in New Issue