← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~sistemas-adhoc/account-financial-tools/currency_update into lp:account-financial-tools

 

Juan José Scarafía has proposed merging lp:~sistemas-adhoc/account-financial-tools/currency_update into lp:account-financial-tools.

Requested reviews:
  Account Core Editors (account-core-editors)

For more details, see:
https://code.launchpad.net/~sistemas-adhoc/account-financial-tools/currency_update/+merge/203755

We make base currency based on currency marked as base and not related to company currency because sometimes your company currency is not the same you use as base currency. We think this way is more appropiate
-- 
https://code.launchpad.net/~sistemas-adhoc/account-financial-tools/currency_update/+merge/203755
Your team Account Core Editors is requested to review the proposed merge of lp:~sistemas-adhoc/account-financial-tools/currency_update into lp:account-financial-tools.
=== modified file 'currency_rate_update/currency_rate_update.py'
--- currency_rate_update/currency_rate_update.py	2013-03-19 11:01:15 +0000
+++ currency_rate_update/currency_rate_update.py	2014-01-29 14:21:10 +0000
@@ -164,7 +164,7 @@
     def run_currency_update(self, cr, uid):
         "update currency at the given frequence"
         factory = Currency_getter_factory()
-        curr_obj = self.pool.get('res_currency')
+        curr_obj = self.pool.get('res.currency')
         rate_obj = self.pool.get('res.currency.rate')
         companies = self.pool.get('res.company').search(cr, uid, [])
         for comp in self.pool.get('res.company').browse(cr, uid, companies):
@@ -176,8 +176,18 @@
             search_filter = []
             if comp.multi_company_currency_enable :
                 search_filter = [('company_id','=',comp.id)]
-            #we fetch the main currency. The main rate should be set at  1.00
-            main_curr = comp.currency_id.name
+            #we fetch the main currency looking for currency with base = true. The main rate should be set at  1.00
+            main_curr_ids = curr_obj.search(cr, uid, [('base','=',True),('company_id','=',comp.id)])
+            if not main_curr_ids:
+                # If we can not find a base currency for this company we look for one with no company set
+                main_curr_ids = curr_obj.search(cr, uid, [('base','=',True),('company_id','=', False)])
+            if main_curr_ids:
+                main_curr_rec = curr_obj.browse(cr, uid, main_curr_ids[0])
+            else:
+                print ('Error !', 'There is no base currency set!')
+            if main_curr_rec.rate != 1:
+                print ('Error !', 'Base currency rate should be 1.00!')
+            main_curr = main_curr_rec.name
             for service in comp.services_to_use :
                 print "comp.services_to_use =", comp.services_to_use
                 note = service.note or ''


Follow ups