diff options
| author | Adrien Widart <awt@odoo.com> | 2021-03-05 16:27:47 +0000 |
|---|---|---|
| committer | Adrien Widart <awt@odoo.com> | 2021-03-08 07:46:53 +0000 |
| commit | 377f70ada0ec720aca055986ff19b8bbff84e33d (patch) | |
| tree | 8b87067936284d31d4db3b9dfe954488e5f76876 | |
| parent | 7e7d8731aa5679123100311b573a65ae23f3db99 (diff) | |
[FIX] sale_stock_margin: compute product uom qty
When confirming a SO, if a line uses a different UoM than the default
UoM of the line product, the computed cost will be updated to the
product unit cost.
To reproduce the error:
1. In Settings, enable:
- Units of Measure
- Margins
2. Create a product P
- Sales Price: $100
- No customer taxes
- Cost: $50
- UoM: Units
3. Create a SO
- Add P
- Set the line UoM to 'Dozens'
4. Display the order line field "Cost"
- [Note] As you can see, since UoM is 'Dozens':
- Unit Price: $1200
- Cost: $600
5. Confirm the SO
Error: Line cost becomes $50 (the cost of one P-product). Since the UoM
of the line is 'Dozens', Cost should be $600 (as before confirming the
SO). As a result, this error creates incorrect data in the margins
(95.83% instead of 50%).
OPW-2444335
closes odoo/odoo#67397
Signed-off-by: Adrien Widart <adwid@users.noreply.github.com>
| -rw-r--r-- | addons/sale_stock_margin/models/sale_order_line.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/addons/sale_stock_margin/models/sale_order_line.py b/addons/sale_stock_margin/models/sale_order_line.py index 67e56b87e29..9ed4be62849 100644 --- a/addons/sale_stock_margin/models/sale_order_line.py +++ b/addons/sale_stock_margin/models/sale_order_line.py @@ -15,4 +15,6 @@ class SaleOrderLine(models.Model): lines_without_moves |= line elif line.product_id.categ_id.property_cost_method != 'standard': line.purchase_price = line.product_id.with_company(line.company_id)._compute_average_price(0, line.product_uom_qty, line.move_ids) + if line.product_uom and line.product_uom != line.product_id.uom_id: + line.purchase_price = line.product_id.uom_id._compute_price(line.purchase_price, line.product_uom) return super(SaleOrderLine, lines_without_moves)._compute_purchase_price() |
