res_currency.compute should check for currency differences before any rate fetch

Bug #557325 reported by marc0s
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Released
Low
OpenERP's Framework R&D

Bug Description

The code in res_currency.compute can be optimized by checking whether we are working with different currencies or not before fetching any conversion rate from the database. Doing it this way we make easier to work when working with only one currency, without taking care of having the current conversion rates already loaded in the database. Actually I've found this by creating an invoice with EUR-only products and customers for a date before 2010-01-01, which is the date of the oldest EUR conversion rate stored in the database.

Revision history for this message
Eduard Carreras i Nadal (ecarreras) wrote :

This patch tries to solve this issue, checking firstly if to_currency_id==from_currency_id.

Changed in openobject-server:
milestone: none → 5.0.12
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

From the description of this bug, it looks like a wishlist / optimization, marking it so, and targetting for v6 (makes more sense right now - v5 only receives bugfixes)

If this is not the case, please explain what the bug is (as far as I can see if I attempt to create an invoice on a date where there is no currency conversion rate it correctly warns about it, so that must not be it).

Changed in openobject-server:
importance: Undecided → Wishlist
milestone: 5.0.12 → 6.0
status: New → Triaged
Revision history for this message
marc0s (marc0s) wrote :

Olivier it's OK to mark it as wishlist or optimization, as stated in the description, it's more a suggestion for optimizing existing code than a misfunction.

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

We should also double-check the code of compute for the "account.move.line" reference

Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Wishlist → Low
milestone: 6.0 → 6.0-rc2
status: Triaged → Confirmed
Revision history for this message
Fabien (Open ERP) (fp-tinyerp) wrote :

This code must be removed from addons/base/res/res_currency.py
(remove the account arg also)

2 if account and (account.currency_mode=='average') and account.currency_id:
2 q = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
2 cr.execute('select sum(debit-credit),sum(amount_currency) from account_move_line l ' \
2 'where l.currency_id=%s and l.account_id=%s and '+q, (account.currency_id.id,account.id,))
2 tot1,tot2 = cr.fetchone()

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Hello,

This suggestion has been implemented, and we have also removed all references to "account" in "base" and moved all account-related code to the account module. This is effective as of the following revisions:
- server: rev. 3150 <email address hidden>
- addons: rev. 4042 <email address hidden>

Thanks reporting, this allowed us to improve other things as well!

Changed in openobject-server:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.