Skip to content

[FIX] product_replenishment_cost: skip currency convert when same currency in compute#905

Open
jcadhoc wants to merge 1 commit into
ingadhoc:18.0from
adhoc-dev:18.0-h-115433-jc
Open

[FIX] product_replenishment_cost: skip currency convert when same currency in compute#905
jcadhoc wants to merge 1 commit into
ingadhoc:18.0from
adhoc-dev:18.0-h-115433-jc

Conversation

@jcadhoc

@jcadhoc jcadhoc commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Problem

_compute_price_unit_and_date_planned_and_name calls seller.currency_id._convert() unconditionally. When the seller currency and the line currency are the same (e.g. both USD), _convert still applies the currency's rounding precision. For very small prices below that precision (e.g. 0.0046 USD rounded to 2 decimals → 0.00), the computed price_unit becomes 0 on manually added PO lines.

This does not affect replenishment (_prepare_purchase_order_line), which already has the guard:

if supplier.currency_id != po.currency_id:
    price_unit = supplier.currency_id._convert(...)

Fix

Apply the same guard in _compute_price_unit_and_date_planned_and_name: only call _convert when the currencies differ.

Related PRs

Works together with:

…rency in compute

_compute_price_unit_and_date_planned_and_name was calling _convert()
unconditionally, which applies currency rounding even for same-currency
pairs. For supplier prices below currency precision (e.g. 0.0046 USD
rounded to 2 decimals = 0.00), this caused price_unit to compute as 0
on manually added PO lines.

_prepare_purchase_order_line already guards with
  if supplier.currency_id != po.currency_id
Apply the same guard in the compute method.
@roboadhoc

Copy link
Copy Markdown
Contributor

Pull request status dashboard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants