[IMP] base_time_window: black, isort

pull/2370/head
Akim Juillerat 2020-04-15 12:45:17 +02:00 committed by Jasmin Solanki
parent 04e80dfd5f
commit 63836b060d
5 changed files with 15 additions and 33 deletions

View File

@ -9,9 +9,6 @@
"license": "AGPL-3", "license": "AGPL-3",
"website": "https://github.com/OCA/server-tools", "website": "https://github.com/OCA/server-tools",
"depends": ["base"], "depends": ["base"],
"data": [ "data": ["data/time_weekday.xml", "security/ir.model.access.xml"],
"data/time_weekday.xml",
"security/ir.model.access.xml"
],
"installable": True, "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 <!-- Copyright 2020 ACSONE SA/NV
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo noupdate="1"> <odoo noupdate="1">
<record model="time.weekday" id="time_weekday_monday"> <record model="time.weekday" id="time_weekday_monday">
<field name="name">0</field> <field name="name">0</field>
</record> </record>
<record model="time.weekday" id="time_weekday_tuesday"> <record model="time.weekday" id="time_weekday_tuesday">
<field name="name">1</field> <field name="name">1</field>
</record> </record>
<record model="time.weekday" id="time_weekday_wednesday"> <record model="time.weekday" id="time_weekday_wednesday">
<field name="name">2</field> <field name="name">2</field>
</record> </record>
<record model="time.weekday" id="time_weekday_thursday"> <record model="time.weekday" id="time_weekday_thursday">
<field name="name">3</field> <field name="name">3</field>
</record> </record>
<record model="time.weekday" id="time_weekday_friday"> <record model="time.weekday" id="time_weekday_friday">
<field name="name">4</field> <field name="name">4</field>
</record> </record>
<record model="time.weekday" id="time_weekday_saturday"> <record model="time.weekday" id="time_weekday_saturday">
<field name="name">5</field> <field name="name">5</field>
</record> </record>
<record model="time.weekday" id="time_weekday_sunday"> <record model="time.weekday" id="time_weekday_sunday">
<field name="name">6</field> <field name="name">6</field>
</record> </record>

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2020 ACSONE SA/NV # Copyright 2020 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
@ -22,9 +21,7 @@ class TimeWeekday(models.Model):
], ],
required=True, required=True,
) )
_sql_constraints = [ _sql_constraints = [("name_uniq", "UNIQUE(name)", _("Name must be unique"))]
("name_uniq", "UNIQUE(name)", _("Name must be unique"))
]
@api.depends("name") @api.depends("name")
def _compute_display_name(self): def _compute_display_name(self):
@ -32,9 +29,7 @@ class TimeWeekday(models.Model):
WORKAROUND since Odoo doesn't handle properly records where name is WORKAROUND since Odoo doesn't handle properly records where name is
a selection a selection
""" """
translated_values = dict( translated_values = dict(self._fields["name"]._description_selection(self.env))
self._fields["name"]._description_selection(self.env)
)
for record in self: for record in self:
record.display_name = translated_values[record.name] record.display_name = translated_values[record.name]

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2020 ACSONE SA/NV # Copyright 2020 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # 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 join %(relation)s as d
on d.%(relation_window_fkey)s = w.id on d.%(relation_window_fkey)s = w.id
WHERE WHERE
NUMRANGE(w.time_window_start::numeric, w.time_window_end::numeric) && NUMRANGE(w.time_window_start::numeric,
NUMRANGE(%(start)s::numeric, %(end)s::numeric) w.time_window_end::numeric) &&
NUMRANGE(%(start)s::numeric, %(end)s::numeric)
AND w.id != %(window_id)s AND w.id != %(window_id)s
AND d.%(relation_week_day_fkey)s in %(weekday_ids)s AND d.%(relation_week_day_fkey)s in %(weekday_ids)s
AND w.%(check_field)s = %(check_field_id)s;""" AND w.%(check_field)s = %(check_field_id)s;"""
@ -76,8 +76,7 @@ class TimeWindowMixin(models.AbstractModel):
if res: if res:
other = self.browse(res[0][0]) other = self.browse(res[0][0])
raise ValidationError( raise ValidationError(
_("%s overlaps %s") _("%s overlaps %s") % (record.display_name, other.display_name)
% (record.display_name, other.display_name)
) )
@api.depends("time_window_start", "time_window_end", "time_window_weekday_ids") @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 <!-- Copyright 2020 ACSONE SA/NV
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo> <odoo>
<record model="ir.model.access" id="time_weekday_access_read"> <record model="ir.model.access" id="time_weekday_access_read">
<field name="name">time.weekday access read</field> <field name="name">time.weekday access read</field>
<field name="model_id" ref="model_time_weekday"/> <field name="model_id" ref="model_time_weekday" />
<field name="group_id" ref="base.group_user"/> <field name="group_id" ref="base.group_user" />
<field name="perm_read" eval="1"/> <field name="perm_read" eval="1" />
<field name="perm_create" eval="0"/> <field name="perm_create" eval="0" />
<field name="perm_write" eval="0"/> <field name="perm_write" eval="0" />
<field name="perm_unlink" eval="0"/> <field name="perm_unlink" eval="0" />
</record> </record>
</odoo> </odoo>