[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#71089 X-original-commit: a6783acaef3c7c2224d1cda72717a36c4b38c001 Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
This commit is contained in:
@@ -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'):
|
||||
|
||||
@@ -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?"/>
|
||||
<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="do_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"/>
|
||||
@@ -189,7 +189,7 @@
|
||||
<label for="date_planned_start"/>
|
||||
<div class="o_row">
|
||||
<field name="date_planned_start"
|
||||
attrs="{'readonly': ['|', ('is_planned', '=', True), ('state', 'in', ['done', 'cancel'])]}"
|
||||
attrs="{'readonly': [('state', 'in', ['close', 'cancel'])]}"
|
||||
decoration-warning="state not in ('done', 'cancel') and date_planned_start < now"
|
||||
decoration-danger="state not in ('done', 'cancel') and date_planned_start < current_date"
|
||||
decoration-bf="state not in ('done', 'cancel') and (date_planned_start < current_date or date_planned_start < now)"/>
|
||||
|
||||
Reference in New Issue
Block a user