From 774ca18fd70f4d4a3523cf3e97014b33489b7034 Mon Sep 17 00:00:00 2001 From: Nikos Tsirintanis Date: Thu, 4 Oct 2018 15:17:33 +0200 Subject: [PATCH 1/8] [IMP] Added hierarchical feature for date_range, via parent_id --- date_range/models/date_range.py | 2 ++ date_range/readme/CONTRIBUTORS.rst | 1 + date_range/tests/test_date_range.py | 48 ++++++++++++++++++++++++++++ date_range/views/date_range_view.xml | 2 ++ 4 files changed, 53 insertions(+) diff --git a/date_range/models/date_range.py b/date_range/models/date_range.py index 29da5b600..a88128013 100644 --- a/date_range/models/date_range.py +++ b/date_range/models/date_range.py @@ -31,6 +31,8 @@ class DateRange(models.Model): active = fields.Boolean( help="The active field allows you to hide the date range without " "removing it.", default=True) + parent_id = fields.Many2one( + comodel_name='date.range', string="Parent", index=1) _sql_constraints = [ ('date_range_uniq', 'unique (name,type_id, company_id)', diff --git a/date_range/readme/CONTRIBUTORS.rst b/date_range/readme/CONTRIBUTORS.rst index 38b10b316..72039de31 100644 --- a/date_range/readme/CONTRIBUTORS.rst +++ b/date_range/readme/CONTRIBUTORS.rst @@ -2,3 +2,4 @@ * Alexis de Lattre * Miquel Raïch * Andrea Stirpe +* Nikos Tsirintanis diff --git a/date_range/tests/test_date_range.py b/date_range/tests/test_date_range.py index 1b774b6f2..55912fc53 100644 --- a/date_range/tests/test_date_range.py +++ b/date_range/tests/test_date_range.py @@ -129,3 +129,51 @@ class DateRangeTest(TransactionCase): 'type_id': self.typeB.id, 'company_id': self.company_2.id, }) + + def test_parent_id(self): + date_range_type = self.env['date.range.type'] + parent = self.date_range.create({ + 'name': 'FS2018', + 'date_start': '2018-01-01', + 'date_end': '2018-12-31', + 'type_id': self.type.id, + }) + # Check here that a validation error is thrown + # when parent and child have same type_id + with self.assertRaises(ValidationError): + self.date_range.create({ + 'name': 'FS2018-period1', + 'date_start': '2018-01-01', + 'date_end': '2018-04-30', + 'type_id': self.type.id, + 'parent_id': parent.id, + }) + type_block = date_range_type.create({ + 'name': 'FS2018-type_block', + 'company_id': False, + 'allow_overlap': False, + }) + period1 = self.date_range.create({ + 'name': 'FS2018-period1', + 'date_start': '2018-01-01', + 'date_end': '2018-04-30', + 'type_id': type_block.id, + 'parent_id': parent.id, + }) + # Check here that a validation error is thrown + # when child periods overlap + with self.assertRaises(ValidationError) as cm, self.env.cr.savepoint(): + self.date_range.create({ + 'name': 'FS2018-period2', + 'date_start': '2018-02-01', + 'date_end': '2018-03-15', + 'type_id': type_block.id, + 'parent_id': parent.id, + }) + self.assertEqual( + cm.exception.name, + 'FS2018-period2 overlaps FS2018-period1' + ) + # Ensure here that parent and children are of different type + self.assertNotEqual(parent.type_id, period1.type_id) + self.assertEqual(parent.type_id, period1.parent_id.type_id) diff --git a/date_range/views/date_range_view.xml b/date_range/views/date_range_view.xml index 97e627e6a..c7506abbb 100644 --- a/date_range/views/date_range_view.xml +++ b/date_range/views/date_range_view.xml @@ -10,6 +10,7 @@ + @@ -25,6 +26,7 @@ + From 18075ff3c1301f09799b9d0150f55619aa0b1521 Mon Sep 17 00:00:00 2001 From: Nikos Tsirintanis Date: Mon, 8 Oct 2018 12:23:20 +0200 Subject: [PATCH 2/8] [ADD] Constraint on date range of childs with respect to date range of parent --- date_range/models/date_range.py | 25 ++++++++++++++ date_range/tests/test_date_range.py | 51 +++++++++++++++++++++++------ 2 files changed, 66 insertions(+), 10 deletions(-) diff --git a/date_range/models/date_range.py b/date_range/models/date_range.py index a88128013..9ea9f84ed 100644 --- a/date_range/models/date_range.py +++ b/date_range/models/date_range.py @@ -55,6 +55,31 @@ class DateRange(models.Model): _('The Company in the Date Range and in ' 'Date Range Type must be the same.')) + @api.constrains('parent_id', 'date_start', 'date_end') + def _validate_child_range(self): + for this in self: + if not this.parent_id: + continue + start = this.parent_id.date_start <= this.date_start + end = this.parent_id.date_end >= this.date_end + child_range = start and end + if not child_range: + if (not start) and end: + text = _("Start dates are not compatible (%s < %s)") % ( + this.date_start, this.parent_id.date_start) + elif (not end) and start: + text = _("End dates are not compatible (%s > %s)") % ( + this.date_end, this.parent_id.date_end) + else: + text = _("%s range not in %s - %s") % ( + this.name, + this.parent_id.date_start, + this.parent_id.date_end, + ) + raise ValidationError( + _("%s not a subrange of %s: " + text) % ( + this.name, this.parent_id.name)) + @api.constrains('type_id', 'date_start', 'date_end', 'company_id') def _validate_range(self): for this in self: diff --git a/date_range/tests/test_date_range.py b/date_range/tests/test_date_range.py index 55912fc53..d19ff6fed 100644 --- a/date_range/tests/test_date_range.py +++ b/date_range/tests/test_date_range.py @@ -138,21 +138,52 @@ class DateRangeTest(TransactionCase): 'date_end': '2018-12-31', 'type_id': self.type.id, }) - # Check here that a validation error is thrown - # when parent and child have same type_id - with self.assertRaises(ValidationError): - self.date_range.create({ - 'name': 'FS2018-period1', - 'date_start': '2018-01-01', - 'date_end': '2018-04-30', - 'type_id': self.type.id, - 'parent_id': parent.id, - }) type_block = date_range_type.create({ 'name': 'FS2018-type_block', 'company_id': False, 'allow_overlap': False, }) + # Check here all three validation errors thrown + # when child range is not a subrange of parent + with self.assertRaises(ValidationError) as cm, self.env.cr.savepoint(): + self.date_range.create({ + 'name': 'FS2018-period1', + 'date_start': '2018-06-06', + 'date_end': '2019-01-02', + 'type_id': type_block.id, + 'parent_id': parent.id, + }) + self.assertEqual( + cm.exception.name, + 'FS2018-period1 not a subrange of FS2018: ' + 'End dates are not compatible (2019-01-02 > 2018-12-31)' + ) + with self.assertRaises(ValidationError) as cm, self.env.cr.savepoint(): + self.date_range.create({ + 'name': 'FS2018-period1', + 'date_start': '2017-06-06', + 'date_end': '2018-01-02', + 'type_id': type_block.id, + 'parent_id': parent.id, + }) + self.assertEqual( + cm.exception.name, + 'FS2018-period1 not a subrange of FS2018: ' + 'Start dates are not compatible (2017-06-06 < 2018-01-01)' + ) + with self.assertRaises(ValidationError) as cm, self.env.cr.savepoint(): + self.date_range.create({ + 'name': 'FS2018-period1', + 'date_start': '2017-06-06', + 'date_end': '2019-01-02', + 'type_id': type_block.id, + 'parent_id': parent.id, + }) + self.assertEqual( + cm.exception.name, + 'FS2018-period1 not a subrange of FS2018: ' + 'FS2018-period1 range not in 2018-01-01 - 2018-12-31' + ) period1 = self.date_range.create({ 'name': 'FS2018-period1', 'date_start': '2018-01-01', From 5042760a362e6c7abc6998d56de2471e9a07036f Mon Sep 17 00:00:00 2001 From: Nikos Tsirintanis Date: Mon, 15 Oct 2018 13:18:11 +0200 Subject: [PATCH 3/8] [ADD] parent_type_id for domain in parent-child(s) relation. --- date_range/models/date_range.py | 9 +++- date_range/models/date_range_type.py | 17 ++++++++ date_range/tests/test_date_range.py | 65 ++++++++++++++++++++++++++-- date_range/views/date_range_view.xml | 4 ++ 4 files changed, 91 insertions(+), 4 deletions(-) diff --git a/date_range/models/date_range.py b/date_range/models/date_range.py index 9ea9f84ed..c8403ea8d 100644 --- a/date_range/models/date_range.py +++ b/date_range/models/date_range.py @@ -31,8 +31,15 @@ class DateRange(models.Model): active = fields.Boolean( help="The active field allows you to hide the date range without " "removing it.", default=True) + parent_type_id = fields.Many2one( + related='type_id.parent_type_id', + store=True, + readonly=True) parent_id = fields.Many2one( - comodel_name='date.range', string="Parent", index=1) + comodel_name='date.range', string="Parent", + domain="['|', ('type_id.parent_type_id', '!=', parent_type_id), " + "('parent_type_id', '=', False)]", + index=1) _sql_constraints = [ ('date_range_uniq', 'unique (name,type_id, company_id)', diff --git a/date_range/models/date_range_type.py b/date_range/models/date_range_type.py index 3d14ff467..575fdeb2f 100644 --- a/date_range/models/date_range_type.py +++ b/date_range/models/date_range_type.py @@ -26,6 +26,9 @@ class DateRangeType(models.Model): comodel_name='res.company', string='Company', index=1, default=_default_company) date_range_ids = fields.One2many('date.range', 'type_id', string='Ranges') + parent_type_id = fields.Many2one( + comodel_name='date.range.type', + index=1) _sql_constraints = [ ('date_range_type_uniq', 'unique (name,company_id)', @@ -44,3 +47,17 @@ class DateRangeType(models.Model): _('You cannot change the company, as this ' 'Date Range Type is assigned to Date Range ' '(%s).') % (rec.date_range_ids.name_get()[0][1])) + + @api.constrains('parent_type_id') + def _validate_parent_type_id(self): + for record in self: + parent = record + while parent: + if not parent.parent_type_id: + break + if record.parent_type_id == parent: + raise ValidationError( + _("A type parent can not have a parent:" + " %s can not have %s as parent") % ( + parent.name, record.name)) + parent = parent.parent_type_id diff --git a/date_range/tests/test_date_range.py b/date_range/tests/test_date_range.py index d19ff6fed..eb7d881b9 100644 --- a/date_range/tests/test_date_range.py +++ b/date_range/tests/test_date_range.py @@ -184,7 +184,7 @@ class DateRangeTest(TransactionCase): 'FS2018-period1 not a subrange of FS2018: ' 'FS2018-period1 range not in 2018-01-01 - 2018-12-31' ) - period1 = self.date_range.create({ + self.date_range.create({ 'name': 'FS2018-period1', 'date_start': '2018-01-01', 'date_end': '2018-04-30', @@ -205,6 +205,65 @@ class DateRangeTest(TransactionCase): cm.exception.name, 'FS2018-period2 overlaps FS2018-period1' ) + + def test_parent_type_id(self): + """Check domain and constraint between parent and child types""" + date_range_type = self.env['date.range.type'] + # First create a parent type + parent_type = date_range_type.create({ + 'name': 'FS2018_parent_type', + 'parent_type_id': False, + }) + # catch here the validation error when assigning + # a date_range_type parent, to another parent(self included) + with self.assertRaises(ValidationError)as cm, self.env.cr.savepoint(): + parent_type.write({ + 'parent_type_id': parent_type.id, + }) + self.assertEqual( + cm.exception.name, + 'A type parent can not have a parent:' + ' FS2018_parent_type can not have FS2018_parent_type as parent' + ) + # Then, add a child type + child_type = date_range_type.create({ + 'name': 'FS2018_child_type', + 'parent_type_id': parent_type.id, + }) + # Now create a parent range + parent_range = self.date_range.create({ + 'name': 'FS2018', + 'date_start': '2018-01-01', + 'date_end': '2018-12-31', + 'type_id': parent_type.id, + }) + # and two child ranges + child_range1 = self.date_range.create({ + 'name': 'FS2018-child1', + 'date_start': '2018-01-01', + 'date_end': '2018-04-30', + 'type_id': child_type.id, + 'parent_id': parent_range.id, + }) + child_range2 = self.date_range.create({ + 'name': 'FS2018-child2', + 'date_start': '2018-05-01', + 'date_end': '2018-06-30', + 'type_id': child_type.id, + 'parent_id': parent_range.id, + }) + # and check how parent_type_id behaves + self.assertEqual(parent_type, child_range1.parent_type_id) + self.assertEqual( + child_range1.parent_type_id, + child_range2.parent_type_id + ) # Ensure here that parent and children are of different type - self.assertNotEqual(parent.type_id, period1.type_id) - self.assertEqual(parent.type_id, period1.parent_id.type_id) + self.assertNotEqual( + parent_range.type_id, + child_range1.type_id + ) + self.assertEqual( + parent_range.type_id, + child_range2.parent_id.type_id + ) diff --git a/date_range/views/date_range_view.xml b/date_range/views/date_range_view.xml index c7506abbb..ceed0e194 100644 --- a/date_range/views/date_range_view.xml +++ b/date_range/views/date_range_view.xml @@ -10,6 +10,7 @@ + @@ -26,6 +27,7 @@ + @@ -40,6 +42,7 @@ + @@ -53,6 +56,7 @@ + From 6b2d4d868019f54b612dd1b651d5fca5dfebe3f7 Mon Sep 17 00:00:00 2001 From: Nikos Tsirintanis Date: Mon, 29 Oct 2018 13:17:26 +0100 Subject: [PATCH 4/8] [FIX] Corrected parent-child constraints and warning messages --- date_range/models/date_range.py | 38 ++++++++++++++++++---------- date_range/models/date_range_type.py | 6 ++--- date_range/tests/test_date_range.py | 11 ++++---- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/date_range/models/date_range.py b/date_range/models/date_range.py index c8403ea8d..02870b5b4 100644 --- a/date_range/models/date_range.py +++ b/date_range/models/date_range.py @@ -37,8 +37,6 @@ class DateRange(models.Model): readonly=True) parent_id = fields.Many2one( comodel_name='date.range', string="Parent", - domain="['|', ('type_id.parent_type_id', '!=', parent_type_id), " - "('parent_type_id', '=', False)]", index=1) _sql_constraints = [ @@ -71,21 +69,35 @@ class DateRange(models.Model): end = this.parent_id.date_end >= this.date_end child_range = start and end if not child_range: + text_dict = { + 'name': this.name, + 'start': this.date_start, + 'end': this.date_end, + 'parent_name': this.parent_id.name, + 'parent_start': this.parent_id.date_start, + 'parent_end': this.parent_id.date_end, + } if (not start) and end: - text = _("Start dates are not compatible (%s < %s)") % ( - this.date_start, this.parent_id.date_start) + text = _( + "Start date %(start)s of %(name)s must be greater than" + " or equal to " + "start date %(parent_start)s of %(parent_name)s" + ) % text_dict elif (not end) and start: - text = _("End dates are not compatible (%s > %s)") % ( - this.date_end, this.parent_id.date_end) + text = _( + "End date %(end)s of %(name)s must be smaller than" + " or equal to " + "end date %(parent_end)s of %(parent_name)s" + ) % text_dict else: - text = _("%s range not in %s - %s") % ( - this.name, - this.parent_id.date_start, - this.parent_id.date_end, - ) + text = _( + "%(name)s range not in " + "%(parent_start)s - %(parent_end)s" + ) % text_dict raise ValidationError( - _("%s not a subrange of %s: " + text) % ( - this.name, this.parent_id.name)) + _("%(name)s not a subrange of" + " %(parent_name)s: " % text_dict) + text + ) @api.constrains('type_id', 'date_start', 'date_end', 'company_id') def _validate_range(self): diff --git a/date_range/models/date_range_type.py b/date_range/models/date_range_type.py index 575fdeb2f..6d83ab848 100644 --- a/date_range/models/date_range_type.py +++ b/date_range/models/date_range_type.py @@ -55,9 +55,7 @@ class DateRangeType(models.Model): while parent: if not parent.parent_type_id: break - if record.parent_type_id == parent: + if parent.parent_type_id == record: raise ValidationError( - _("A type parent can not have a parent:" - " %s can not have %s as parent") % ( - parent.name, record.name)) + _("A type can not have itself as parent or child")) parent = parent.parent_type_id diff --git a/date_range/tests/test_date_range.py b/date_range/tests/test_date_range.py index eb7d881b9..9babe6a1d 100644 --- a/date_range/tests/test_date_range.py +++ b/date_range/tests/test_date_range.py @@ -156,7 +156,8 @@ class DateRangeTest(TransactionCase): self.assertEqual( cm.exception.name, 'FS2018-period1 not a subrange of FS2018: ' - 'End dates are not compatible (2019-01-02 > 2018-12-31)' + 'End date 2019-01-02 of FS2018-period1 must be ' + 'smaller than or equal to end date 2018-12-31 of FS2018' ) with self.assertRaises(ValidationError) as cm, self.env.cr.savepoint(): self.date_range.create({ @@ -169,7 +170,8 @@ class DateRangeTest(TransactionCase): self.assertEqual( cm.exception.name, 'FS2018-period1 not a subrange of FS2018: ' - 'Start dates are not compatible (2017-06-06 < 2018-01-01)' + 'Start date 2017-06-06 of FS2018-period1 must be ' + 'greater than or equal to start date 2018-01-01 of FS2018' ) with self.assertRaises(ValidationError) as cm, self.env.cr.savepoint(): self.date_range.create({ @@ -215,15 +217,14 @@ class DateRangeTest(TransactionCase): 'parent_type_id': False, }) # catch here the validation error when assigning - # a date_range_type parent, to another parent(self included) + # a child as its own parent, or vise-versa (predestination) with self.assertRaises(ValidationError)as cm, self.env.cr.savepoint(): parent_type.write({ 'parent_type_id': parent_type.id, }) self.assertEqual( cm.exception.name, - 'A type parent can not have a parent:' - ' FS2018_parent_type can not have FS2018_parent_type as parent' + 'A type can not have itself as parent or child' ) # Then, add a child type child_type = date_range_type.create({ From eeb1d6c641f89111e5654d5f2658cb9cb4a5c3e4 Mon Sep 17 00:00:00 2001 From: Nikos Tsirintanis Date: Tue, 30 Oct 2018 14:37:04 +0100 Subject: [PATCH 5/8] [FIX] computing domain for parent_id in date.range dynamically --- date_range/models/date_range.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/date_range/models/date_range.py b/date_range/models/date_range.py index 02870b5b4..38986d6dc 100644 --- a/date_range/models/date_range.py +++ b/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), + ] + } + } From c9aa4805b490b022f0ae0b2435b0fb6d6ab9ad3a Mon Sep 17 00:00:00 2001 From: Ronald Portier Date: Wed, 31 Oct 2018 11:58:26 +0100 Subject: [PATCH 6/8] [IMP] date_range. Provide sensible domain for parent_id. --- date_range/models/date_range.py | 33 +++++++++++++++++++--------- date_range/views/date_range_view.xml | 10 +++++++-- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/date_range/models/date_range.py b/date_range/models/date_range.py index 38986d6dc..55cdedb19 100644 --- a/date_range/models/date_range.py +++ b/date_range/models/date_range.py @@ -142,14 +142,27 @@ class DateRange(models.Model): (field_name, '<=', self.date_end)] @api.multi - @api.onchange('type_id') + @api.onchange('company_id', 'type_id', 'date_start', 'date_end') def onchange_type_id(self): - return { - 'domain': { - 'parent_id': [ - '|', - ('parent_type_id', '=', False), - ('type_id', '=', self.type_id.parent_type_id.id), - ] - } - } + """The type_id and the dates determine the choices for parent.""" + domain = [] + if self.company_id: + domain.append(('company_id', '=', self.company_id.id)) + if self.parent_type_id: + domain.append(('type_id', '=', self.parent_type_id.id)) + if self.date_start: + domain.append('|') + domain.append(('date_start', '<=', self.date_start)) + domain.append(('date_start', '=', False)) + if self.date_end: + domain.append('|') + domain.append(('date_end', '>=', self.date_end)) + domain.append(('date_end', '=', False)) + if domain: + # If user did not select a parent already, autoselect the last + # (ordered by date_start) or only parent that applies. + if self.type_id and self.date_start and not self.parent_id: + possible_parent = self.search( + domain, limit=1, order='date_start desc') + self.parent_id = possible_parent # can be empty! + return {'domain': {'parent_id': domain}} diff --git a/date_range/views/date_range_view.xml b/date_range/views/date_range_view.xml index ceed0e194..a965dc2a8 100644 --- a/date_range/views/date_range_view.xml +++ b/date_range/views/date_range_view.xml @@ -11,7 +11,10 @@ - + @@ -28,7 +31,10 @@ - + From b39a0c4420f0e2b259b933c03b0a42d43860f6cb Mon Sep 17 00:00:00 2001 From: Nikos Tsirintanis Date: Wed, 31 Oct 2018 16:58:49 +0100 Subject: [PATCH 7/8] [IMP] using parent_id in date_range generator wizard (amended with unit test) --- date_range/tests/test_date_range_generator.py | 38 +++++++++++++++++++ date_range/wizard/date_range_generator.py | 22 ++++++++++- date_range/wizard/date_range_generator.xml | 1 + 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/date_range/tests/test_date_range_generator.py b/date_range/tests/test_date_range_generator.py index 7764fd3e3..2ee643b6e 100644 --- a/date_range/tests/test_date_range_generator.py +++ b/date_range/tests/test_date_range_generator.py @@ -72,3 +72,41 @@ class DateRangeGeneratorTest(TransactionCase): 'count': 4, 'company_id': self.company_2.id, }) + + def test_generator_partner_id_domain(self): + """Check here domain returned for partner_id + in both date.range and date.range.generator""" + date_range = self.env['date.range'] + generator = self.env['date.range.generator'] + date_type = self.env['date.range.type'] + month_type = date_type.create({ + 'name': 'month type' + }) + day_type = date_type.create({ + 'name': 'day type', + 'parent_type_id': month_type.id, + }) + month_range = date_range.create({ + 'name': 'month range', + 'type_id': month_type.id, + 'date_start': '01-01-2050', + 'date_end': '02-01-2050', + }) + # now trigger onchange in generator, + # which would also trigger onchange in date_range + values = { + 'date_start': month_range.date_start, + 'type_id': day_type.id, + } + on_change = generator._onchange_spec() + domain = generator.onchange( + values, + ['type_id', 'date_start'], + on_change, + ) + # check that with this search domain, + # only the month_range record is returned. + self.assertEqual( + date_range.search(domain['domain']['parent_id']), + month_range, + ) diff --git a/date_range/wizard/date_range_generator.py b/date_range/wizard/date_range_generator.py index 534263e0c..a32f42ea9 100644 --- a/date_range/wizard/date_range_generator.py +++ b/date_range/wizard/date_range_generator.py @@ -38,6 +38,8 @@ class DateRangeGenerator(models.TransientModel): duration_count = fields.Integer('Duration', required=True) count = fields.Integer( string="Number of ranges to generate", required=True) + parent_id = fields.Many2one( + comodel_name='date.range', string="Parent", index=1) @api.multi def _compute_date_ranges(self): @@ -60,7 +62,8 @@ class DateRangeGenerator(models.TransientModel): 'date_start': date_start, 'date_end': date_end, 'type_id': self.type_id.id, - 'company_id': self.company_id.id}) + 'company_id': self.company_id.id, + 'parent_id': self.parent_id.id}) return date_ranges @api.onchange('company_id') @@ -88,3 +91,20 @@ class DateRangeGenerator(models.TransientModel): self.env['date.range'].create(dr) return self.env['ir.actions.act_window'].for_xml_id( module='date_range', xml_id='date_range_action') + + @api.multi + @api.onchange('type_id', 'date_start') + def onchange_type_id(self): + self.ensure_one() + date_range = self.env['date.range'] + values = { + 'date_start': self.date_start, + 'type_id': self.type_id.id, + } + on_change = date_range._onchange_spec() + domain = date_range.onchange( + values, + ['type_id', 'date_start'], + on_change, + ) + return domain diff --git a/date_range/wizard/date_range_generator.xml b/date_range/wizard/date_range_generator.xml index 73551151b..aea993b12 100644 --- a/date_range/wizard/date_range_generator.xml +++ b/date_range/wizard/date_range_generator.xml @@ -15,6 +15,7 @@ + From ed05e386ac237f5b8f0344e5f6e7088609aae639 Mon Sep 17 00:00:00 2001 From: "Laurent Mignon (ACSONE)" Date: Mon, 19 Nov 2018 17:33:45 +0100 Subject: [PATCH 8/8] [REL] date_range: 10.0.3.0.0 --- date_range/__manifest__.py | 2 +- date_range/readme/HISTORY.rst | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/date_range/__manifest__.py b/date_range/__manifest__.py index d5309e0b0..9076cd663 100644 --- a/date_range/__manifest__.py +++ b/date_range/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Date Range", "summary": "Manage all kind of date range", - "version": "10.0.2.0.1", + "version": "10.0.3.0.0", "category": "Uncategorized", "website": "https://odoo-community.org/", "author": "ACSONE SA/NV, Odoo Community Association (OCA)", diff --git a/date_range/readme/HISTORY.rst b/date_range/readme/HISTORY.rst index 9dcf0ba1d..4b5578a13 100644 --- a/date_range/readme/HISTORY.rst +++ b/date_range/readme/HISTORY.rst @@ -1,3 +1,9 @@ +10.0.3.0.0 (2019-11-20) +~~~~~~~~~~~~~~~~~~~~~~~ + +* [IMP] Added hierarchical feature for date_range. + (`#1380 `_) + 10.0.2.0.1 (2018-11-19) ~~~~~~~~~~~~~~~~~~~~~~~