Merge lp:~camptocamp/account-financial-tools/6.1-fix-1276998 into lp:~account-core-editors/account-financial-tools/6.1

Proposed by Yannick Vaucher @ Camptocamp
Status: Merged
Merged at revision: 108
Proposed branch: lp:~camptocamp/account-financial-tools/6.1-fix-1276998
Merge into: lp:~account-core-editors/account-financial-tools/6.1
Diff against target: 56 lines (+5/-10)
1 file modified
currency_rate_update/currency_rate_update.py (+5/-10)
To merge this branch: bzr merge lp:~camptocamp/account-financial-tools/6.1-fix-1276998
Reviewer Review Type Date Requested Status
Alexis de Lattre (community) code review and tests with openerp 6.1 Approve
Alexandre Fayolle - camptocamp code review, no test Approve
Pedro Manuel Baeza code review Approve
Review via email: mp+205121@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Why do you put self.logger?

Usual practice is to declare one variable:

logger = logging.get(self.__name__)

And then use it.

Regards.

review: Needs Fixing (code review)
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

I'm just using the self.logger which is instantiated in Currency_rate_update_service class.

This fix is a simple fix to restore currency_rate_update which is broken.

109. By Yannick Vaucher @ Camptocamp

[FIX] replace netsvc notifyChannel by logger.info and remove import of netsvc

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

OK then, I don't see that instantiation on MP, so my question was by that.

Regards.

review: Approve (code review)
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

line 55 could use self.logger.error(error_msg) (ie. change the logging level and use a more informative message)

review: Approve (code review, no test)
Revision history for this message
Alexis de Lattre (alexis-via) :
review: Approve (code review and tests with openerp 6.1)
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

I fast tracked this one and merged it a moment ago.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'currency_rate_update/currency_rate_update.py'
--- currency_rate_update/currency_rate_update.py 2013-09-17 18:12:30 +0000
+++ currency_rate_update/currency_rate_update.py 2014-02-06 11:45:49 +0000
@@ -45,7 +45,7 @@
45from osv import osv, fields45from osv import osv, fields
46import time46import time
47from datetime import datetime, timedelta47from datetime import datetime, timedelta
48import netsvc48import logging
49from tools.translate import _49from tools.translate import _
5050
51class Currency_rate_update_service(osv.osv):51class Currency_rate_update_service(osv.osv):
@@ -128,7 +128,6 @@
128 }128 }
129129
130 logger = logging.getLogger(__name__)130 logger = logging.getLogger(__name__)
131 LOG_NAME = 'cron-rates'
132 MOD_NAME = 'currency_rate_update: '131 MOD_NAME = 'currency_rate_update: '
133 def get_cron_id(self, cr, uid, context):132 def get_cron_id(self, cr, uid, context):
134 """return the updater cron's id. Create one if the cron does not exists """133 """return the updater cron's id. Create one if the cron does not exists """
@@ -150,11 +149,7 @@
150 )149 )
151 cron_id = int(cron_id[0])150 cron_id = int(cron_id[0])
152 except Exception, e :151 except Exception, e :
153 self.logger.notifyChannel(152 self.logger.info('warning cron not found one will be created')
154 self.LOG_NAME,
155 netsvc.LOG_INFO,
156 'warning cron not found one will be created'
157 )
158 pass # ignore if the cron is missing cause we are going to create it in db153 pass # ignore if the cron is missing cause we are going to create it in db
159154
160 # the cron does not exists155 # the cron does not exists
@@ -189,13 +184,13 @@
189 # we fetch the main currency. The main rate should be set at 1.00184 # we fetch the main currency. The main rate should be set at 1.00
190 main_curr = comp.currency_id.name185 main_curr = comp.currency_id.name
191 for service in comp.services_to_use :186 for service in comp.services_to_use :
192 logger.debug("comp.services_to_use = %s" % (comp.services_to_use))187 self.logger.debug("comp.services_to_use = %s" % (comp.services_to_use))
193 note = service.note or ''188 note = service.note or ''
194 try :189 try :
195 # # we initalize the class that will handle the request190 # # we initalize the class that will handle the request
196 # # and return a dict of rate191 # # and return a dict of rate
197 getter = factory.register(service.service)192 getter = factory.register(service.service)
198 logger.debug("getter = %s" % (type(getter)))193 self.logger.debug("getter = %s" % (type(getter)))
199 curr_to_fetch = map(lambda x : x.name, service.currency_to_update)194 curr_to_fetch = map(lambda x : x.name, service.currency_to_update)
200 res, log_info = getter.get_updated_currency(curr_to_fetch, main_curr, service.max_delta_days)195 res, log_info = getter.get_updated_currency(curr_to_fetch, main_curr, service.max_delta_days)
201 rate_name = time.strftime('%Y-%m-%d')196 rate_name = time.strftime('%Y-%m-%d')
@@ -227,7 +222,7 @@
227 except Exception, e:222 except Exception, e:
228 error_msg = note + "\n%s ERROR : %s"\223 error_msg = note + "\n%s ERROR : %s"\
229 % (datetime.strftime(datetime.today(), '%Y-%m-%d %H:%M:%S'), str(e))224 % (datetime.strftime(datetime.today(), '%Y-%m-%d %H:%M:%S'), str(e))
230 self.logger.notifyChannel(self.LOG_NAME, netsvc.LOG_INFO, str(e))225 self.logger.info(str(e))
231 service.write({'note':error_msg})226 service.write({'note':error_msg})
232227
233228

Subscribers

People subscribed via source and target branches