From ec6459d42abf9b7fb0b29013b21d3235c06879eb Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Thu, 13 Jul 2017 11:12:33 +0200 Subject: [PATCH] [FIX] resource: Wrong default value for Time Efficiency The time efficiency cannot be set to 0 otherwise it raised an error when creating a workorder. opw:752251 --- addons/resource/i18n/resource.pot | 6 ++++++ addons/resource/models/resource.py | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/addons/resource/i18n/resource.pot b/addons/resource/i18n/resource.pot index 92a2ee17ecb..5256eed99ac 100644 --- a/addons/resource/i18n/resource.pot +++ b/addons/resource/i18n/resource.pot @@ -319,6 +319,12 @@ msgstr "" msgid "This field is used to calculate the the expected duration of a work order at this work center. For example, if a work order takes one hour and the efficiency factor is 100%, then the expected duration will be one hour. If the efficiency factor is 200%, however the expected duration will be 30 minutes." msgstr "" +#. module: resource +#: code:addons/resource/models/resource.py:714 +#, python-format +msgid "The efficiency factor cannot be equal to 0." +msgstr "" + #. module: resource #: selection:resource.calendar.attendance,dayofweek:0 msgid "Thursday" diff --git a/addons/resource/models/resource.py b/addons/resource/models/resource.py index b500ac8213a..b79befad18e 100644 --- a/addons/resource/models/resource.py +++ b/addons/resource/models/resource.py @@ -706,6 +706,13 @@ class ResourceResource(models.Model): help="This field is used to calculate the the expected duration of a work order at this work center. For example, if a work order takes one hour and the efficiency factor is 100%, then the expected duration will be one hour. If the efficiency factor is 200%, however the expected duration will be 30 minutes.") calendar_id = fields.Many2one("resource.calendar", string='Working Time', help="Define the schedule of resource") + @api.multi + @api.constrains('time_efficiency') + def _check_time_efficiency(self): + for record in self: + if record.time_efficiency == 0: + raise ValidationError(_('The efficiency factor cannot be equal to 0.')) + @api.multi def copy(self, default=None): self.ensure_one()