[FIX] purchase: orderpoint on existing PO

- Create product A:
Reordering rule of 5 units
Set a vendor V
- Create a SO with 1 unit of A
- Create a PO with 1 unit of A for vendor V
- Run the scheduler => the PO contains 6 units
- Run the scheduler => the PO contains 12 units

The PO should not be updated the second time the scheduler is run.

It occurs because the `orderpoint_id` is not set on the PO line, while
the `_quantity_in_progress` method searches for PO lines with the
orderpoint set.

opw-2000962

closes odoo/odoo#33798

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
Nicolas Martinelli
2019-05-31 13:19:15 +00:00
parent 0799742d05
commit dea93a683b
+5 -1
View File
@@ -983,11 +983,15 @@ class ProcurementRule(models.Model):
if price_unit and seller and line.order_id.currency_id and seller.currency_id != line.order_id.currency_id:
price_unit = seller.currency_id.compute(price_unit, line.order_id.currency_id)
return {
res = {
'product_qty': line.product_qty + procurement_uom_po_qty,
'price_unit': price_unit,
'move_dest_ids': [(4, x.id) for x in values.get('move_dest_ids', [])]
}
orderpoint_id = values.get('orderpoint_id')
if orderpoint_id:
res['orderpoint_id'] = orderpoint_id.id
return res
@api.multi
def _prepare_purchase_order_line(self, product_id, product_qty, product_uom, values, po, supplier):