commit
195e2042fb
|
|
@ -175,7 +175,7 @@
|
|||
|
||||
<field name="property_id" required="1" attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||
<field name="unit_ids" domain="[('property_id', '=', property_id)]"
|
||||
attrs="{'required':[('renter_invoice', '=', True)], 'readonly':[('state','!=','draft')]}"
|
||||
attrs="{'readonly':[('state','!=','draft')]}"
|
||||
widget="many2many_tags"/>
|
||||
</group>
|
||||
<group>
|
||||
|
|
@ -252,4 +252,4 @@
|
|||
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
</odoo>
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@
|
|||
</button>
|
||||
|
||||
<button class="oe_stat_button" string="Documents" name="get_attachments" type="object" icon="fa-file-text-o"/>
|
||||
<button name="action_view_maintenance" type="object" class="oe_stat_button">
|
||||
<field name="maintenance_count" widget="statinfo" string="Maintenance"/>
|
||||
</button>
|
||||
|
||||
</div>
|
||||
<h4>
|
||||
|
|
|
|||
|
|
@ -25,6 +25,10 @@
|
|||
<span class="o_stat_text" attrs="{'invisible': [('unlock', '=', False)]}">Unlock</span>
|
||||
<span class="o_stat_text" attrs="{'invisible': [('unlock', '=', True)]}">Lock</span>
|
||||
</button>
|
||||
<!-- Add your buttons here -->
|
||||
<button name="action_view_maintenance" type="object" class="oe_stat_button">
|
||||
<field name="maintenance_count" widget="statinfo" string="Maintenance"/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<h4>
|
||||
|
|
|
|||
Loading…
Reference in New Issue