diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index e438ee2220a..cfef384f808 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -359,13 +359,19 @@ class PurchaseOrder(models.Model): # Do not add a contact as a supplier partner = self.partner_id if not self.partner_id.parent_id else self.partner_id.parent_id if line.product_id and partner not in line.product_id.seller_ids.mapped('name') and len(line.product_id.seller_ids) <= 10: + # Convert the price in the right currency. currency = partner.property_purchase_currency_id or self.env.company.currency_id + price = self.currency_id._convert(line.price_unit, currency, line.company_id, line.date_order or fields.Date.today(), round=False) + # Compute the price for the template's UoM, because the supplier's UoM is related to that UoM. + if line.product_id.product_tmpl_id.uom_po_id != line.product_uom: + default_uom = line.product_id.product_tmpl_id.uom_po_id + price = line.product_uom._compute_price(price, default_uom) + supplierinfo = { 'name': partner.id, 'sequence': max(line.product_id.seller_ids.mapped('sequence')) + 1 if line.product_id.seller_ids else 1, - 'product_uom': line.product_uom.id, 'min_qty': 0.0, - 'price': self.currency_id._convert(line.price_unit, currency, line.company_id, line.date_order or fields.Date.today(), round=False), + 'price': price, 'currency_id': currency.id, 'delay': 0, }