diff --git a/addons/stock_dropshipping/models/purchase.py b/addons/stock_dropshipping/models/purchase.py index cefc96ee830..533ecc89187 100644 --- a/addons/stock_dropshipping/models/purchase.py +++ b/addons/stock_dropshipping/models/purchase.py @@ -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, diff --git a/addons/stock_dropshipping/tests/test_dropship.py b/addons/stock_dropshipping/tests/test_dropship.py index 7fb7a4ddf7c..5eb9bf8bf57 100644 --- a/addons/stock_dropshipping/tests/test_dropship.py +++ b/addons/stock_dropshipping/tests/test_dropship.py @@ -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)