From 47e43b8711f2ddd14bf98ca88b98894be4732e2c Mon Sep 17 00:00:00 2001 From: Andrea Date: Tue, 2 Oct 2018 15:50:00 +0200 Subject: [PATCH] [FIX] fixed constrains + fixed onchange + other minor fixes --- date_range/README.rst | 2 +- date_range/__manifest__.py | 2 +- date_range/models/date_range.py | 3 +- date_range/models/date_range_type.py | 5 ++- date_range/readme/CONTRIBUTORS.rst | 1 + date_range/readme/INSTALL.rst | 2 - date_range/static/src/js/date_range.js | 48 +++++++++++------------ date_range/wizard/date_range_generator.py | 1 + 8 files changed, 33 insertions(+), 31 deletions(-) diff --git a/date_range/README.rst b/date_range/README.rst index 3eedd39..32176f3 100644 --- a/date_range/README.rst +++ b/date_range/README.rst @@ -133,7 +133,7 @@ promote its widespread use. :target: https://github.com/lmignon :alt: lmignon -Current `maintainer `__: +Current `maintainer `_: |maintainer-lmignon| diff --git a/date_range/__manifest__.py b/date_range/__manifest__.py index fd65913..32c4a02 100644 --- a/date_range/__manifest__.py +++ b/date_range/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Date Range", "summary": "Manage all kind of date range", - "version": "11.0.2.0.0", + "version": "11.0.2.0.1", "category": "Uncategorized", "website": "https://github.com/oca/server-ux", "author": "ACSONE SA/NV, Odoo Community Association (OCA)", diff --git a/date_range/models/date_range.py b/date_range/models/date_range.py index 10e7881..3038efb 100644 --- a/date_range/models/date_range.py +++ b/date_range/models/date_range.py @@ -8,6 +8,7 @@ from odoo.exceptions import ValidationError class DateRange(models.Model): _name = "date.range" + _description = "Date Range" _order = "type_name,date_start" @api.model @@ -34,7 +35,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: diff --git a/date_range/models/date_range_type.py b/date_range/models/date_range_type.py index 9ddae3e..d51f4b2 100644 --- a/date_range/models/date_range_type.py +++ b/date_range/models/date_range_type.py @@ -8,6 +8,7 @@ from odoo.exceptions import ValidationError class DateRangeType(models.Model): _name = "date.range.type" + _description = "Date Range Type" @api.model def _default_company(self): @@ -35,10 +36,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..d3066b6 100644 --- a/date_range/static/src/js/date_range.js +++ b/date_range/static/src/js/date_range.js @@ -1,4 +1,4 @@ -/* © 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"; @@ -11,7 +11,7 @@ var framework = require('web.framework'); var _t = core._t; filters.ExtendedSearchProposition.include({ - select_field: function(field) { + select_field: function (field) { this._super.apply(this, arguments); this.is_date_range_selected = false; this.is_date = field.type === 'date' || field.type === 'datetime'; @@ -22,9 +22,9 @@ filters.ExtendedSearchProposition.include({ } }, - add_date_range_types_operator: function(date_range_types){ + add_date_range_types_operator: function (date_range_types){ var self = this; - _.each(date_range_types, function(drt) { + _.each(date_range_types, function (drt) { $('