Update re_unit
This commit is contained in:
parent
abda0a2f11
commit
a5e8266d92
|
|
@ -16,6 +16,8 @@ class Unit(models.Model):
|
||||||
_inherit = ['mail.thread', 'mail.activity.mixin']
|
_inherit = ['mail.thread', 'mail.activity.mixin']
|
||||||
_order = "id desc"
|
_order = "id desc"
|
||||||
|
|
||||||
|
|
||||||
|
attach_nbr = fields.Integer(compute='get_attachments')
|
||||||
active = fields.Boolean(default=True)
|
active = fields.Boolean(default=True)
|
||||||
unlock = fields.Boolean(default=True, string="Unlock")
|
unlock = fields.Boolean(default=True, string="Unlock")
|
||||||
name = fields.Char(string="Unit Name")
|
name = fields.Char(string="Unit Name")
|
||||||
|
|
@ -74,6 +76,16 @@ class Unit(models.Model):
|
||||||
]
|
]
|
||||||
# Smart button to count related maintenance records
|
# Smart button to count related maintenance records
|
||||||
maintenance_count = fields.Integer(string="Maintenance Count", compute='_compute_maintenance_count')
|
maintenance_count = fields.Integer(string="Maintenance Count", compute='_compute_maintenance_count')
|
||||||
|
def get_attachments(self):
|
||||||
|
action = self.env['ir.actions.act_window']._for_xml_id('base.action_attachment')
|
||||||
|
action['domain'] = str([('res_model', '=', 're.unit'),('res_id', 'in', self.ids)])
|
||||||
|
action['context'] = "{'default_res_model': '%s','default_res_id': %d}" % (self._name, self.id)
|
||||||
|
return action
|
||||||
|
def get_attachments(self):
|
||||||
|
res = super(Unit, self).get_attachments()
|
||||||
|
domain = [('res_model', '=', 're.unit'), ('res_id', '=', self.id)]
|
||||||
|
self.attach_nbr = self.env['ir.attachment'].search_count(domain)
|
||||||
|
return res
|
||||||
|
|
||||||
def _compute_maintenance_count(self):
|
def _compute_maintenance_count(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue