diff --git a/base_time_window/__manifest__.py b/base_time_window/__manifest__.py index 353c0b3f9..7c4b6b582 100644 --- a/base_time_window/__manifest__.py +++ b/base_time_window/__manifest__.py @@ -9,9 +9,6 @@ "license": "AGPL-3", "website": "https://github.com/OCA/server-tools", "depends": ["base"], - "data": [ - "data/time_weekday.xml", - "security/ir.model.access.xml" - ], + "data": ["data/time_weekday.xml", "security/ir.model.access.xml"], "installable": True, } diff --git a/base_time_window/data/time_weekday.xml b/base_time_window/data/time_weekday.xml index 14407fddf..8c2837e5d 100644 --- a/base_time_window/data/time_weekday.xml +++ b/base_time_window/data/time_weekday.xml @@ -1,33 +1,25 @@ - + - - 0 - 1 - 2 - 3 - 4 - 5 - 6 diff --git a/base_time_window/models/time_weekday.py b/base_time_window/models/time_weekday.py index bf6489f5b..78d17ecd3 100644 --- a/base_time_window/models/time_weekday.py +++ b/base_time_window/models/time_weekday.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2020 ACSONE SA/NV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). @@ -22,9 +21,7 @@ class TimeWeekday(models.Model): ], required=True, ) - _sql_constraints = [ - ("name_uniq", "UNIQUE(name)", _("Name must be unique")) - ] + _sql_constraints = [("name_uniq", "UNIQUE(name)", _("Name must be unique"))] @api.depends("name") def _compute_display_name(self): @@ -32,9 +29,7 @@ class TimeWeekday(models.Model): WORKAROUND since Odoo doesn't handle properly records where name is a selection """ - translated_values = dict( - self._fields["name"]._description_selection(self.env) - ) + translated_values = dict(self._fields["name"]._description_selection(self.env)) for record in self: record.display_name = translated_values[record.name] diff --git a/base_time_window/models/time_window_mixin.py b/base_time_window/models/time_window_mixin.py index d4bb4d192..da62f71d4 100644 --- a/base_time_window/models/time_window_mixin.py +++ b/base_time_window/models/time_window_mixin.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2020 ACSONE SA/NV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). @@ -52,8 +51,9 @@ class TimeWindowMixin(models.AbstractModel): join %(relation)s as d on d.%(relation_window_fkey)s = w.id WHERE - NUMRANGE(w.time_window_start::numeric, w.time_window_end::numeric) && - NUMRANGE(%(start)s::numeric, %(end)s::numeric) + NUMRANGE(w.time_window_start::numeric, + w.time_window_end::numeric) && + NUMRANGE(%(start)s::numeric, %(end)s::numeric) AND w.id != %(window_id)s AND d.%(relation_week_day_fkey)s in %(weekday_ids)s AND w.%(check_field)s = %(check_field_id)s;""" @@ -76,8 +76,7 @@ class TimeWindowMixin(models.AbstractModel): if res: other = self.browse(res[0][0]) raise ValidationError( - _("%s overlaps %s") - % (record.display_name, other.display_name) + _("%s overlaps %s") % (record.display_name, other.display_name) ) @api.depends("time_window_start", "time_window_end", "time_window_weekday_ids") diff --git a/base_time_window/security/ir.model.access.xml b/base_time_window/security/ir.model.access.xml index 440f0c5c1..886ae01b9 100644 --- a/base_time_window/security/ir.model.access.xml +++ b/base_time_window/security/ir.model.access.xml @@ -1,15 +1,14 @@ - + - time.weekday access read - - - - - - + + + + + +