[FIX] mrp, 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:751638, 752035
This commit is contained in:
Goffin Simon
2017-07-12 13:32:51 +02:00
parent 0f2a06e29b
commit 45e7389a1e
3 changed files with 14 additions and 1 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ class MrpWorkcenter(models.Model):
# resource
name = fields.Char(related='resource_id.name', store=True)
time_efficiency = fields.Float('Time Efficiency', related='resource_id.time_efficiency', store=True)
time_efficiency = fields.Float('Time Efficiency', related='resource_id.time_efficiency', default=100, store=True)
active = fields.Boolean('Active', related='resource_id.active', default=True, store=True)
code = fields.Char('Code', copy=False)
+6
View File
@@ -441,6 +441,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:667
#, python-format
msgid "The efficiency factor cannot be equal to 0."
msgstr ""
#. module: resource
#: selection:resource.calendar.attendance,dayofweek:0
msgid "Thursday"
+7
View File
@@ -659,6 +659,13 @@ class ResourceResource(models.Model):
required=True,
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.model
def create(self, values):
if values.get('company_id') and not values.get('calendar_id'):