Skip to content

Commit

Permalink
[IMP] Simpler....
Browse files Browse the repository at this point in the history
  • Loading branch information
jco-odoo committed Feb 21, 2017
1 parent dbccf32 commit 01053a5
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions addons/stock/models/stock_inventory.py
Expand Up @@ -390,15 +390,11 @@ def _generate_moves(self):
if float_utils.float_compare(line.theoretical_qty, line.product_qty, precision_rounding=line.product_id.uom_id.rounding) == 0 and not neg_quants:
continue

neg_quant_qty = - sum([x.qty for x in neg_quants])
if float_utils.float_compare(line.theoretical_qty, 0, precision_rounding=line.product_id.uom_id.rounding) < 0:
neg_quant_qty += line.theoretical_qty # As the theoretical_qty is negative, we add it to neg_quant_qty
diff = line.theoretical_qty - line.product_qty
if diff > 0:
neg_quant_qty -= diff
if neg_quant_qty < 0:
neg_quant_qty = 0

neg_quant_qty = - sum([x.qty for x in neg_quants])
if diff < 0:
neg_quant_qty -= min(neg_quant_qty, -diff) # Reconciliation will be done when adding material for the difference already

vals = {
'name': _('INV:') + (line.inventory_id.name or ''),
'product_id': line.product_id.id,
Expand All @@ -408,7 +404,8 @@ def _generate_moves(self):
'inventory_id': line.inventory_id.id,
'state': 'confirmed',
'restrict_lot_id': line.prod_lot_id.id,
'restrict_partner_id': line.partner_id.id}
'restrict_partner_id': line.partner_id.id
}
move_add = False
move_rem = False
if diff < 0 or neg_quant_qty: # found more than expected
Expand Down Expand Up @@ -436,4 +433,4 @@ def _generate_moves(self):
for quant in move_add.quant_ids:
if quant.location_id.id == move_add.location_dest_id.id: #To avoid we take a quant that was reconcile already
quant._quant_reconcile_negative(move_add)
return moves
return moves

0 comments on commit 01053a5

Please sign in to comment.