Browse Source

[FIX] computing domain for parent_id in date.range dynamically

pull/47/head
Nikos Tsirintanis 6 years ago
parent
commit
f0c95c2fda
  1. 16
      date_range/models/date_range.py

16
date_range/models/date_range.py

@ -35,8 +35,7 @@ class DateRange(models.Model):
store=True,
readonly=True)
parent_id = fields.Many2one(
comodel_name='date.range', string="Parent",
index=1)
comodel_name='date.range', string="Parent", index=1)
_sql_constraints = [
('date_range_uniq', 'unique (name,type_id, company_id)',
@ -140,3 +139,16 @@ class DateRange(models.Model):
self.ensure_one()
return [(field_name, '>=', self.date_start),
(field_name, '<=', self.date_end)]
@api.multi
@api.onchange('type_id')
def onchange_type_id(self):
return {
'domain': {
'parent_id': [
'|',
('parent_type_id', '=', False),
('type_id', '=', self.type_id.parent_type_id.id),
]
}
}
Loading…
Cancel
Save