[IMP] base_time_window: black, isort

pull/2559/head
Akim Juillerat 2020-04-15 12:45:17 +02:00 committed by sbejaoui
parent e3910a572b
commit 02feb9457d
5 changed files with 15 additions and 33 deletions

View File

@ -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,
}

View File

@ -1,33 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2020 ACSONE SA/NV
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo noupdate="1">
<record model="time.weekday" id="time_weekday_monday">
<field name="name">0</field>
</record>
<record model="time.weekday" id="time_weekday_tuesday">
<field name="name">1</field>
</record>
<record model="time.weekday" id="time_weekday_wednesday">
<field name="name">2</field>
</record>
<record model="time.weekday" id="time_weekday_thursday">
<field name="name">3</field>
</record>
<record model="time.weekday" id="time_weekday_friday">
<field name="name">4</field>
</record>
<record model="time.weekday" id="time_weekday_saturday">
<field name="name">5</field>
</record>
<record model="time.weekday" id="time_weekday_sunday">
<field name="name">6</field>
</record>

View File

@ -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]

View File

@ -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")

View File

@ -1,15 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2020 ACSONE SA/NV
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record model="ir.model.access" id="time_weekday_access_read">
<field name="name">time.weekday access read</field>
<field name="model_id" ref="model_time_weekday"/>
<field name="group_id" ref="base.group_user"/>
<field name="perm_read" eval="1"/>
<field name="perm_create" eval="0"/>
<field name="perm_write" eval="0"/>
<field name="perm_unlink" eval="0"/>
<field name="model_id" ref="model_time_weekday" />
<field name="group_id" ref="base.group_user" />
<field name="perm_read" eval="1" />
<field name="perm_create" eval="0" />
<field name="perm_write" eval="0" />
<field name="perm_unlink" eval="0" />
</record>
</odoo>