From a40a8ddfa5fc1d3c2e19b1b5200e519394c4624f Mon Sep 17 00:00:00 2001 From: Andrea Date: Mon, 1 Oct 2018 16:44:07 +0200 Subject: [PATCH] [12.0][MIG] date_range --- date_range/README.rst | 10 +- date_range/__init__.py | 1 - date_range/__manifest__.py | 9 +- .../11.0.2.0.0/noupdate_changes.xml | 9 - .../11.0.2.0.0/openupgrade_analysis.txt | 3 - .../11.0.2.0.0/openupgrade_analysis_work.txt | 4 - .../migrations/11.0.2.0.0/post-migration.py | 11 - date_range/models/__init__.py | 1 - date_range/models/date_range.py | 14 +- date_range/models/date_range_type.py | 14 +- date_range/readme/CONTRIBUTORS.rst | 1 + date_range/readme/INSTALL.rst | 2 - date_range/static/src/js/date_range.js | 210 +++++++++--------- date_range/tests/__init__.py | 1 - date_range/tests/test_date_range.py | 10 +- date_range/tests/test_date_range_generator.py | 13 +- date_range/tests/test_date_range_type.py | 7 +- date_range/wizard/__init__.py | 1 - date_range/wizard/date_range_generator.py | 22 +- 19 files changed, 155 insertions(+), 188 deletions(-) delete mode 100644 date_range/migrations/11.0.2.0.0/noupdate_changes.xml delete mode 100644 date_range/migrations/11.0.2.0.0/openupgrade_analysis.txt delete mode 100644 date_range/migrations/11.0.2.0.0/openupgrade_analysis_work.txt delete mode 100644 date_range/migrations/11.0.2.0.0/post-migration.py diff --git a/date_range/README.rst b/date_range/README.rst index 3eedd39..4232f2d 100644 --- a/date_range/README.rst +++ b/date_range/README.rst @@ -14,13 +14,13 @@ Date Range :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--ux-lightgray.png?logo=github - :target: https://github.com/OCA/server-ux/tree/11.0/date_range + :target: https://github.com/OCA/server-ux/tree/12.0/date_range :alt: OCA/server-ux .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png :target: https://translation.odoo-community.org/projects/server-ux-11-0/server-ux-11-0-date_range :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/250/11.0 + :target: https://runbot.odoo-community.org/runbot/250/12.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -97,7 +97,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -133,10 +133,10 @@ promote its widespread use. :target: https://github.com/lmignon :alt: lmignon -Current `maintainer `__: +Current `maintainer `_: |maintainer-lmignon| -This module is part of the `OCA/server-ux `_ project on GitHub. +This module is part of the `OCA/server-ux `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/date_range/__init__.py b/date_range/__init__.py index faa4535..4d7a49b 100644 --- a/date_range/__init__.py +++ b/date_range/__init__.py @@ -1,4 +1,3 @@ -# © 2016 ACSONE SA/NV () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from . import models diff --git a/date_range/__manifest__.py b/date_range/__manifest__.py index fd65913..68390a2 100644 --- a/date_range/__manifest__.py +++ b/date_range/__manifest__.py @@ -1,14 +1,13 @@ -# © 2016 ACSONE SA/NV () +# Copyright 2016 ACSONE SA/NV () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "Date Range", "summary": "Manage all kind of date range", - "version": "11.0.2.0.0", + "version": "12.0.1.0.0", "category": "Uncategorized", "website": "https://github.com/oca/server-ux", "author": "ACSONE SA/NV, Odoo Community Association (OCA)", "license": "AGPL-3", - "application": False, "installable": True, "depends": [ "web", @@ -23,6 +22,6 @@ "qweb": [ "static/src/xml/date_range.xml", ], - 'development_status': 'Mature', - 'maintainers': ['lmignon'], + "development_status": "Mature", + "maintainers": ["lmignon"], } diff --git a/date_range/migrations/11.0.2.0.0/noupdate_changes.xml b/date_range/migrations/11.0.2.0.0/noupdate_changes.xml deleted file mode 100644 index db1aff7..0000000 --- a/date_range/migrations/11.0.2.0.0/noupdate_changes.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - ['|',('company_id','child_of',[user.company_id.id]),('company_id','=',False)] - - - ['|',('company_id','child_of',[user.company_id.id]),('company_id','=',False)] - - diff --git a/date_range/migrations/11.0.2.0.0/openupgrade_analysis.txt b/date_range/migrations/11.0.2.0.0/openupgrade_analysis.txt deleted file mode 100644 index f5a9ace..0000000 --- a/date_range/migrations/11.0.2.0.0/openupgrade_analysis.txt +++ /dev/null @@ -1,3 +0,0 @@ ----Fields in module 'date_range'--- ----XML records in module 'date_range'--- -NEW ir.rule: date_range.date_range_generator_comp_rule (noupdate) diff --git a/date_range/migrations/11.0.2.0.0/openupgrade_analysis_work.txt b/date_range/migrations/11.0.2.0.0/openupgrade_analysis_work.txt deleted file mode 100644 index b14d703..0000000 --- a/date_range/migrations/11.0.2.0.0/openupgrade_analysis_work.txt +++ /dev/null @@ -1,4 +0,0 @@ ----Fields in module 'date_range'--- ----XML records in module 'date_range'--- -NEW ir.rule: date_range.date_range_generator_comp_rule (noupdate) -# NOTHING TO DO \ No newline at end of file diff --git a/date_range/migrations/11.0.2.0.0/post-migration.py b/date_range/migrations/11.0.2.0.0/post-migration.py deleted file mode 100644 index 1145d80..0000000 --- a/date_range/migrations/11.0.2.0.0/post-migration.py +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright 2017 Eficent -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from openupgradelib import openupgrade - - -@openupgrade.migrate() -def migrate(env, version): - openupgrade.load_data( - env.cr, 'date_range', 'migrations/11.0.2.0.0/noupdate_changes.xml', - ) diff --git a/date_range/models/__init__.py b/date_range/models/__init__.py index 2464998..4c36edf 100644 --- a/date_range/models/__init__.py +++ b/date_range/models/__init__.py @@ -1,4 +1,3 @@ -# © 2016 ACSONE SA/NV () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from . import date_range_type diff --git a/date_range/models/date_range.py b/date_range/models/date_range.py index 10e7881..704f602 100644 --- a/date_range/models/date_range.py +++ b/date_range/models/date_range.py @@ -1,13 +1,13 @@ -# © 2016 ACSONE SA/NV () +# Copyright 2016 ACSONE SA/NV () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, fields, models -from odoo.tools.translate import _ +from odoo import _, api, fields, models from odoo.exceptions import ValidationError class DateRange(models.Model): _name = "date.range" + _description = "Date Range" _order = "type_name,date_start" @api.model @@ -22,7 +22,7 @@ class DateRange(models.Model): ondelete='restrict', domain="['|', ('company_id', '=', company_id), " "('company_id', '=', False)]") type_name = fields.Char( - string='Type', related='type_id.name', readonly=True, store=True) + related='type_id.name', readonly=True, store=True, string="Type Name") company_id = fields.Many2one( comodel_name='res.company', string='Company', index=1, default=_default_company) @@ -34,7 +34,7 @@ class DateRange(models.Model): ('date_range_uniq', 'unique (name,type_id, company_id)', 'A date range must be unique per company !')] - @api.onchange('company_id') + @api.onchange('company_id', 'type_id') def _onchange_company_id(self): if self.company_id and self.type_id.company_id and \ self.type_id.company_id != self.company_id: @@ -54,9 +54,7 @@ class DateRange(models.Model): @api.constrains('type_id', 'date_start', 'date_end', 'company_id') def _validate_range(self): for this in self: - start = fields.Date.from_string(this.date_start) - end = fields.Date.from_string(this.date_end) - if start > end: + if this.date_start > this.date_end: raise ValidationError( _("%s is not a valid range (%s > %s)") % ( this.name, this.date_start, this.date_end)) diff --git a/date_range/models/date_range_type.py b/date_range/models/date_range_type.py index 9ddae3e..a5f5406 100644 --- a/date_range/models/date_range_type.py +++ b/date_range/models/date_range_type.py @@ -1,13 +1,13 @@ -# © 2016 ACSONE SA/NV () +# Copyright 2016 ACSONE SA/NV () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, fields, models -from odoo.tools.translate import _ +from odoo import _, api, fields, models from odoo.exceptions import ValidationError class DateRangeType(models.Model): _name = "date.range.type" + _description = "Date Range Type" @api.model def _default_company(self): @@ -18,8 +18,8 @@ class DateRangeType(models.Model): help="If sets date range of same type must not overlap.", default=False) active = fields.Boolean( - help="The active field allows you to hide the date range without " - "removing it.", default=True) + help="The active field allows you to hide the date range type " + "without removing it.", default=True) company_id = fields.Many2one( comodel_name='res.company', string='Company', index=1, default=_default_company) @@ -35,10 +35,10 @@ class DateRangeType(models.Model): for rec in self.sudo(): if not rec.company_id: continue - if bool(self.date_range_ids.filtered( + if bool(rec.date_range_ids.filtered( lambda r: r.company_id and r.company_id != rec.company_id)): raise ValidationError( _('You cannot change the company, as this ' 'Date Range Type is assigned to Date Range ' - '(%s).') % (self.date_range_ids.name_get()[0][1])) + '(%s).') % (rec.date_range_ids.name_get()[0][1])) diff --git a/date_range/readme/CONTRIBUTORS.rst b/date_range/readme/CONTRIBUTORS.rst index 4d37025..38b10b3 100644 --- a/date_range/readme/CONTRIBUTORS.rst +++ b/date_range/readme/CONTRIBUTORS.rst @@ -1,3 +1,4 @@ * Laurent Mignon * Alexis de Lattre * Miquel Raïch +* Andrea Stirpe diff --git a/date_range/readme/INSTALL.rst b/date_range/readme/INSTALL.rst index 695d21f..f4bf76d 100644 --- a/date_range/readme/INSTALL.rst +++ b/date_range/readme/INSTALL.rst @@ -1,3 +1 @@ The addon use the daterange method from postgres. This method is supported as of postgresql 9.2 - - diff --git a/date_range/static/src/js/date_range.js b/date_range/static/src/js/date_range.js index 7775f55..9b8200e 100644 --- a/date_range/static/src/js/date_range.js +++ b/date_range/static/src/js/date_range.js @@ -1,125 +1,125 @@ -/* © 2016 ACSONE SA/NV () +/* Copyright 2016 ACSONE SA/NV () * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ odoo.define('date_range.search_filters', function (require) { -"use strict"; - -var core = require('web.core'); -var data = require('web.data'); -var filters = require('web.search_filters'); -var rpc = require('web.rpc'); -var framework = require('web.framework'); - -var _t = core._t; -filters.ExtendedSearchProposition.include({ - select_field: function(field) { - this._super.apply(this, arguments); - this.is_date_range_selected = false; - this.is_date = field.type === 'date' || field.type === 'datetime'; - this.$value = this.$el.find('.searchview_extended_prop_value, .o_searchview_extended_prop_value'); - if (this.is_date){ - var ds = new data.DataSetSearch(this, 'date.range.type', this.context, [[1, '=', 1]]); - ds.read_slice(['name'], {}).done(this.proxy('add_date_range_types_operator')); - } - }, - - add_date_range_types_operator: function(date_range_types){ - var self = this; - _.each(date_range_types, function(drt) { - $('