[FIX] sale_purchase: raise if currency are not the same

- Create un SO in EUR with a product with service_to_purchase, with supplier A
- Supplier A work in USD
--> Confirm order
Issue fields.datetime.now() doesn't exist.

closes odoo/odoo#110795

X-original-commit: 02813802a429570a05cf5ad1402408b2e3d01e99
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
This commit is contained in:
Florent de Labarre
2023-01-24 10:21:01 +01:00
committed by William Henrotin
parent adad3f06ed
commit c2adc51cd9
@@ -172,7 +172,7 @@ class SaleOrderLine(models.Model):
price_unit = self.env['account.tax'].sudo()._fix_tax_included_price_company(
supplierinfo.price, supplier_taxes, taxes, self.company_id)
if purchase_order.currency_id and supplierinfo.currency_id != purchase_order.currency_id:
price_unit = supplierinfo.currency_id._convert(price_unit, purchase_order.currency_id, purchase_order.company_id, fields.datetime.today())
price_unit = supplierinfo.currency_id._convert(price_unit, purchase_order.currency_id, purchase_order.company_id, fields.Date.context_today(self))
product_ctx.update({'seller_id': supplierinfo.id})
else:
product_ctx.update({'partner_id': purchase_order.partner_id.id})