From dee25dccbd7d098ccaca26c330b55aa3d96d05ab Mon Sep 17 00:00:00 2001 From: William Henrotin Date: Tue, 22 Sep 2020 09:31:22 +0000 Subject: [PATCH] [IMP] mrp: change scheduled date unplan workorders MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With this commit, changing the scheduled date on a planned production order will unplan the workorders and so highlight the 'Plan' button to replan them from the new scheduled date. closes odoo/odoo#71089 X-original-commit: a6783acaef3c7c2224d1cda72717a36c4b38c001 Signed-off-by: Rémy Voet --- addons/mrp/models/mrp_production.py | 4 ++-- addons/mrp/views/mrp_production_views.xml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index eed00193df3..64859aae120 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -691,8 +691,8 @@ class MrpProduction(models.Model): if 'date_planned_start' in vals and not self.env.context.get('force_date', False): if production.state in ['done', 'cancel']: raise UserError(_('You cannot move a manufacturing order once it is cancelled or done.')) - if any(wo.date_planned_start and wo.date_planned_finished for wo in production.workorder_ids): - raise UserError(_('You cannot move a manufacturing order once it has a planned workorder, move related workorder(s) instead.')) + if production.is_planned: + production.button_unplan() if vals.get('date_planned_start'): production.move_raw_ids.write({'date': production.date_planned_start, 'date_deadline': production.date_planned_start}) if vals.get('date_planned_finished'): diff --git a/addons/mrp/views/mrp_production_views.xml b/addons/mrp/views/mrp_production_views.xml index 6a6588542f3..0db33089bb7 100644 --- a/addons/mrp/views/mrp_production_views.xml +++ b/addons/mrp/views/mrp_production_views.xml @@ -87,9 +87,9 @@ ('state', '!=', 'to_close')]}" string="Mark as Done" type="object" class="oe_highlight" confirm="There are no components to consume. Are you still sure you want to continue?"/>