Update internal_property.py

This commit is contained in:
zainab2097 2024-08-08 14:59:02 +03:00 committed by GitHub
parent 1b1c0665a8
commit 3dd4c57c7d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 21 additions and 0 deletions

View File

@ -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')