[FIX] purchase: link extra move to PO line

Commit ec949ad5 links the extra move to the Sale Order through the
procurement. To be consistent, we also have to link the extra move to
the Purchase Order.

The original issue is that any extra move is not taken into account in
the received quantity calculated.

opw-665398
This commit is contained in:
Nicolas Martinelli
2016-01-06 08:22:59 +01:00
parent 136c563bc6
commit fcab79217a
2 changed files with 13 additions and 1 deletions
+5 -1
View File
@@ -434,6 +434,7 @@ class PurchaseOrderLine(models.Model):
@api.depends('order_id.state', 'move_ids.state')
def _compute_qty_received(self):
ProductUom = self.env['product.uom']
for line in self:
if line.order_id.state not in ['purchase', 'done']:
line.qty_received = 0.0
@@ -444,7 +445,10 @@ class PurchaseOrderLine(models.Model):
total = 0.0
for move in line.move_ids:
if move.state == 'done':
total += move.product_uom_qty
if move.product_uom != line.product_uom:
total += ProductUom._compute_qty_obj(move.product_uom, move.product_uom_qty, line.product_uom)
else:
total += move.product_uom_qty
line.qty_received = total
name = fields.Text(string='Description', required=True)
+8
View File
@@ -12,6 +12,14 @@ class stock_picking(osv.osv):
readonly=True, relation="many2one"),
}
def _prepare_values_extra_move(self, cr, uid, op, product, remaining_qty, context=None):
res = super(stock_picking, self)._prepare_values_extra_move(cr, uid, op, product, remaining_qty, context=context)
for m in op.linked_move_operation_ids:
if m.move_id.purchase_line_id and m.move_id.product_id == product:
res['purchase_line_id'] = m.move_id.purchase_line_id.id
break
return res
class stock_move(osv.osv):
_inherit = 'stock.move'