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 @@ + - +