diff options
| author | Nicolas Martinelli <nim@odoo.com> | 2016-01-05 15:47:49 +0100 |
|---|---|---|
| committer | Nicolas Martinelli <nim@odoo.com> | 2016-01-06 08:22:59 +0100 |
| commit | fcab79217a11fc105cdabf881fdb8f2bf28da1de (patch) | |
| tree | 761edaab36411ad3a051ac64c3acb803f2638aa8 | |
| parent | 136c563bc6c7c7325cd1f785024e7e047e684cdd (diff) | |
[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
| -rw-r--r-- | addons/purchase/purchase.py | 6 | ||||
| -rw-r--r-- | addons/purchase/stock.py | 8 |
2 files changed, 13 insertions, 1 deletions
diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 6d134f4f200..8e9adb74f32 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -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) diff --git a/addons/purchase/stock.py b/addons/purchase/stock.py index 791672b1dfc..b0486950f26 100644 --- a/addons/purchase/stock.py +++ b/addons/purchase/stock.py @@ -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' |
