Skip to content

Commit

Permalink
[FIX] purchase_stock: vendor reference
Browse files Browse the repository at this point in the history
- Create a product A
  MTO, Buy
  Add a supplier S1 and set a specific reference
- Create a product B
  MTO, Buy
  Add a supplier S2 and set a specific reference
- Create a SO with A & B, confirm
- 2 RFQ are created

The first RFQ is created with the correct reference, but not the second
one.

This is because `display_name` depends on context keys: it is computed
once for both products with `partner_id` set as `S1`, while it should be
recomputed for product B with `partner_id` set as `S2`.

In order to avoid this, we use `with_prefetch()` to avoid reusing the
prefetched value.

opw-2176638

closes odoo#44487

Signed-off-by: Nicolas Martinelli (nim) <[email protected]>
  • Loading branch information
nim-odoo committed Feb 3, 2020
1 parent 6a5ce8d commit 88b686c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion addons/purchase_stock/models/stock_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def _prepare_purchase_order_line(self, product_id, product_qty, product_uom, com
price_unit = seller.currency_id._convert(
price_unit, po.currency_id, po.company_id, po.date_order or fields.Date.today())

product_lang = product_id.with_context(
product_lang = product_id.with_prefetch().with_context(
lang=partner.lang,
partner_id=partner.id,
)
Expand Down

0 comments on commit 88b686c

Please sign in to comment.