From 7265228f200b25d42275129b02ee095cecd1dbd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Csaba=20T=C3=B3th?= Date: Thu, 5 Jan 2023 08:06:11 +0000 Subject: [PATCH] [FIX] project: translate error message in Project Sharing Before this commit, when the user cannot write on a certain field an error is occurred to notice the user, he cannot write on that field. The problem is the `on` is never translated. This commit fixes the issue to be sure the whole error message is translated. closes odoo/odoo#109288 X-original-commit: 5098c59cc6d1a853210f8c4f5340f0d4ee8dd883 Signed-off-by: Xavier Bol (xbo) --- addons/project/i18n/project.pot | 20 ++++++++++++++------ addons/project/models/project.py | 6 +++++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/addons/project/i18n/project.pot b/addons/project/i18n/project.pot index 71387654deb..3aaa1dd3029 100644 --- a/addons/project/i18n/project.pot +++ b/addons/project/i18n/project.pot @@ -5791,12 +5791,6 @@ msgstr "" msgid "You can only set a personal stage on a private task." msgstr "" -#. module: project -#: code:addons/project/models/project.py:0 -#, python-format -msgid "You cannot %s %s fields in task." -msgstr "" - #. module: project #: code:addons/project/models/analytic_account.py:0 #, python-format @@ -5826,6 +5820,20 @@ msgid "" "their tasks." msgstr "" +#. module: project +#. odoo-python +#: code:addons/project/models/project.py:0 +#, python-format +msgid "You cannot read %s fields in task." +msgstr "" + +#. module: project +#. odoo-python +#: code:addons/project/models/project.py:0 +#, python-format +msgid "You cannot write on %s fields in task." +msgstr "" + #. module: project #: code:addons/project/models/project.py:0 #, python-format diff --git a/addons/project/models/project.py b/addons/project/models/project.py index 6f289f7d83f..96016ebe998 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -1880,7 +1880,11 @@ class Task(models.Model): if fields and (not check_group_user or self.env.user.has_group('base.group_portal')) and not self.env.su: unauthorized_fields = set(fields) - (self.SELF_READABLE_FIELDS if operation == 'read' else self.SELF_WRITABLE_FIELDS) if unauthorized_fields: - raise AccessError(_('You cannot %s %s fields in task.', operation if operation == 'read' else '%s on' % operation, ', '.join(unauthorized_fields))) + if operation == 'read': + error_message = _('You cannot read %s fields in task.', ', '.join(unauthorized_fields)) + else: + error_message = _('You cannot write on %s fields in task.', ', '.join(unauthorized_fields)) + raise AccessError(error_message) def read(self, fields=None, load='_classic_read'): self._ensure_fields_are_accessible(fields)