Skip to content
Snippets Groups Projects
Commit 6fc5bb27 authored by Touati Djamel (otd)'s avatar Touati Djamel (otd)
Browse files

[FIX] purchase: use the current company currency in purchase analysis


Steps to reproduce the bug:
- Connect with a company using USD currency.
- Create a storable product "P1":
    - Cost: $100

- Create a Purchase order:
    - Add 1 unit of "P1"
    - Currency: USD

- Create another Purchase order:
    - Add 1 unit of "P1"
    - Currency: EUR

- Go to the purchase analysis and select the list view.

Problem:
The purchase order in EUR is converted into the current company
currency, but the Euro currency symbol is used instead of the dollar
symbol

opw-3354221
opw-3348265

closes odoo/odoo#127389

Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
parent 994fe756
No related branches found
No related tags found
No related merge requests found
......@@ -80,7 +80,7 @@ class PurchaseReport(models.Model):
l.product_id,
p.product_tmpl_id,
t.categ_id as category_id,
po.currency_id,
c.currency_id,
t.uom_id as product_uom,
extract(epoch from age(po.date_approve,po.date_order))/(24*60*60)::decimal(16,2) as delay,
extract(epoch from age(l.date_planned,po.date_order))/(24*60*60)::decimal(16,2) as delay_pass,
......@@ -111,6 +111,7 @@ class PurchaseReport(models.Model):
join res_partner partner on po.partner_id = partner.id
left join product_product p on (l.product_id=p.id)
left join product_template t on (p.product_tmpl_id=t.id)
left join res_company C ON C.id = po.company_id
left join uom_uom line_uom on (line_uom.id=l.product_uom)
left join uom_uom product_uom on (product_uom.id=t.uom_id)
left join account_analytic_account analytic_account on (l.account_analytic_id = analytic_account.id)
......@@ -133,7 +134,7 @@ class PurchaseReport(models.Model):
po.user_id,
po.partner_id,
line_uom.factor,
po.currency_id,
c.currency_id,
l.price_unit,
po.date_approve,
l.date_planned,
......
......@@ -153,3 +153,35 @@ class TestPurchaseOrderReport(AccountTestInvoicingCommon):
)
self.assertEqual(report[0]['qty_ordered'], 11)
self.assertEqual(round(report[0]['price_average'], 2), 46.36)
def test_po_report_currency(self):
"""
Check that the currency of the report is the one of the current company
"""
po = self.env['purchase.order'].create({
'partner_id': self.partner_a.id,
'currency_id': self.currency_data['currency'].id,
'order_line': [
(0, 0, {
'product_id': self.product_a.id,
'product_qty': 10.0,
'price_unit': 50.0,
}),
],
})
po_2 = self.env['purchase.order'].create({
'partner_id': self.partner_a.id,
'currency_id': self.env['res.currency'].search([('name', '=', 'EUR')], limit=1).id,
'order_line': [
(0, 0, {
'product_id': self.product_a.id,
'product_qty': 10.0,
'price_unit': 50.0,
}),
],
})
# flush the POs to make sure the report is up to date
po.flush()
po_2.flush()
report = self.env['purchase.report'].search([('product_id', "=", self.product_a.id)])
self.assertEqual(report.currency_id, self.env.company.currency_id)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment