summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Henrotin <whe@odoo.com>2020-09-22 09:31:22 +0000
committerWilliam Henrotin <whe@odoo.com>2020-09-25 07:30:48 +0000
commit7cbb4eb9afa64206c46b56b01d4b51d58e0219cb (patch)
tree4e153533810ad200b2adbc8270552d5e63a20c96
parent481f84953159837514ca4a0cdf825821fc37b6f0 (diff)
[IMP] mrp: change scheduled date unplan workorders
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#58185 Related: odoo/enterprise#13397 Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
-rw-r--r--addons/mrp/models/mrp_production.py4
-rw-r--r--addons/mrp/views/mrp_production_views.xml6
2 files changed, 5 insertions, 5 deletions
diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py
index 2e899ea0f02..540af59415c 100644
--- a/addons/mrp/models/mrp_production.py
+++ b/addons/mrp/models/mrp_production.py
@@ -714,8 +714,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 e9d4926fbdc..dc06a60bfbe 100644
--- a/addons/mrp/views/mrp_production_views.xml
+++ b/addons/mrp/views/mrp_production_views.xml
@@ -77,9 +77,9 @@
('qty_producing', '!=', 0),
('state', '!=', 'to_close')]}" string="Mark as Done" type="object" class="oe_highlight"/>
<button name="action_confirm" attrs="{'invisible': [('state', '!=', 'draft')]}" string="Confirm" type="object" class="oe_highlight"/>
- <button name="action_assign" attrs="{'invisible': ['|', ('state', 'in', ('draft', 'done', 'cancel')), ('reserve_visible', '=', False)]}" string="Check availability" type="object"/>
<button name="button_plan" attrs="{'invisible': ['|', '|', ('state', 'not in', ('confirmed', 'progress', 'to_close')), ('workorder_ids', '=', []), ('is_planned', '=', True)]}" type="object" string="Plan" class="oe_highlight"/>
- <button name="button_unplan" type="object" string="Unplan" attrs="{'invisible': ['|', '|', ('is_planned', '!=', 'True'), ('date_planned_start', '=', False), ('date_planned_finished', '=', False)]}"/>
+ <button name="button_unplan" type="object" string="Unplan" attrs="{'invisible': [('is_planned', '=', False)]}"/>
+ <button name="action_assign" attrs="{'invisible': ['|', ('state', 'in', ('draft', 'done', 'cancel')), ('reserve_visible', '=', False)]}" string="Check availability" type="object"/>
<button name="button_unreserve" type="object" string="Unreserve" attrs="{'invisible': [('unreserve_visible', '=', False)]}"/>
<button name="button_scrap" type="object" string="Scrap" attrs="{'invisible': [('state', 'in', ('cancel', 'draft'))]}"/>
<field name="state" widget="statusbar" statusbar_visible="draft,confirmed,progress,done"/>
@@ -177,7 +177,7 @@
<label for="date_planned_start"/>
<div class="o_row">
<field name="date_planned_start"
- attrs="{'readonly': ['|', ('is_planned', '=', True), ('state', 'in', ['close', 'cancel'])]}"
+ attrs="{'readonly': [('state', 'in', ['close', 'cancel'])]}"
decoration-warning="state not in ('done', 'cancel') and date_planned_start &lt; now"
decoration-danger="state not in ('done', 'cancel') and date_planned_start &lt; current_date"
decoration-bf="state not in ('done', 'cancel') and (date_planned_start &lt; current_date or date_planned_start &lt; now)"/>