From a2d554c0a55eb00002a22434606ffe0e48d3782b Mon Sep 17 00:00:00 2001 From: Pierre Masereel Date: Thu, 22 Feb 2018 15:39:09 +0100 Subject: [PATCH] [FIX] stock: fix various bug in picking views The following bugs in detailed operations have been fixed in this commit: - Avoid to edit reserved quantity on move lines. When a picking is set in 'UNLOCK' mode you are able to edit the reserved quantity of move lines, even if it doesn't really causes problems it create confusion on what is the reserved quantity. - Avoid to edit the product_id on a move if there is a move lines linked to it. This will cause inceonsistencies by having move lines with product_id different than the related moves. - Avoid to edit the product_id on a move line if it has a linked move for the same reasons as above. We also avoid the edition when picking is done to avoid issues with the stock valuation - Remove call to 'force_assign' method on demo data as this method is not used anymore and set some pickings in wierd states - Adding a move line in the detailed operation view does not create an associated move. - Don't allow editing moves when we are in detailed views and state is done, even if picking is unlocked. TASK-1817931 --- addons/stock/data/stock_demo.yml | 5 ----- addons/stock/models/stock_move.py | 8 ++++++++ addons/stock/models/stock_move_line.py | 2 +- addons/stock/views/stock_picking_views.xml | 10 ++++++---- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/addons/stock/data/stock_demo.yml b/addons/stock/data/stock_demo.yml index 697bd8a2cad..08573afe9ff 100644 --- a/addons/stock/data/stock_demo.yml +++ b/addons/stock/data/stock_demo.yml @@ -342,11 +342,6 @@ record_chi_in = self.browse(ref('incomming_chicago_warehouse1')) record_chi_out = self.browse(ref('outgoing_chicago_warehouse1')) if record.state != 'done' and record_chi_in.state != 'done' and record_chi_out.state != 'done': - self.browse([ - ref('outgoing_shipment_main_warehouse'), - ref('outgoing_chicago_warehouse3'), - ref('outgoing_shipment_main_warehouse2') - ]).force_assign() self.browse([ ref('outgoing_shipment_main_warehouse1'), ref('incomming_chicago_warehouse1'), diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index d97f69c861e..900398f14c0 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -158,6 +158,7 @@ class StockMove(models.Model): 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') reference = fields.Char(compute='_compute_reference', string="Reference", store=True) + has_move_lines = fields.Boolean(compute='_compute_has_move_lines') @api.depends('picking_id.is_locked') def _compute_is_locked(self): @@ -217,6 +218,8 @@ class StockMove(models.Model): move.is_quantity_done_editable = False elif move.show_details_visible: move.is_quantity_done_editable = False + elif move.show_operations: + move.is_quantity_done_editable = False else: move.is_quantity_done_editable = True @@ -225,6 +228,11 @@ class StockMove(models.Model): for move in self: move.reference = move.picking_id.name if move.picking_id else move.name + @api.depends('move_line_ids') + def _compute_has_move_lines(self): + for move in self: + move.has_move_lines = bool(move.move_line_ids) + @api.one @api.depends('product_id', 'product_uom', 'product_uom_qty') def _compute_product_qty(self): diff --git a/addons/stock/models/stock_move_line.py b/addons/stock/models/stock_move_line.py index 25f567a39db..82df0bef736 100644 --- a/addons/stock/models/stock_move_line.py +++ b/addons/stock/models/stock_move_line.py @@ -167,7 +167,7 @@ class StockMoveLine(models.Model): # If the move line is directly create on the picking view. # If this picking is already done we should generate an # associated done move. - if 'picking_id' in vals and 'move_id' not in vals: + if 'picking_id' in vals and not vals.get('move_id'): picking = self.env['stock.picking'].browse(vals['picking_id']) if picking.state == 'done': product = self.env['product.product'].browse(vals['product_id']) diff --git a/addons/stock/views/stock_picking_views.xml b/addons/stock/views/stock_picking_views.xml index 8ad0a305571..699e4c83306 100644 --- a/addons/stock/views/stock_picking_views.xml +++ b/addons/stock/views/stock_picking_views.xml @@ -259,7 +259,8 @@ - + + @@ -272,7 +273,7 @@ - + @@ -282,7 +283,7 @@ - + @@ -297,8 +298,9 @@ + - +