diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index 49859495318..0978adaec8a 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -564,6 +564,7 @@ class StockMove(models.Model): moves_to_assign = self.env['stock.move'] moves_to_do = self.env['stock.move'] operations = self.env['stock.pack.operation'] + ancestors_list = {} # work only on in progress moves moves = self.filtered(lambda move: move.state in ['confirmed', 'waiting', 'assigned']) @@ -586,6 +587,7 @@ class StockMove(models.Model): # we always search for yet unassigned quants main_domain[move.id] = [('reservation_id', '=', False), ('qty', '>', 0)] + ancestors_list[move.id] = True if ancestors else False if move.state == 'waiting' and not ancestors: # if the waiting move hasn't yet any ancestor (PO/MO not confirmed yet), don't find any quant available in stock main_domain[move.id] += [('id', '=', False)] @@ -629,7 +631,9 @@ class StockMove(models.Model): lot_qty[lot] -= qty move_qty -= qty - for move in moves_to_do: + # Sort moves to reserve first the ones with ancestors, in case the same product is listed in + # different stock moves. + for move in sorted(moves_to_do, key=lambda x: -1 if ancestors_list.get(x.id) else 0): # then if the move isn't totally assigned, try to find quants without any specific domain if move.state != 'assigned' and not self.env.context.get('reserve_only_ops'): qty_already_assigned = move.reserved_availability diff --git a/addons/web/static/src/js/framework/pyeval.js b/addons/web/static/src/js/framework/pyeval.js index 0430aee9274..bcab0b0717f 100644 --- a/addons/web/static/src/js/framework/pyeval.js +++ b/addons/web/static/src/js/framework/pyeval.js @@ -852,6 +852,7 @@ function eval_domains (domains, evaluation_context) { var result_domain = []; // Normalize only if the first domain is the array ["|"] or ["!"] var need_normalization = ( + domains && domains.length > 0 && domains[0].length === 1 && (domains[0][0] === "|" || domains[0][0] === "!") diff --git a/addons/web/static/src/js/views/list_view.js b/addons/web/static/src/js/views/list_view.js index 83420da2ace..dddc2b1bcf3 100644 --- a/addons/web/static/src/js/views/list_view.js +++ b/addons/web/static/src/js/views/list_view.js @@ -939,9 +939,11 @@ ListView.List = Class.extend({ $row = self.$current.children( '[data-id=' + record.get('id') + ']'); } - var $newRow = $(self.render_record(record)); - $newRow.find('.o_list_record_selector input').prop('checked', !!$row.find('.o_list_record_selector input').prop('checked')); - $row.replaceWith($newRow); + if ($row.length) { + var $newRow = $(self.render_record(record)); + $newRow.find('.o_list_record_selector input').prop('checked', !!$row.find('.o_list_record_selector input').prop('checked')); + $row.replaceWith($newRow); + } }, 'add': function (ev, records, record, index) { var $new_row = $(self.render_record(record));