Skip to content
Snippets Groups Projects
Commit ed6ac9c6 authored by Andrea Grazioso (agr-odoo)'s avatar Andrea Grazioso (agr-odoo)
Browse files

[FIX] purchase: specific search alter order duplication


1) Go to purchasing, and in the search area type "8888"
2) Click on the little arrow next to "Search Product for: 8888"
3) Select "[FURN_8888] Office Lamp"
4) Choose Purchase Order PO00009 which has FURN_8888 on the second line:
5) Choose Action > Duplicate

The 1st line end up with the searched product, not the original product.
This happens because the search add the context key
'default_product_id'. By chance the product.product model has a
'product_id' field which may happen to be not filled.
This cause the model api to look for a default value in the context and the
first line of the order get overridden.

Removing the specific key from the env solve the issue

opw-2188429

closes odoo/odoo#44598

Signed-off-by: default avatarNicolas Martinelli (nim) <nim@odoo.com>
parent f9f33e08
No related branches found
No related tags found
No related merge requests found
......@@ -168,6 +168,9 @@ class PurchaseOrder(models.Model):
@api.multi
def copy(self, default=None):
ctx = dict(self.env.context)
ctx.pop('default_product_id', None)
self = self.with_context(ctx)
new_po = super(PurchaseOrder, self).copy(default=default)
for line in new_po.order_line:
seller = line.product_id._select_seller(
......
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