Skip to content
Snippets Groups Projects
Commit e7ce0b43 authored by Nans Lefebvre's avatar Nans Lefebvre
Browse files

[FIX] stock_dropshipping: do not merge PO lines coming from a SO


Fine tuning of commit b9e3c153, for the same use-case.
The route may not be passed in values, in which case the bug is still present.
There are two ways to go around that.
We could add the stock.rule in values, which contains the route.
The solution we adopt here is to use the sale_line_id field on the purchase line
If it is present, it was added through _prepare_purchase_order_line,
and thus we want to keep track of the origin.

opw 1957701

closes odoo/odoo#32683

Signed-off-by: default avatarNans Lefebvre (len) <len@odoo.com>
parent c9c8f1b4
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,9 @@ class PurchaseOrderLine(models.Model):
return res
def _merge_in_existing_line(self, product_id, product_qty, product_uom, location_id, name, origin, values):
if values.get('route_ids') and values['route_ids'] == self.env.ref('stock_dropshipping.route_drop_shipping'):
if values.get('sale_line_id') and values['sale_line_id'] != self.sale_line_id.id:
# if this is defined, this is a dropshipping line, so no
# this is to correctly map delivered quantities to the so lines
return False
return super(PurchaseOrderLine, self)._merge_in_existing_line(
product_id=product_id, product_qty=product_qty, product_uom=product_uom,
......
......@@ -43,3 +43,19 @@ class TestDropship(TransactionCase):
# Update qty on SO and check PO
so.order_line.product_uom_qty = 2.00
self.assertAlmostEqual(po_line.product_qty, 2.00)
# Create a new so line
sol2 = self.env['sale.order.line'].create({
'order_id': so.id,
'name': prod.name,
'product_id': prod.id,
'product_uom_qty': 3.00,
'product_uom': prod.uom_id.id,
'price_unit': 12,
})
# there is a new line
pol2 = po.order_line - po_line
# the first line is unchanged
self.assertAlmostEqual(po_line.product_qty, 2.00)
# the new line matches the new line on the so
self.assertAlmostEqual(pol2.product_qty, sol2.product_uom_qty)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment