From e3ee78c7ef37d3c039ebfb282d5463edca6c618c Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 7 Dec 2016 15:50:31 +0100 Subject: [PATCH] [FIX] mrp: start date The start date of a manufacturing order is never set. One consequence is that the Gantt view, which relies on this field, is never populated. opw-693743 --- addons/mrp/models/mrp_workorder.py | 7 +++++-- addons/mrp/wizard/mrp_product_produce.py | 7 ++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py index 9d2062b62c9..dbc0ee221c2 100644 --- a/addons/mrp/models/mrp_workorder.py +++ b/addons/mrp/models/mrp_workorder.py @@ -356,7 +356,10 @@ class MrpWorkorder(models.Model): raise UserError(_("You need to define at least one productivity loss in the category 'Performance'. Create one from the Manufacturing app, menu: Configuration / Productivity Losses.")) for workorder in self: if workorder.production_id.state != 'progress': - workorder.production_id.state = 'progress' + workorder.production_id.write({ + 'state': 'progress', + 'date_start': datetime.now(), + }) timeline.create({ 'workorder_id': workorder.id, 'workcenter_id': workorder.workcenter_id.id, @@ -449,4 +452,4 @@ class MrpWorkorder(models.Model): self.ensure_one() action = self.env.ref('stock.action_stock_scrap').read()[0] action['domain'] = [('workorder_id', '=', self.id)] - return action \ No newline at end of file + return action diff --git a/addons/mrp/wizard/mrp_product_produce.py b/addons/mrp/wizard/mrp_product_produce.py index 428cb627404..3ac2b1bf7c3 100644 --- a/addons/mrp/wizard/mrp_product_produce.py +++ b/addons/mrp/wizard/mrp_product_produce.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. +from datetime import datetime + from odoo import api, fields, models, _ from odoo.addons import decimal_precision as dp from odoo.exceptions import UserError @@ -87,7 +89,10 @@ class MrpProductProduce(models.TransientModel): move.quantity_done_store += quantity * move.unit_factor self.check_finished_move_lots() if self.production_id.state == 'confirmed': - self.production_id.state = 'progress' + self.production_id.write({ + 'state': 'progress', + 'date_start': datetime.now(), + }) return {'type': 'ir.actions.act_window_close'} @api.multi