diff --git a/date_range/__init__.py b/date_range/__init__.py index faa4535..2b913a3 100644 --- a/date_range/__init__.py +++ b/date_range/__init__.py @@ -1,5 +1,5 @@ -# © 2016 ACSONE SA/NV () -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# © 2016 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from . import models from . import wizard diff --git a/date_range/__manifest__.py b/date_range/__manifest__.py index 32c4a02..347c72a 100644 --- a/date_range/__manifest__.py +++ b/date_range/__manifest__.py @@ -1,9 +1,9 @@ -# © 2016 ACSONE SA/NV () -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# © 2016 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "Date Range", "summary": "Manage all kind of date range", - "version": "11.0.2.0.1", + "version": "11.0.3.0.0", "category": "Uncategorized", "website": "https://github.com/oca/server-ux", "author": "ACSONE SA/NV, Odoo Community Association (OCA)", diff --git a/date_range/models/__init__.py b/date_range/models/__init__.py index 2464998..2fe8214 100644 --- a/date_range/models/__init__.py +++ b/date_range/models/__init__.py @@ -1,5 +1,5 @@ -# © 2016 ACSONE SA/NV () -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# © 2016 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from . import date_range_type from . import date_range diff --git a/date_range/models/date_range.py b/date_range/models/date_range.py index 221708c..4926f81 100644 --- a/date_range/models/date_range.py +++ b/date_range/models/date_range.py @@ -1,5 +1,5 @@ -# © 2016 ACSONE SA/NV () -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# © 2016 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import api, fields, models from odoo.tools.translate import _ diff --git a/date_range/models/date_range_type.py b/date_range/models/date_range_type.py index c575806..d1d0eb8 100644 --- a/date_range/models/date_range_type.py +++ b/date_range/models/date_range_type.py @@ -1,5 +1,5 @@ -# © 2016 ACSONE SA/NV () -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# © 2016 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import api, fields, models from odoo.tools.translate import _ diff --git a/date_range/readme/CONTRIBUTORS.rst b/date_range/readme/CONTRIBUTORS.rst index 1e9c5f7..72039de 100644 --- a/date_range/readme/CONTRIBUTORS.rst +++ b/date_range/readme/CONTRIBUTORS.rst @@ -1,8 +1,5 @@ * Laurent Mignon * Alexis de Lattre * Miquel Raïch -<<<<<<< HEAD * Andrea Stirpe -======= * Nikos Tsirintanis ->>>>>>> 72713cb6... [IMP] Added hierarchical feature for date_range, via parent_id diff --git a/date_range/tests/__init__.py b/date_range/tests/__init__.py index 974619e..c809177 100644 --- a/date_range/tests/__init__.py +++ b/date_range/tests/__init__.py @@ -1,5 +1,5 @@ -# © 2016 ACSONE SA/NV () -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# © 2016 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from . import test_date_range_type from . import test_date_range diff --git a/date_range/tests/test_date_range.py b/date_range/tests/test_date_range.py index 42f6135..814d63b 100644 --- a/date_range/tests/test_date_range.py +++ b/date_range/tests/test_date_range.py @@ -1,5 +1,5 @@ -# © 2016 ACSONE SA/NV () -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) +# © 2016 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) from odoo.tests.common import TransactionCase from odoo.exceptions import ValidationError diff --git a/date_range/tests/test_date_range_generator.py b/date_range/tests/test_date_range_generator.py index 4ff05de..e42064f 100644 --- a/date_range/tests/test_date_range_generator.py +++ b/date_range/tests/test_date_range_generator.py @@ -1,5 +1,5 @@ -# © 2016 ACSONE SA/NV () -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)nses/agpl). +# © 2016 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)nses/agpl). from odoo.tests.common import TransactionCase from odoo.exceptions import ValidationError @@ -73,3 +73,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/tests/test_date_range_type.py b/date_range/tests/test_date_range_type.py index 8178c09..ee492bf 100644 --- a/date_range/tests/test_date_range_type.py +++ b/date_range/tests/test_date_range_type.py @@ -1,5 +1,5 @@ -# © 2016 ACSONE SA/NV () -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) +# © 2016 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) from odoo.tests.common import TransactionCase from odoo.tools import mute_logger diff --git a/date_range/wizard/date_range_generator.py b/date_range/wizard/date_range_generator.py index 69ee851..9b912c4 100644 --- a/date_range/wizard/date_range_generator.py +++ b/date_range/wizard/date_range_generator.py @@ -37,6 +37,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): @@ -59,7 +61,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') @@ -87,3 +90,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 df1b06f..194347e 100644 --- a/date_range/wizard/date_range_generator.xml +++ b/date_range/wizard/date_range_generator.xml @@ -15,6 +15,7 @@ +