Browse Source

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

pull/1431/head
Nikos Tsirintanis 6 years ago
committed by Laurent Mignon (ACSONE)
parent
commit
eeb1d6c641
  1. 16
      date_range/models/date_range.py

16
date_range/models/date_range.py

@ -36,8 +36,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)',
@ -141,3 +140,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