From 585fa0dedfcb9a23a5940005b6732f2e17affd2c Mon Sep 17 00:00:00 2001 From: Simon Hick Date: Fri, 10 Jul 2026 11:39:09 +0200 Subject: [PATCH 1/2] [FIX] fixed wrong check for change time limit shift_change --- shift_change/models/shift_change.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shift_change/models/shift_change.py b/shift_change/models/shift_change.py index 4d88ec240..54b05f879 100644 --- a/shift_change/models/shift_change.py +++ b/shift_change/models/shift_change.py @@ -190,7 +190,7 @@ def _check_old_shift(self, old_shift_id, worker_id): @api.model def _check_new_shift(self, new_shift_id, worker_id): """Check if shift can be changed or not""" - old_shift_hour_limit_change = self._get_old_shift_hour_limit_change() + new_shift_hour_limit_change = self._get_new_shift_hour_limit_change() if new_shift_id.worker_id: raise ValidationError( _("You can't subscribe to a shift assigned to someone else.") @@ -198,7 +198,7 @@ def _check_new_shift(self, new_shift_id, worker_id): if new_shift_id.start_time <= datetime.now(): raise ValidationError(_("You can't subscribe to a shift in the past.")) if new_shift_id.start_time <= datetime.now() + timedelta( - hours=old_shift_hour_limit_change + hours=new_shift_hour_limit_change ): raise ValidationError( _("You can't subscribe to a shift so close in the futur.") From 8f22d0d0bd974b2fb47985c3d2a466d18ce1b0a3 Mon Sep 17 00:00:00 2001 From: hugues de keyzer Date: Fri, 17 Jul 2026 20:16:36 +0200 Subject: [PATCH 2/2] [IMP] improve user strings and add fr translation --- shift_change/i18n/fr.po | 293 ++++++++++++++++++ shift_change/i18n/shift_change.pot | 78 +++-- shift_change/models/res_partner.py | 2 +- shift_change/models/shift_change.py | 21 +- .../views/res_config_setting_view.xml | 2 +- shift_change/views/res_partner.xml | 2 +- shift_change/views/shift_change_menu.xml | 4 +- .../wizard/shift_change_create_wizard.py | 4 +- 8 files changed, 366 insertions(+), 40 deletions(-) create mode 100644 shift_change/i18n/fr.po diff --git a/shift_change/i18n/fr.po b/shift_change/i18n/fr.po new file mode 100644 index 000000000..f98c6dee3 --- /dev/null +++ b/shift_change/i18n/fr.po @@ -0,0 +1,293 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * shift_change +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: shift_change +#: model_terms:ir.ui.view,arch_db:shift_change.res_config_settings_swap_view_form +msgid "" +"\n" +" Maximum changes for the same shift\n" +" " +msgstr "" +"\n" +" Nombre maximum de changements pour le même " +"shift\n" +" " + +#. module: shift_change +#: model_terms:ir.ui.view,arch_db:shift_change.res_config_settings_swap_view_form +msgid "" +"\n" +" Time limit to change a shift\n" +" " +msgstr "" +"\n" +" Limite de temps pour changer un shift\n" +" " + +#. module: shift_change +#: model_terms:ir.ui.view,arch_db:shift_change.res_config_settings_swap_view_form +msgid "" +"\n" +" Time limit to take a new shift\n" +" " +msgstr "" +"\n" +" Limite de temps pour participer à un nouveau " +"shift\n" +" " + +#. module: shift_change +#: model:ir.model,name:shift_change.model_shift_change +msgid "A model to track a change of a shift" +msgstr "" + +#. module: shift_change +#: model:ir.model.fields,field_description:shift_change.field_shift_change_create_wizard__available_new_shift_ids +msgid "Available New Shifts" +msgstr "Nouveaux shifts disponibles" + +#. module: shift_change +#: model_terms:ir.ui.view,arch_db:shift_change.shift_change_create_wizard_form +msgid "Cancel" +msgstr "Annuler" + +#. module: shift_change +#. odoo-python +#: code:addons/shift_change/models/res_partner.py:0 +#: model_terms:ir.ui.view,arch_db:shift_change.res_partner_shift_change_button +#, python-format +msgid "Change a Shift" +msgstr "Changer un shift" + +#. module: shift_change +#: model:ir.model,name:shift_change.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: shift_change +#: model_terms:ir.ui.view,arch_db:shift_change.shift_change_create_wizard_form +msgid "Confirm" +msgstr "Confirmer" + +#. module: shift_change +#: model:ir.model,name:shift_change.model_res_partner +msgid "Contact" +msgstr "" + +#. module: shift_change +#: model_terms:ir.ui.view,arch_db:shift_change.shift_change_view_search +msgid "Create Date" +msgstr "" + +#. module: shift_change +#: model:ir.actions.act_window,name:shift_change.action_shift_change_create_wizard +#: model:ir.ui.menu,name:shift_change.menu_shift_change_create_wizard +#: model_terms:ir.ui.view,arch_db:shift_change.shift_change_create_wizard_form +msgid "Create Shift Change" +msgstr "Créer un changement de shift" + +#. module: shift_change +#: model:ir.model.fields,field_description:shift_change.field_shift_change__create_uid +#: model:ir.model.fields,field_description:shift_change.field_shift_change_create_wizard__create_uid +msgid "Created by" +msgstr "Créé par" + +#. module: shift_change +#: model:ir.model.fields,field_description:shift_change.field_shift_change__create_date +#: model:ir.model.fields,field_description:shift_change.field_shift_change_create_wizard__create_date +msgid "Created on" +msgstr "Créé le" + +#. module: shift_change +#: model:ir.model.fields,field_description:shift_change.field_shift_change__display_name +#: model:ir.model.fields,field_description:shift_change.field_shift_change_create_wizard__display_name +msgid "Display Name" +msgstr "" + +#. module: shift_change +#: model_terms:ir.ui.view,arch_db:shift_change.shift_change_view_search +msgid "Group By" +msgstr "" + +#. module: shift_change +#: model_terms:ir.ui.view,arch_db:shift_change.res_config_settings_swap_view_form +msgid "Hours" +msgstr "Heures" + +#. module: shift_change +#: model:ir.model.fields,field_description:shift_change.field_shift_change__id +#: model:ir.model.fields,field_description:shift_change.field_shift_change_create_wizard__id +msgid "ID" +msgstr "" + +#. module: shift_change +#: model:ir.model.fields,field_description:shift_change.field_shift_change____last_update +#: model:ir.model.fields,field_description:shift_change.field_shift_change_create_wizard____last_update +msgid "Last Modified on" +msgstr "" + +#. module: shift_change +#: model:ir.model.fields,field_description:shift_change.field_shift_change__write_uid +#: model:ir.model.fields,field_description:shift_change.field_shift_change_create_wizard__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: shift_change +#: model:ir.model.fields,field_description:shift_change.field_shift_change__write_date +#: model:ir.model.fields,field_description:shift_change.field_shift_change_create_wizard__write_date +msgid "Last Updated on" +msgstr "" + +#. module: shift_change +#: model_terms:ir.ui.view,arch_db:shift_change.shift_change_view_search +msgid "My Changes" +msgstr "Mes changements" + +#. module: shift_change +#: model:ir.model.fields,field_description:shift_change.field_shift_change__new_shift_id +#: model:ir.model.fields,field_description:shift_change.field_shift_change_create_wizard__new_shift_id +msgid "New Shift" +msgstr "Nouveau shift" + +#. module: shift_change +#: model:ir.model.fields,field_description:shift_change.field_res_config_settings__new_shift_hour_limit_change +msgid "New Shift Hour Limit Change" +msgstr "" + +#. module: shift_change +#: model_terms:ir.ui.view,arch_db:shift_change.res_config_settings_swap_view_form +msgid "Number of hours below which a new shift cannot be taken" +msgstr "" +"Nombre d'heures en-dessous desquelles il n'est plus possible de s'inscrire à " +"un nouveau shift" + +#. module: shift_change +#: model_terms:ir.ui.view,arch_db:shift_change.res_config_settings_swap_view_form +msgid "Number of hours below which a shift cannot be changed" +msgstr "" +"Nombre d'heures en-dessous desquelles un shift ne peut plus être changé" + +#. module: shift_change +#: model_terms:ir.ui.view,arch_db:shift_change.res_config_settings_swap_view_form +msgid "Number of time the same shift can be changed" +msgstr "Nombre de fois qu'un même shift peut être changé" + +#. module: shift_change +#: model:ir.model.fields,field_description:shift_change.field_shift_change__old_shift_id +#: model:ir.model.fields,field_description:shift_change.field_shift_change_create_wizard__old_shift_id +msgid "Old Shift" +msgstr "Ancien shift" + +#. module: shift_change +#: model:ir.model.fields,field_description:shift_change.field_res_config_settings__old_shift_hour_limit_change +msgid "Old Shift Hour Limit Change" +msgstr "" + +#. module: shift_change +#: model:ir.model.fields,field_description:shift_change.field_res_config_settings__same_shift_change_max +msgid "Same Shift Change Max" +msgstr "" + +#. module: shift_change +#: model:ir.actions.act_window,name:shift_change.action_shift_change +#: model:ir.ui.menu,name:shift_change.menu_change_top +#: model_terms:ir.ui.view,arch_db:shift_change.res_config_settings_swap_view_form +msgid "Shift Changes" +msgstr "Changements de shift" + +#. module: shift_change +#: model:ir.ui.menu,name:shift_change.menu_change +msgid "Shift Changes History" +msgstr "Historique de changements de shift" + +#. module: shift_change +#: model_terms:ir.ui.view,arch_db:shift_change.res_config_settings_swap_view_form +msgid "Times" +msgstr "Fois" + +#. module: shift_change +#: model:ir.model,name:shift_change.model_shift_change_create_wizard +msgid "Wizard to create a shift change" +msgstr "" + +#. module: shift_change +#: model:ir.model.fields,field_description:shift_change.field_shift_change__worker_id +#: model:ir.model.fields,field_description:shift_change.field_shift_change_create_wizard__worker_id +#: model_terms:ir.ui.view,arch_db:shift_change.shift_change_view_search +msgid "Worker" +msgstr "Travailleur" + +#. module: shift_change +#. odoo-python +#: code:addons/shift_change/models/shift_change.py:0 +#, python-format +msgid "You can't change a shift that is in the past." +msgstr "Vous ne pouvez pas changer un shift qui est dans le passé." + +#. module: shift_change +#. odoo-python +#: code:addons/shift_change/models/shift_change.py:0 +#, python-format +msgid "You can't change a shift that is so close in the future." +msgstr "Vous ne pouvez pas changer un shift qui est si proche dans le temps." + +#. module: shift_change +#. odoo-python +#: code:addons/shift_change/models/shift_change.py:0 +#, python-format +msgid "You can't change a shift to which your are not assigned." +msgstr "Vous ne pouvez pas changer un shift auquel vous n'êtes pas assigné." + +#. module: shift_change +#. odoo-python +#: code:addons/shift_change/models/shift_change.py:0 +#, python-format +msgid "" +"You can't change the same shift more than %(same_shift_change_max)s times." +msgstr "" +"Vous ne pouvez pas changer un shift plus de %(same_shift_change_max)s fois." + +#. module: shift_change +#. odoo-python +#: code:addons/shift_change/models/shift_change.py:0 +#, python-format +msgid "You can't subscribe to a shift assigned to someone else." +msgstr "" +"Vous ne pouvez pas vous inscrire à un shift assigné à quelqu'un d'autre." + +#. module: shift_change +#. odoo-python +#: code:addons/shift_change/models/shift_change.py:0 +#, python-format +msgid "You can't subscribe to a shift in the past." +msgstr "Vous ne pouvez pas vous inscrire à un shift qui est dans le passé." + +#. module: shift_change +#. odoo-python +#: code:addons/shift_change/models/shift_change.py:0 +#, python-format +msgid "You can't subscribe to a shift that is so close in the future." +msgstr "" +"Vous ne pouvez pas vous inscrire à un shift qui est si proche dans le temps." + +#. module: shift_change +#. odoo-python +#: code:addons/shift_change/models/shift_change.py:0 +#, python-format +msgid "You can't subscribe to this shift, it's not available to you." +msgstr "" +"Vous ne pouvez pas vous inscrire à ce shift, il n'est pas disponible pour " +"vous." diff --git a/shift_change/i18n/shift_change.pot b/shift_change/i18n/shift_change.pot index 1e1400aaa..cfac22bd7 100644 --- a/shift_change/i18n/shift_change.pot +++ b/shift_change/i18n/shift_change.pot @@ -33,7 +33,7 @@ msgstr "" #: model_terms:ir.ui.view,arch_db:shift_change.res_config_settings_swap_view_form msgid "" "\n" -" Time limit to take a new a shift\n" +" Time limit to take a new shift\n" " " msgstr "" @@ -57,7 +57,7 @@ msgstr "" #: code:addons/shift_change/models/res_partner.py:0 #: model_terms:ir.ui.view,arch_db:shift_change.res_partner_shift_change_button #, python-format -msgid "Change a shift" +msgid "Change a Shift" msgstr "" #. module: shift_change @@ -81,6 +81,7 @@ msgid "Create Date" msgstr "" #. module: shift_change +#: model:ir.actions.act_window,name:shift_change.action_shift_change_create_wizard #: model:ir.ui.menu,name:shift_change.menu_shift_change_create_wizard #: model_terms:ir.ui.view,arch_db:shift_change.shift_change_create_wizard_form msgid "Create Shift Change" @@ -144,14 +145,14 @@ msgid "My Changes" msgstr "" #. module: shift_change -#: model:ir.model.fields,field_description:shift_change.field_res_config_settings__new_shift_hour_limit_change -msgid "New Shift Hour Limit Change" +#: model:ir.model.fields,field_description:shift_change.field_shift_change__new_shift_id +#: model:ir.model.fields,field_description:shift_change.field_shift_change_create_wizard__new_shift_id +msgid "New Shift" msgstr "" #. module: shift_change -#: model:ir.model.fields,field_description:shift_change.field_shift_change__new_shift_id -#: model:ir.model.fields,field_description:shift_change.field_shift_change_create_wizard__new_shift_id -msgid "New shift" +#: model:ir.model.fields,field_description:shift_change.field_res_config_settings__new_shift_hour_limit_change +msgid "New Shift Hour Limit Change" msgstr "" #. module: shift_change @@ -169,28 +170,24 @@ msgstr "" msgid "Number of time the same shift can be changed" msgstr "" -#. module: shift_change -#: model:ir.model.fields,field_description:shift_change.field_res_config_settings__old_shift_hour_limit_change -msgid "Old Shift Hour Limit Change" -msgstr "" - #. module: shift_change #: model:ir.model.fields,field_description:shift_change.field_shift_change__old_shift_id #: model:ir.model.fields,field_description:shift_change.field_shift_change_create_wizard__old_shift_id -msgid "Old shift" +msgid "Old Shift" msgstr "" #. module: shift_change -#: model:ir.model.fields,field_description:shift_change.field_res_config_settings__same_shift_change_max -msgid "Same Shift Change Max" +#: model:ir.model.fields,field_description:shift_change.field_res_config_settings__old_shift_hour_limit_change +msgid "Old Shift Hour Limit Change" msgstr "" #. module: shift_change -#: model:ir.actions.act_window,name:shift_change.action_shift_change_create_wizard -msgid "Shift Change Create Wizard" +#: model:ir.model.fields,field_description:shift_change.field_res_config_settings__same_shift_change_max +msgid "Same Shift Change Max" msgstr "" #. module: shift_change +#: model:ir.actions.act_window,name:shift_change.action_shift_change #: model:ir.ui.menu,name:shift_change.menu_change_top #: model_terms:ir.ui.view,arch_db:shift_change.res_config_settings_swap_view_form msgid "Shift Changes" @@ -201,11 +198,6 @@ msgstr "" msgid "Shift Changes History" msgstr "" -#. module: shift_change -#: model:ir.actions.act_window,name:shift_change.action_shift_change -msgid "Shift changes" -msgstr "" - #. module: shift_change #: model_terms:ir.ui.view,arch_db:shift_change.res_config_settings_swap_view_form msgid "Times" @@ -227,19 +219,55 @@ msgstr "" #. odoo-python #: code:addons/shift_change/models/shift_change.py:0 #, python-format -msgid "You can't change a shift so close in the futur." +msgid "You can't change a shift that is in the past." +msgstr "" + +#. module: shift_change +#. odoo-python +#: code:addons/shift_change/models/shift_change.py:0 +#, python-format +msgid "You can't change a shift that is so close in the future." +msgstr "" + +#. module: shift_change +#. odoo-python +#: code:addons/shift_change/models/shift_change.py:0 +#, python-format +msgid "You can't change a shift to which your are not assigned." +msgstr "" + +#. module: shift_change +#. odoo-python +#: code:addons/shift_change/models/shift_change.py:0 +#, python-format +msgid "" +"You can't change the same shift more than %(same_shift_change_max)s times." +msgstr "" + +#. module: shift_change +#. odoo-python +#: code:addons/shift_change/models/shift_change.py:0 +#, python-format +msgid "You can't subscribe to a shift assigned to someone else." +msgstr "" + +#. module: shift_change +#. odoo-python +#: code:addons/shift_change/models/shift_change.py:0 +#, python-format +msgid "You can't subscribe to a shift in the past." msgstr "" #. module: shift_change #. odoo-python #: code:addons/shift_change/models/shift_change.py:0 #, python-format -msgid "You can't change shift that is in the past." +msgid "You can't subscribe to a shift that is so close in the future." msgstr "" #. module: shift_change #. odoo-python #: code:addons/shift_change/models/shift_change.py:0 #, python-format -msgid "You can't change shift that your are not worker." +msgid "You can't subscribe to this shift, it's not available to you." msgstr "" diff --git a/shift_change/models/res_partner.py b/shift_change/models/res_partner.py index 0f328ea19..d444e7595 100644 --- a/shift_change/models/res_partner.py +++ b/shift_change/models/res_partner.py @@ -10,7 +10,7 @@ class ResPartner(models.Model): def button_change_shift(self): return { - "name": _("Change a shift"), + "name": _("Change a Shift"), "type": "ir.actions.act_window", "view_type": "form", "view_mode": "form", diff --git a/shift_change/models/shift_change.py b/shift_change/models/shift_change.py index 54b05f879..1d72339ca 100644 --- a/shift_change/models/shift_change.py +++ b/shift_change/models/shift_change.py @@ -23,10 +23,10 @@ class ShiftChange(models.Model): ], required=True, ) - old_shift_id = fields.Many2one("shift.shift", string="Old shift", required=True) + old_shift_id = fields.Many2one("shift.shift", string="Old Shift", required=True) new_shift_id = fields.Many2one( "shift.shift", - string="New shift", + string="New Shift", required=True, ) @@ -144,13 +144,17 @@ def _check_old_shift(self, old_shift_id, worker_id): """Check if old shift can be changed""" old_shift_hour_limit_change = self._get_old_shift_hour_limit_change() if not old_shift_id.worker_id or old_shift_id.worker_id != worker_id: - raise ValidationError(_("You can't change shift that your are not worker.")) + raise ValidationError( + _("You can't change a shift to which your are not assigned.") + ) if old_shift_id.start_time <= datetime.now(): - raise ValidationError(_("You can't change shift that is in the past.")) + raise ValidationError(_("You can't change a shift that is in the past.")) if old_shift_id.start_time <= datetime.now() + timedelta( hours=old_shift_hour_limit_change ): - raise ValidationError(_("You can't change a shift so close in the futur.")) + raise ValidationError( + _("You can't change a shift that is so close in the future.") + ) try: same_shift_change_max = int( self.env["ir.config_parameter"] @@ -183,7 +187,8 @@ def _check_old_shift(self, old_shift_id, worker_id): raise ValidationError( _( "You can't change the same shift more than " - f"{same_shift_change_max} times." + "%(same_shift_change_max)s times.", + same_shift_change_max=same_shift_change_max, ) ) @@ -201,9 +206,9 @@ def _check_new_shift(self, new_shift_id, worker_id): hours=new_shift_hour_limit_change ): raise ValidationError( - _("You can't subscribe to a shift so close in the futur.") + _("You can't subscribe to a shift that is so close in the future.") ) if new_shift_id not in self._get_available_new_shift_ids(worker_id): raise ValidationError( - _("You can't subscribe to this shift, it’s not available for you.") + _("You can't subscribe to this shift, it's not available to you.") ) diff --git a/shift_change/views/res_config_setting_view.xml b/shift_change/views/res_config_setting_view.xml index 2bcda1ebb..572dac448 100644 --- a/shift_change/views/res_config_setting_view.xml +++ b/shift_change/views/res_config_setting_view.xml @@ -41,7 +41,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later - Time limit to take a new a shift + Time limit to take a new shift
Number of hours below which a new shift cannot be taken diff --git a/shift_change/views/res_partner.xml b/shift_change/views/res_partner.xml index b5f1d764a..dff764edd 100644 --- a/shift_change/views/res_partner.xml +++ b/shift_change/views/res_partner.xml @@ -14,7 +14,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later