odoo / odoo

Odoo. Open Source Apps To Grow Your Business.
https://www.odoo.com
Other
39.2k stars 25.38k forks source link

sale_margin no conversion rate is used to calculate gross margin #54251

Open grey27 opened 4 years ago

grey27 commented 4 years ago

Impacted versions:13.0

my standard currency is CNY I set the cost of a product to 50 CNY

when I set up a price list in USD I set this product as 5 USD on the sale lines The calculated gross profit is -45 USD

odoo\addons\sale_margin\models\sale_order.py

  @api.depends('product_id', 'purchase_price', 'product_uom_qty', 'price_unit', 'price_subtotal')
    def _product_margin(self):
        for line in self:
            currency = line.order_id.pricelist_id.currency_id
            price = line.purchase_price 
            margin = line.price_subtotal - (price * line.product_uom_qty)
            line.margin = currency.round(margin) if currency else margin

the reason I found is that there is no exchange rate conversion when calculating gross profit in this method

maybe you should

price = line.purchase_price  * currency.rate
sswapnesh commented 4 years ago

Not sure but It is talking about https://github.com/odoo/odoo/issues/52562 ? (About missing calculation of Multi-currency)

pedrobaeza commented 4 years ago

AFAIK, the margin is expressed in the quotation currency.