Skip to content

Commit

Permalink
[MERGE] forward port branch saas-6 up to 7bcfa2b
Browse files Browse the repository at this point in the history
  • Loading branch information
KangOl committed Mar 28, 2017
2 parents 30dda3f + 7bcfa2b commit e876bec
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
6 changes: 6 additions & 0 deletions addons/stock/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -2429,6 +2429,7 @@ def action_assign(self, cr, uid, ids, no_prepare=False, context=None):
main_domain = {}
todo_moves = []
operations = set()
ancestors_list = {}
self.do_unreserve(cr, uid, [x.id for x in self.browse(cr, uid, ids, context=context) if x.reserved_quant_ids and x.state in ['confirmed', 'waiting', 'assigned']], context=context)
for move in self.browse(cr, uid, ids, context=context):
if move.state not in ('confirmed', 'waiting', 'assigned'):
Expand All @@ -2449,6 +2450,7 @@ def action_assign(self, cr, uid, ids, no_prepare=False, context=None):

#if the move is preceeded, restrict the choice of quants in the ones moved previously in original move
ancestors = self.find_move_ancestors(cr, uid, move, context=context)
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)]
Expand Down Expand Up @@ -2491,6 +2493,10 @@ def action_assign(self, cr, uid, ids, no_prepare=False, context=None):
lot_qty[lot] -= qty
move_qty -= qty


# Sort moves to reserve first the ones with ancestors, in case the same product is listed in
# different stock moves.
todo_moves.sort(key=lambda x: -1 if ancestors_list.get(x.id) else 0)
for move in todo_moves:
#then if the move isn't totally assigned, try to find quants without any specific domain
if (move.state != 'assigned') and not context.get("reserve_only_ops"):
Expand Down
1 change: 1 addition & 0 deletions addons/web/static/src/js/framework/pyeval.js
Original file line number Diff line number Diff line change
Expand Up @@ -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] === "!")
Expand Down
8 changes: 5 additions & 3 deletions addons/web/static/src/js/views/list_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -1027,9 +1027,11 @@ ListView.List = Class.extend( /** @lends instance.web.ListView.List# */{
'[data-id=' + record.get('id') + ']');
}

var $newRow = $(self.render_record(record));
$newRow.find('.oe_list_record_selector input').prop('checked', !!$row.find('.oe_list_record_selector input').prop('checked'));
$row.replaceWith($newRow);
if ($row.length) {
var $newRow = $(self.render_record(record));
$newRow.find('.oe_list_record_selector input').prop('checked', !!$row.find('.oe_list_record_selector input').prop('checked'));
$row.replaceWith($newRow);
}
},
'add': function (ev, records, record, index) {
var $new_row = $(self.render_record(record));
Expand Down

0 comments on commit e876bec

Please sign in to comment.