From 0b30f6aec4dcd945a92ccfdbf141c75071ea9d28 Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Fri, 22 Sep 2017 14:28:56 +0200 Subject: [PATCH] [FIX] stock: show operations view and planned pickings According to the planned_picking context key (which is set by the plan a picking button), the detailed operations page should be visible or not. --- addons/stock/models/stock_picking.py | 15 +++++++++++++-- addons/stock/views/stock_picking_views.xml | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index 6467f290f8b..fec1dadbe04 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -288,12 +288,23 @@ class Picking(models.Model): 'changing the done quantities.') # Used to search on pickings product_id = fields.Many2one('product.product', 'Product', related='move_lines.product_id') - show_operations = fields.Boolean(related='picking_type_id.show_operations') + show_operations = fields.Boolean(compute='_compute_show_operations') _sql_constraints = [ ('name_uniq', 'unique(name, company_id)', 'Reference must be unique per company!'), ] + @api.depends('picking_type_id.show_operations') + def _compute_show_operations(self): + for picking in self: + if picking.picking_type_id.show_operations: + if (picking.state == 'draft' and not self.env.context.get('planned_picking')) or picking.state != 'draft': + picking.show_operations = True + else: + picking.show_operations = False + else: + picking.show_operations = False + @api.depends('move_type', 'move_lines.state', 'move_lines.picking_id') @api.one def _compute_state(self): @@ -381,7 +392,7 @@ class Picking(models.Model): @api.depends('state', 'move_lines') def _compute_show_mark_as_todo(self): for picking in self: - if not self.move_lines: + if not picking.move_lines: picking.show_mark_as_todo = False elif self._context.get('planned_picking') and picking.state == 'draft': picking.show_mark_as_todo = True diff --git a/addons/stock/views/stock_picking_views.xml b/addons/stock/views/stock_picking_views.xml index 2a3a63fbf42..405ae33818b 100644 --- a/addons/stock/views/stock_picking_views.xml +++ b/addons/stock/views/stock_picking_views.xml @@ -254,7 +254,7 @@ - +