From cb4c2be37748b92e97b32b5c8defce7b7c1e6bd9 Mon Sep 17 00:00:00 2001 From: len-odoo <35492570+len-odoo@users.noreply.github.com> Date: Fri, 18 May 2018 13:20:29 +0200 Subject: [PATCH] 11.0 fix negativewos jco (#24781) * [FIX] mrp: negative workorder issues - In the onchange of the qty_producing in the wo, we need to add the date to the stock.move.line as it is a required field. - When starting a workorder, check first if it has not already been done. --- addons/mrp/models/mrp_workorder.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py index c617427cd1f..f9e0bd5eadc 100644 --- a/addons/mrp/models/mrp_workorder.py +++ b/addons/mrp/models/mrp_workorder.py @@ -219,6 +219,7 @@ class MrpWorkorder(models.Model): 'done_wo': False, 'location_id': move.location_id.id, 'location_dest_id': move.location_dest_id.id, + 'date': move.date, }) qty_todo -= 1 elif float_compare(qty_todo, 0.0, precision_rounding=rounding) < 0: @@ -410,7 +411,12 @@ class MrpWorkorder(models.Model): @api.multi def button_start(self): - # TDE CLEANME + self.ensure_one() + # As button_start is automatically called in the new view + if self.state in ('done', 'cancel'): + return True + + # Need a loss in case of the real time exceeding the expected timeline = self.env['mrp.workcenter.productivity'] if self.duration < self.duration_expected: loss_id = self.env['mrp.workcenter.productivity.loss'].search([('loss_type','=','productive')], limit=1)