[FIX] stock, mrp: don't allow to unlock when state 'cancel'

When a picking or a manufacturing order is in state cancel, we shouldn't
be able to modify it as we didn't move anything and it won't have any
impact on stock
This commit is contained in:
Vandan Shah
2017-09-30 10:32:32 +02:00
committed by Pierre Masereel
parent 74493be97f
commit 2cf234df6d
4 changed files with 4 additions and 3 deletions
+1 -1
View File
@@ -526,7 +526,7 @@ class MrpProduction(models.Model):
raw_moves = production.move_raw_ids.filtered(lambda x: x.state not in ('done', 'cancel'))
(finish_moves | raw_moves)._action_cancel()
self.write({'state': 'cancel'})
self.write({'state': 'cancel', 'is_locked': True})
return True
def _cal_price(self, consumed_moves):
+1 -1
View File
@@ -48,7 +48,7 @@
<button name="button_unreserve" type="object" string="Unreserve" attrs="{'invisible': [('unreserve_visible', '=', False)]}"/>
<span class="label label-danger" attrs="{'invisible': ['|',('availability', 'in', ('assigned', 'none')), ('state', 'not in', ('confirmed','progress'))]}">Raw materials not available!</span>
<field name="state" widget="statusbar" statusbar_visible="confirmed,progress,done"/>
<button name="action_toggle_is_locked" attrs="{'invisible': ['|', ('id', '=', False), ('is_locked', '=', False)]}" string="Unlock" groups="mrp.group_mrp_manager" type="object" help="If the manufacturing order is unlocked you can add to the initial demand."/>
<button name="action_toggle_is_locked" attrs="{'invisible': ['|', '|', ('state', '=', 'cancel'), ('id', '=', False), ('is_locked', '=', False)]}" string="Unlock" groups="mrp.group_mrp_manager" type="object" help="If the manufacturing order is unlocked you can add to the initial demand."/>
<button name="action_toggle_is_locked" attrs="{'invisible': [('is_locked', '=', True)]}" string="Lock" class="oe_highlight" groups="mrp.group_mrp_manager" type="object"/>
</header>
<sheet>
+1
View File
@@ -539,6 +539,7 @@ class Picking(models.Model):
@api.multi
def action_cancel(self):
self.mapped('move_lines')._action_cancel()
self.is_locked = True
return True
@api.multi
+1 -1
View File
@@ -217,7 +217,7 @@
<field name="move_line_exist" invisible="1"/>
<field name="has_packages" invisible="1"/>
<button name="button_scrap" type="object" string="Scrap" attrs="{'invisible': ['|', '|', '&amp;', ('picking_type_code', '!=', 'incoming'), ('state', 'in', ('draft', 'cancel', 'waiting')), '&amp;', ('picking_type_code', '=', 'incoming'), ('state', '!=', 'done'), ('is_locked', '=', False)]}"/>
<button name="action_toggle_is_locked" attrs="{'invisible': ['|', ('state', '=', 'draft'), ('is_locked', '=', False)]}" string="Unlock" groups="stock.group_stock_manager" type="object" help="If the picking is unlocked you can edit initial demand (for a draft picking) or done quantities (for a done picking)."/>
<button name="action_toggle_is_locked" attrs="{'invisible': ['|', ('state', 'in', ('draft','cancel')), ('is_locked', '=', False)]}" string="Unlock" groups="stock.group_stock_manager" type="object" help="If the picking is unlocked you can edit initial demand (for a draft picking) or done quantities (for a done picking)."/>
<button name="action_toggle_is_locked" attrs="{'invisible': [('is_locked', '=', True)]}" string="Lock" class="oe_highlight" groups="stock.group_stock_manager" type="object"/>
<field name="state" widget="statusbar" statusbar_visible="draft,confirmed,partially_available,assigned,done" />
<field name="picking_type_entire_packs" invisible="1"/>