diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index 52727d083cb..f248e727b86 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -156,6 +156,7 @@ class StockMove(models.Model): additional = fields.Boolean("Whether the move was added after the picking's confirmation", default=False) is_locked = fields.Boolean(related='picking_id.is_locked', readonly=True) is_initial_demand_editable = fields.Boolean('Is initial demand editable', compute='_compute_is_initial_demand_editable') + is_quantity_done_editable = fields.Boolean('Is quantity done editable', compute='_compute_is_quantity_done_editable') @api.depends('product_id', 'has_tracking', 'move_line_ids', 'location_id', 'location_dest_id') def _compute_show_details_visible(self): @@ -196,6 +197,17 @@ class StockMove(models.Model): else: move.is_initial_demand_editable = False + @api.multi + @api.depends('state', 'picking_id') + def _compute_is_quantity_done_editable(self): + for move in self: + if self._context.get('planned_picking') and move.picking_id.state == 'draft': + move.is_quantity_done_editable = False + elif move.picking_id.is_locked and move.state in ('done', 'cancel'): + move.is_quantity_done_editable = False + else: + move.is_quantity_done_editable = True + @api.one @api.depends('product_id', 'product_uom', 'product_uom_qty') def _compute_product_qty(self): diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index 078b1172ca2..f01532da49d 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -271,6 +271,12 @@ class Picking(models.Model): show_check_availability = fields.Boolean( compute='_compute_show_check_availability', help='Technical field used to compute whether the check availability button should be shown.') + show_mark_as_todo = fields.Boolean( + compute='_compute_show_mark_as_todo', + help='Technical field used to compute whether the mark as todo button should be shown.') + show_validate = fields.Boolean( + compute='_compute_show_validate', + help='Technical field used to compute whether the validate should be shown.') owner_id = fields.Many2one( 'res.partner', 'Owner', @@ -371,6 +377,28 @@ class Picking(models.Model): ) picking.show_check_availability = picking.is_locked and picking.state in ('confirmed', 'waiting') and has_moves_to_reserve + @api.multi + @api.depends('state') + def _compute_show_mark_as_todo(self): + for picking in self: + if self._context.get('planned_picking') and picking.state == 'draft': + picking.show_mark_as_todo = True + elif picking.state != 'draft' or not picking.id: + picking.show_mark_as_todo = False + else: + picking.show_mark_as_todo = True + + @api.multi + @api.depends('state', 'is_locked') + def _compute_show_validate(self): + for picking in self: + if self._context.get('planned_picking') and picking.state == 'draft': + picking.show_validate = False + elif picking.state not in ('draft', 'confirmed', 'assigned') or not picking.is_locked: + picking.show_validate = False + else: + picking.show_validate = True + @api.onchange('picking_type_id', 'partner_id') def onchange_picking_type(self): if self.picking_type_id: diff --git a/addons/stock/views/stock_picking_views.xml b/addons/stock/views/stock_picking_views.xml index 3dc8dcbb43d..987cbbea883 100644 --- a/addons/stock/views/stock_picking_views.xml +++ b/addons/stock/views/stock_picking_views.xml @@ -201,10 +201,12 @@