Merge lp:~elbati/account-financial-tools/currency_rate_update_v7 into lp:~account-core-editors/account-financial-tools/7.0
- currency_rate_update_v7
- Merge into 7.0
Status: | Merged |
---|---|
Approved by: | Joël Grand-Guillaume @ camptocamp |
Approved revision: | 116 |
Merged at revision: | 111 |
Proposed branch: | lp:~elbati/account-financial-tools/currency_rate_update_v7 |
Merge into: | lp:~account-core-editors/account-financial-tools/7.0 |
Diff against target: |
362 lines (+49/-86) 8 files modified
currency_rate_update/__init__.py (+0/-1) currency_rate_update/__openerp__.py (+13/-11) currency_rate_update/company.py (+5/-3) currency_rate_update/company_view.xml (+5/-4) currency_rate_update/currency_rate_update.py (+25/-32) currency_rate_update/currency_rate_update.xml (+0/-4) currency_rate_update/security/security.xml (+1/-1) currency_rate_update/wizard/__init__.py (+0/-30) |
To merge this branch: | bzr merge lp:~elbati/account-financial-tools/currency_rate_update_v7 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alexandre Fayolle - camptocamp | code review, no test | Approve | |
Joël Grand-Guillaume @ camptocamp | code review, no test | Approve | |
Guewen Baconnier @ Camptocamp | Approve | ||
Review via email: mp+147945@code.launchpad.net |
Commit message
Description of the change
Small changes to make currency_
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote : | # |
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote : | # |
Please:
* use orm.Model instead of osv.osv in currency_
* remove unused wizard directory (and the corresponding import in currency_
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote : | # |
> Please:
>
> * use orm.Model instead of osv.osv in currency_
> * remove unused wizard directory (and the corresponding import in
> currency_
also:
* merge init_xml and update_xml in 'data' in __openerp__.py (you need to add a noupdate=1 in the security.xml file)
* rename demo_xml to demo in __openerp__.py
Thanks
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote : | # |
It seems like I need to improve my review ;) ! Thanks Alex
- 111. By Lorenzo Battistini
-
[FIX] use osv.Model
- 112. By Lorenzo Battistini
-
[DEL] remove unused wizard directory
- 113. By Lorenzo Battistini
-
[FIX] loading xml files
- 114. By Lorenzo Battistini
-
[FIX] parameter name
- 115. By Lorenzo Battistini
-
[IMP] copyright headers
Lorenzo Battistini (elbati) wrote : | # |
On 02/14/2013 01:22 PM, Alexandre Fayolle - camptocamp wrote:
>> Please:
>>
>> * use orm.Model instead of osv.osv in currency_
>> * remove unused wizard directory (and the corresponding import in
>> currency_
> also:
>
> * merge init_xml and update_xml in 'data' in __openerp__.py (you need to add a noupdate=1 in the security.xml file)
> * rename demo_xml to demo in __openerp__.py
Done
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
When `logging` is used, the variables should not be substituted in the string directly like this:
_logger.
But rather, given as arguments to the call as follows:
_logger.
Thus, they will be interpreted only if the logging is effective.
As nobody noticed that before, I won't mind if you don't change them. But would be nice...
Beside that, seems fine to me.
Thanks
- 116. By Lorenzo Battistini
-
[IMP] logging arguments
Lorenzo Battistini (elbati) wrote : | # |
2013/2/18 Guewen Baconnier @ Camptocamp <email address hidden>
>
> But rather, given as arguments to the call as follows:
>
> _logger.
> rate_date_str)
>
> Thus, they will be interpreted only if the logging is effective.
>
>
Done
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote : | # |
Hi,
Thanks for the contribs !
Regards,
Joël
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote : | # |
LGTM. I'm about to merge.
Preview Diff
1 | === modified file 'currency_rate_update/__init__.py' | |||
2 | --- currency_rate_update/__init__.py 2011-08-12 12:35:23 +0000 | |||
3 | +++ currency_rate_update/__init__.py 2013-02-21 18:08:22 +0000 | |||
4 | @@ -30,4 +30,3 @@ | |||
5 | 30 | 30 | ||
6 | 31 | import currency_rate_update | 31 | import currency_rate_update |
7 | 32 | import company | 32 | import company |
8 | 33 | import wizard | ||
9 | 34 | 33 | ||
10 | === modified file 'currency_rate_update/__openerp__.py' | |||
11 | --- currency_rate_update/__openerp__.py 2013-01-04 10:31:20 +0000 | |||
12 | +++ currency_rate_update/__openerp__.py 2013-02-21 18:08:22 +0000 | |||
13 | @@ -3,7 +3,7 @@ | |||
14 | 3 | # Copyright (c) 2008 Camtocamp SA | 3 | # Copyright (c) 2008 Camtocamp SA |
15 | 4 | # @author JB Aubort, Nicolas Bessi, Joel Grand-Guillaume | 4 | # @author JB Aubort, Nicolas Bessi, Joel Grand-Guillaume |
16 | 5 | # European Central Bank and Polish National Bank invented by Grzegorz Grzelak | 5 | # European Central Bank and Polish National Bank invented by Grzegorz Grzelak |
18 | 6 | # $Id: $ | 6 | # Ported to OpenERP 7.0 by Lorenzo Battistini <lorenzo.battistini@agilebg.com> |
19 | 7 | # | 7 | # |
20 | 8 | # WARNING: This program as such is intended to be used by professional | 8 | # WARNING: This program as such is intended to be used by professional |
21 | 9 | # programmers who take the whole responsability of assessing all potential | 9 | # programmers who take the whole responsability of assessing all potential |
22 | @@ -29,7 +29,7 @@ | |||
23 | 29 | ############################################################################## | 29 | ############################################################################## |
24 | 30 | { | 30 | { |
25 | 31 | "name" : "Currency Rate Update", | 31 | "name" : "Currency Rate Update", |
27 | 32 | "version" : "0.6", | 32 | "version" : "0.7", |
28 | 33 | "author" : "Camptocamp", | 33 | "author" : "Camptocamp", |
29 | 34 | "website" : "http://camptocamp.com", | 34 | "website" : "http://camptocamp.com", |
30 | 35 | "category" : "Financial Management/Configuration", | 35 | "category" : "Financial Management/Configuration", |
31 | @@ -79,14 +79,16 @@ | |||
32 | 79 | 79 | ||
33 | 80 | Thanks to main contributors: Grzegorz Grzelak, Alexis de Lattre | 80 | Thanks to main contributors: Grzegorz Grzelak, Alexis de Lattre |
34 | 81 | """, | 81 | """, |
43 | 82 | "depends" : ["base", | 82 | "depends" : [ |
44 | 83 | "account"], #Added to ensure account security groups are present | 83 | "base", |
45 | 84 | "init_xml" : ["security/security.xml"], | 84 | "account", #Added to ensure account security groups are present |
46 | 85 | "update_xml" : [ | 85 | ], |
47 | 86 | "currency_rate_update.xml", | 86 | "data" : [ |
48 | 87 | "company_view.xml", | 87 | "currency_rate_update.xml", |
49 | 88 | ], | 88 | "company_view.xml", |
50 | 89 | "demo_xml" : [], | 89 | "security/security.xml", |
51 | 90 | ], | ||
52 | 91 | "demo" : [], | ||
53 | 90 | "active": False, | 92 | "active": False, |
55 | 91 | 'installable': False | 93 | 'installable': True |
56 | 92 | } | 94 | } |
57 | 93 | 95 | ||
58 | === modified file 'currency_rate_update/company.py' | |||
59 | --- currency_rate_update/company.py 2013-01-04 10:51:23 +0000 | |||
60 | +++ currency_rate_update/company.py 2013-02-21 18:08:22 +0000 | |||
61 | @@ -29,8 +29,9 @@ | |||
62 | 29 | ############################################################################## | 29 | ############################################################################## |
63 | 30 | 30 | ||
64 | 31 | import netsvc | 31 | import netsvc |
67 | 32 | from osv import fields, osv | 32 | from openerp.osv import fields, osv |
68 | 33 | class res_company(osv.osv): | 33 | |
69 | 34 | class res_company(osv.Model): | ||
70 | 34 | """override company to add currency update""" | 35 | """override company to add currency update""" |
71 | 35 | 36 | ||
72 | 36 | def _multi_curr_enable(self, cr, uid, ids, field_name, arg, context={}): | 37 | def _multi_curr_enable(self, cr, uid, ids, field_name, arg, context={}): |
73 | @@ -161,4 +162,5 @@ | |||
74 | 161 | ' not set currency is active on two company' | 162 | ' not set currency is active on two company' |
75 | 162 | ), | 163 | ), |
76 | 163 | } | 164 | } |
78 | 164 | res_company() | 165 | |
79 | 166 | |||
80 | 165 | 167 | ||
81 | === modified file 'currency_rate_update/company_view.xml' | |||
82 | --- currency_rate_update/company_view.xml 2012-02-03 13:53:02 +0000 | |||
83 | +++ currency_rate_update/company_view.xml 2013-02-21 18:08:22 +0000 | |||
84 | @@ -4,13 +4,14 @@ | |||
85 | 4 | <field name="name">res.company.form.inherit</field> | 4 | <field name="name">res.company.form.inherit</field> |
86 | 5 | <field name="model">res.company</field> | 5 | <field name="model">res.company</field> |
87 | 6 | <field name="inherit_id" ref="base.view_company_form"/> | 6 | <field name="inherit_id" ref="base.view_company_form"/> |
88 | 7 | <field name="type">form</field> | ||
89 | 8 | <field name="arch" type="xml"> | 7 | <field name="arch" type="xml"> |
90 | 9 | <notebook position="inside"> | 8 | <notebook position="inside"> |
91 | 10 | <page string="Currency auto update configuration"> | 9 | <page string="Currency auto update configuration"> |
95 | 11 | <field name="auto_currency_up" on_change="on_change_auto_currency_up(auto_currency_up)"/> | 10 | <group> |
96 | 12 | <field name="interval_type" on_change="on_change_intervall(interval_type)"/> | 11 | <field name="auto_currency_up" on_change="on_change_auto_currency_up(auto_currency_up)"/> |
97 | 13 | <field name="multi_company_currency_enable"/> | 12 | <field name="interval_type" on_change="on_change_intervall(interval_type)"/> |
98 | 13 | <field name="multi_company_currency_enable"/> | ||
99 | 14 | </group> | ||
100 | 14 | <separator string="Currency updates services" colspan="4"/> | 15 | <separator string="Currency updates services" colspan="4"/> |
101 | 15 | <field name="services_to_use" colspan="4" nolabel="1"/> | 16 | <field name="services_to_use" colspan="4" nolabel="1"/> |
102 | 16 | <button name="button_refresh_currency" string="Refresh currencies" type='object' /> | 17 | <button name="button_refresh_currency" string="Refresh currencies" type='object' /> |
103 | 17 | 18 | ||
104 | === modified file 'currency_rate_update/currency_rate_update.py' | |||
105 | --- currency_rate_update/currency_rate_update.py 2012-04-23 12:19:50 +0000 | |||
106 | +++ currency_rate_update/currency_rate_update.py 2013-02-21 18:08:22 +0000 | |||
107 | @@ -14,6 +14,7 @@ | |||
108 | 14 | # For more details, see Launchpad bug #645263 | 14 | # For more details, see Launchpad bug #645263 |
109 | 15 | # - mecanism to check if rates given by the webservice are "fresh" enough to be | 15 | # - mecanism to check if rates given by the webservice are "fresh" enough to be |
110 | 16 | # written in OpenERP ('max_delta_days' parameter for each currency update service) | 16 | # written in OpenERP ('max_delta_days' parameter for each currency update service) |
111 | 17 | # Ported to OpenERP 7.0 by Lorenzo Battistini <lorenzo.battistini@agilebg.com> | ||
112 | 17 | # | 18 | # |
113 | 18 | # WARNING: This program as such is intended to be used by professional | 19 | # WARNING: This program as such is intended to be used by professional |
114 | 19 | # programmers who take the whole responsability of assessing all potential | 20 | # programmers who take the whole responsability of assessing all potential |
115 | @@ -42,13 +43,15 @@ | |||
116 | 42 | # a webservice to the list of currencies supported by the Webservice | 43 | # a webservice to the list of currencies supported by the Webservice |
117 | 43 | # TODO : implement max_delta_days for Yahoo webservice | 44 | # TODO : implement max_delta_days for Yahoo webservice |
118 | 44 | 45 | ||
120 | 45 | from osv import osv, fields | 46 | from openerp.osv import fields, osv |
121 | 46 | import time | 47 | import time |
122 | 47 | from datetime import datetime, timedelta | 48 | from datetime import datetime, timedelta |
127 | 48 | import netsvc | 49 | import logging |
128 | 49 | from tools.translate import _ | 50 | from openerp.tools.translate import _ |
129 | 50 | 51 | ||
130 | 51 | class Currency_rate_update_service(osv.osv): | 52 | _logger = logging.getLogger(__name__) |
131 | 53 | |||
132 | 54 | class Currency_rate_update_service(osv.Model): | ||
133 | 52 | """Class thats tell for wich services wich currencies | 55 | """Class thats tell for wich services wich currencies |
134 | 53 | have to be updated""" | 56 | have to be updated""" |
135 | 54 | _name = "currency.rate.update.service" | 57 | _name = "currency.rate.update.service" |
136 | @@ -107,9 +110,8 @@ | |||
137 | 107 | (_check_max_delta_days, "'Max delta days' must be >= 0", ['max_delta_days']), | 110 | (_check_max_delta_days, "'Max delta days' must be >= 0", ['max_delta_days']), |
138 | 108 | ] | 111 | ] |
139 | 109 | 112 | ||
140 | 110 | Currency_rate_update_service() | ||
141 | 111 | 113 | ||
143 | 112 | class Currency_rate_update(osv.osv): | 114 | class Currency_rate_update(osv.Model): |
144 | 113 | """Class that handle an ir cron call who will | 115 | """Class that handle an ir cron call who will |
145 | 114 | update currencies based on a web url""" | 116 | update currencies based on a web url""" |
146 | 115 | _name = "currency.rate.update" | 117 | _name = "currency.rate.update" |
147 | @@ -128,7 +130,6 @@ | |||
148 | 128 | 'args' : '()', | 130 | 'args' : '()', |
149 | 129 | } | 131 | } |
150 | 130 | 132 | ||
151 | 131 | logger = netsvc.Logger() | ||
152 | 132 | LOG_NAME = 'cron-rates' | 133 | LOG_NAME = 'cron-rates' |
153 | 133 | MOD_NAME = 'c2c_currency_rate_update: ' | 134 | MOD_NAME = 'c2c_currency_rate_update: ' |
154 | 134 | def get_cron_id(self, cr, uid, context): | 135 | def get_cron_id(self, cr, uid, context): |
155 | @@ -151,11 +152,7 @@ | |||
156 | 151 | ) | 152 | ) |
157 | 152 | cron_id = int(cron_id[0]) | 153 | cron_id = int(cron_id[0]) |
158 | 153 | except Exception,e : | 154 | except Exception,e : |
164 | 154 | self.logger.notifyChannel( | 155 | _logger.info('warning cron not found one will be created') |
160 | 155 | self.LOG_NAME, | ||
161 | 156 | netsvc.LOG_INFO, | ||
162 | 157 | 'warning cron not found one will be created' | ||
163 | 158 | ) | ||
165 | 159 | pass # ignore if the cron is missing cause we are going to create it in db | 156 | pass # ignore if the cron is missing cause we are going to create it in db |
166 | 160 | 157 | ||
167 | 161 | #the cron does not exists | 158 | #the cron does not exists |
168 | @@ -228,11 +225,10 @@ | |||
169 | 228 | except Exception, e: | 225 | except Exception, e: |
170 | 229 | error_msg = note + "\n%s ERROR : %s"\ | 226 | error_msg = note + "\n%s ERROR : %s"\ |
171 | 230 | %(datetime.strftime(datetime.today(), '%Y-%m-%d %H:%M:%S'), str(e)) | 227 | %(datetime.strftime(datetime.today(), '%Y-%m-%d %H:%M:%S'), str(e)) |
173 | 231 | self.logger.notifyChannel(self.LOG_NAME, netsvc.LOG_INFO, str(e)) | 228 | _logger.info(str(e)) |
174 | 232 | service.write({'note':error_msg}) | 229 | service.write({'note':error_msg}) |
175 | 233 | 230 | ||
178 | 234 | 231 | ||
177 | 235 | Currency_rate_update() | ||
179 | 236 | 232 | ||
180 | 237 | ### Error Definition as specified in python 2.6 PEP | 233 | ### Error Definition as specified in python 2.6 PEP |
181 | 238 | class AbstractClassError(Exception): | 234 | class AbstractClassError(Exception): |
182 | @@ -355,7 +351,7 @@ | |||
183 | 355 | rate_date_str = datetime.strftime(rate_date, '%Y-%m-%d') | 351 | rate_date_str = datetime.strftime(rate_date, '%Y-%m-%d') |
184 | 356 | if rate_date_str != datetime.strftime(datetime.today(), '%Y-%m-%d'): | 352 | if rate_date_str != datetime.strftime(datetime.today(), '%Y-%m-%d'): |
185 | 357 | self.log_info = "WARNING : the rate date from ECB (%s) is not today's date" % rate_date_str | 353 | self.log_info = "WARNING : the rate date from ECB (%s) is not today's date" % rate_date_str |
187 | 358 | netsvc.Logger().notifyChannel("rate_update", netsvc.LOG_WARNING, "the rate date from ECB (%s) is not today's date" % rate_date_str) | 354 | _logger.warning("the rate date from ECB (%s) is not today's date", rate_date_str) |
188 | 359 | 355 | ||
189 | 360 | 356 | ||
190 | 361 | #Yahoo ################################################################################### | 357 | #Yahoo ################################################################################### |
191 | @@ -402,11 +398,10 @@ | |||
192 | 402 | currency_array.remove(main_currency) | 398 | currency_array.remove(main_currency) |
193 | 403 | # Move to new XML lib cf Launchpad bug #645263 | 399 | # Move to new XML lib cf Launchpad bug #645263 |
194 | 404 | from lxml import etree | 400 | from lxml import etree |
197 | 405 | logger = netsvc.Logger() | 401 | _logger.debug("Admin.ch currency rate service : connecting...") |
196 | 406 | logger.notifyChannel("rate_update", netsvc.LOG_DEBUG, "Admin.ch currency rate service : connecting...") | ||
198 | 407 | rawfile = self.get_url(url) | 402 | rawfile = self.get_url(url) |
199 | 408 | dom = etree.fromstring(rawfile) | 403 | dom = etree.fromstring(rawfile) |
201 | 409 | logger.notifyChannel("rate_update", netsvc.LOG_DEBUG, "Admin.ch sent a valid XML file") | 404 | _logger.debug("Admin.ch sent a valid XML file") |
202 | 410 | adminch_ns = {'def': 'http://www.afd.admin.ch/publicdb/newdb/mwst_kurse'} | 405 | adminch_ns = {'def': 'http://www.afd.admin.ch/publicdb/newdb/mwst_kurse'} |
203 | 411 | rate_date = dom.xpath('/def:wechselkurse/def:datum/text()', namespaces=adminch_ns)[0] | 406 | rate_date = dom.xpath('/def:wechselkurse/def:datum/text()', namespaces=adminch_ns)[0] |
204 | 412 | rate_date_datetime = datetime.strptime(rate_date, '%Y-%m-%d') | 407 | rate_date_datetime = datetime.strptime(rate_date, '%Y-%m-%d') |
205 | @@ -416,7 +411,7 @@ | |||
206 | 416 | self.supported_currency_array = [x.upper() for x in self.supported_currency_array] | 411 | self.supported_currency_array = [x.upper() for x in self.supported_currency_array] |
207 | 417 | self.supported_currency_array.append('CHF') | 412 | self.supported_currency_array.append('CHF') |
208 | 418 | 413 | ||
210 | 419 | logger.notifyChannel("rate_update", netsvc.LOG_DEBUG, "Supported currencies = " + str(self.supported_currency_array)) | 414 | _logger.debug("Supported currencies = " + str(self.supported_currency_array)) |
211 | 420 | self.validate_cur(main_currency) | 415 | self.validate_cur(main_currency) |
212 | 421 | if main_currency != 'CHF': | 416 | if main_currency != 'CHF': |
213 | 422 | main_curr_data = self.rate_retrieve(dom, adminch_ns, main_currency) | 417 | main_curr_data = self.rate_retrieve(dom, adminch_ns, main_currency) |
214 | @@ -434,7 +429,7 @@ | |||
215 | 434 | else : | 429 | else : |
216 | 435 | rate = main_rate * curr_data['rate_ref'] / curr_data['rate_currency'] | 430 | rate = main_rate * curr_data['rate_ref'] / curr_data['rate_currency'] |
217 | 436 | self.updated_currency[curr] = rate | 431 | self.updated_currency[curr] = rate |
219 | 437 | logger.notifyChannel("rate_update", netsvc.LOG_DEBUG, "Rate retrieved : 1 " + main_currency + ' = ' + str(rate) + ' ' + curr) | 432 | _logger.debug("Rate retrieved : 1 " + main_currency + ' = ' + str(rate) + ' ' + curr) |
220 | 438 | return self.updated_currency, self.log_info | 433 | return self.updated_currency, self.log_info |
221 | 439 | 434 | ||
222 | 440 | ## ECB getter ############################################################################ | 435 | ## ECB getter ############################################################################ |
223 | @@ -464,11 +459,10 @@ | |||
224 | 464 | currency_array.remove(main_currency) | 459 | currency_array.remove(main_currency) |
225 | 465 | # Move to new XML lib cf Launchpad bug #645263 | 460 | # Move to new XML lib cf Launchpad bug #645263 |
226 | 466 | from lxml import etree | 461 | from lxml import etree |
229 | 467 | logger = netsvc.Logger() | 462 | _logger.debug("ECB currency rate service : connecting...") |
228 | 468 | logger.notifyChannel("rate_update", netsvc.LOG_DEBUG, "ECB currency rate service : connecting...") | ||
230 | 469 | rawfile = self.get_url(url) | 463 | rawfile = self.get_url(url) |
231 | 470 | dom = etree.fromstring(rawfile) | 464 | dom = etree.fromstring(rawfile) |
233 | 471 | logger.notifyChannel("rate_update", netsvc.LOG_DEBUG, "ECB sent a valid XML file") | 465 | _logger.debug("ECB sent a valid XML file") |
234 | 472 | ecb_ns = {'gesmes': 'http://www.gesmes.org/xml/2002-08-01', 'def': 'http://www.ecb.int/vocabulary/2002-08-01/eurofxref'} | 466 | ecb_ns = {'gesmes': 'http://www.gesmes.org/xml/2002-08-01', 'def': 'http://www.ecb.int/vocabulary/2002-08-01/eurofxref'} |
235 | 473 | rate_date = dom.xpath('/gesmes:Envelope/def:Cube/def:Cube/@time', namespaces=ecb_ns)[0] | 467 | rate_date = dom.xpath('/gesmes:Envelope/def:Cube/def:Cube/@time', namespaces=ecb_ns)[0] |
236 | 474 | rate_date_datetime = datetime.strptime(rate_date, '%Y-%m-%d') | 468 | rate_date_datetime = datetime.strptime(rate_date, '%Y-%m-%d') |
237 | @@ -476,7 +470,7 @@ | |||
238 | 476 | #we dynamically update supported currencies | 470 | #we dynamically update supported currencies |
239 | 477 | self.supported_currency_array = dom.xpath("/gesmes:Envelope/def:Cube/def:Cube/def:Cube/@currency", namespaces=ecb_ns) | 471 | self.supported_currency_array = dom.xpath("/gesmes:Envelope/def:Cube/def:Cube/def:Cube/@currency", namespaces=ecb_ns) |
240 | 478 | self.supported_currency_array.append('EUR') | 472 | self.supported_currency_array.append('EUR') |
242 | 479 | logger.notifyChannel("rate_update", netsvc.LOG_DEBUG, "Supported currencies = " + str(self.supported_currency_array)) | 473 | _logger.debug("Supported currencies = " + str(self.supported_currency_array)) |
243 | 480 | self.validate_cur(main_currency) | 474 | self.validate_cur(main_currency) |
244 | 481 | if main_currency != 'EUR': | 475 | if main_currency != 'EUR': |
245 | 482 | main_curr_data = self.rate_retrieve(dom, ecb_ns, main_currency) | 476 | main_curr_data = self.rate_retrieve(dom, ecb_ns, main_currency) |
246 | @@ -491,7 +485,7 @@ | |||
247 | 491 | else: | 485 | else: |
248 | 492 | rate = curr_data['rate_currency'] / main_curr_data['rate_currency'] | 486 | rate = curr_data['rate_currency'] / main_curr_data['rate_currency'] |
249 | 493 | self.updated_currency[curr] = rate | 487 | self.updated_currency[curr] = rate |
251 | 494 | logger.notifyChannel("rate_update", netsvc.LOG_DEBUG, "Rate retrieved : 1 " + main_currency + ' = ' + str(rate) + ' ' + curr) | 488 | _logger.debug("Rate retrieved : 1 " + main_currency + ' = ' + str(rate) + ' ' + curr) |
252 | 495 | return self.updated_currency, self.log_info | 489 | return self.updated_currency, self.log_info |
253 | 496 | 490 | ||
254 | 497 | ##PL NBP ############################################################################ | 491 | ##PL NBP ############################################################################ |
255 | @@ -517,12 +511,11 @@ | |||
256 | 517 | currency_array.remove(main_currency) | 511 | currency_array.remove(main_currency) |
257 | 518 | # Move to new XML lib cf Launchpad bug #645263 | 512 | # Move to new XML lib cf Launchpad bug #645263 |
258 | 519 | from lxml import etree | 513 | from lxml import etree |
261 | 520 | logger = netsvc.Logger() | 514 | _logger.debug("NBP.pl currency rate service : connecting...") |
260 | 521 | logger.notifyChannel("rate_update", netsvc.LOG_DEBUG, "NBP.pl currency rate service : connecting...") | ||
262 | 522 | rawfile = self.get_url(url) | 515 | rawfile = self.get_url(url) |
263 | 523 | dom = etree.fromstring(rawfile) # If rawfile is not XML, it crashes here | 516 | dom = etree.fromstring(rawfile) # If rawfile is not XML, it crashes here |
264 | 524 | ns = {} # Cool, there are no namespaces ! | 517 | ns = {} # Cool, there are no namespaces ! |
266 | 525 | logger.notifyChannel("rate_update", netsvc.LOG_DEBUG, "NBP.pl sent a valid XML file") | 518 | _logger.debug("NBP.pl sent a valid XML file") |
267 | 526 | #node = xpath.Evaluate("/tabela_kursow", dom) # BEGIN Polish - rates table name | 519 | #node = xpath.Evaluate("/tabela_kursow", dom) # BEGIN Polish - rates table name |
268 | 527 | #if isinstance(node, list) : | 520 | #if isinstance(node, list) : |
269 | 528 | # node = node[0] | 521 | # node = node[0] |
270 | @@ -535,7 +528,7 @@ | |||
271 | 535 | #we dynamically update supported currencies | 528 | #we dynamically update supported currencies |
272 | 536 | self.supported_currency_array = dom.xpath('/tabela_kursow/pozycja/kod_waluty/text()', namespaces=ns) | 529 | self.supported_currency_array = dom.xpath('/tabela_kursow/pozycja/kod_waluty/text()', namespaces=ns) |
273 | 537 | self.supported_currency_array.append('PLN') | 530 | self.supported_currency_array.append('PLN') |
275 | 538 | logger.notifyChannel("rate_update", netsvc.LOG_DEBUG, "Supported currencies = " + str(self.supported_currency_array)) | 531 | _logger.debug("Supported currencies = " + str(self.supported_currency_array)) |
276 | 539 | self.validate_cur(main_currency) | 532 | self.validate_cur(main_currency) |
277 | 540 | if main_currency != 'PLN': | 533 | if main_currency != 'PLN': |
278 | 541 | main_curr_data = self.rate_retrieve(dom, ns, main_currency) | 534 | main_curr_data = self.rate_retrieve(dom, ns, main_currency) |
279 | @@ -553,5 +546,5 @@ | |||
280 | 553 | else: | 546 | else: |
281 | 554 | rate = main_rate * curr_data['rate_ref'] / curr_data['rate_currency'] | 547 | rate = main_rate * curr_data['rate_ref'] / curr_data['rate_currency'] |
282 | 555 | self.updated_currency[curr] = rate | 548 | self.updated_currency[curr] = rate |
284 | 556 | logger.notifyChannel("rate_update", netsvc.LOG_DEBUG, "Rate retrieved : 1 " + main_currency + ' = ' + str(rate) + ' ' + curr) | 549 | _logger.debug("Rate retrieved : 1 " + main_currency + ' = ' + str(rate) + ' ' + curr) |
285 | 557 | return self.updated_currency, self.log_info | 550 | return self.updated_currency, self.log_info |
286 | 558 | 551 | ||
287 | === modified file 'currency_rate_update/currency_rate_update.xml' | |||
288 | --- currency_rate_update/currency_rate_update.xml 2011-08-12 12:35:23 +0000 | |||
289 | +++ currency_rate_update/currency_rate_update.xml 2013-02-21 18:08:22 +0000 | |||
290 | @@ -4,12 +4,10 @@ | |||
291 | 4 | <record model="ir.ui.view" id="currency_rate_update_tree"> | 4 | <record model="ir.ui.view" id="currency_rate_update_tree"> |
292 | 5 | <field name="name">Update Rates service</field> | 5 | <field name="name">Update Rates service</field> |
293 | 6 | <field name="model">currency.rate.update.service</field> | 6 | <field name="model">currency.rate.update.service</field> |
294 | 7 | <field name="type">tree</field> | ||
295 | 8 | <field name="arch" type="xml"> | 7 | <field name="arch" type="xml"> |
296 | 9 | <tree string="Rates"> | 8 | <tree string="Rates"> |
297 | 10 | <field name="service"/> | 9 | <field name="service"/> |
298 | 11 | <field name="currency_to_update"/> | 10 | <field name="currency_to_update"/> |
299 | 12 | <field name="company_id"/> | ||
300 | 13 | 11 | ||
301 | 14 | </tree> | 12 | </tree> |
302 | 15 | </field> | 13 | </field> |
303 | @@ -18,11 +16,9 @@ | |||
304 | 18 | <record model="ir.ui.view" id="currency_rate_update_form"> | 16 | <record model="ir.ui.view" id="currency_rate_update_form"> |
305 | 19 | <field name="name">Update Rates</field> | 17 | <field name="name">Update Rates</field> |
306 | 20 | <field name="model">currency.rate.update.service</field> | 18 | <field name="model">currency.rate.update.service</field> |
307 | 21 | <field name="type">form</field> | ||
308 | 22 | <field name="arch" type="xml"> | 19 | <field name="arch" type="xml"> |
309 | 23 | <form string="Rate"> | 20 | <form string="Rate"> |
310 | 24 | <field name="service"/> | 21 | <field name="service"/> |
311 | 25 | <field name="company_id"/> | ||
312 | 26 | <field name="max_delta_days"/> | 22 | <field name="max_delta_days"/> |
313 | 27 | <separator string="Currencies to update with this service" colspan="4"/> | 23 | <separator string="Currencies to update with this service" colspan="4"/> |
314 | 28 | <field name="currency_to_update" colspan="4" nolabel="1"/> | 24 | <field name="currency_to_update" colspan="4" nolabel="1"/> |
315 | 29 | 25 | ||
316 | === modified file 'currency_rate_update/security/security.xml' | |||
317 | --- currency_rate_update/security/security.xml 2011-09-01 13:58:58 +0000 | |||
318 | +++ currency_rate_update/security/security.xml 2013-02-21 18:08:22 +0000 | |||
319 | @@ -1,6 +1,6 @@ | |||
320 | 1 | <?xml version="1.0" ?> | 1 | <?xml version="1.0" ?> |
321 | 2 | <openerp> | 2 | <openerp> |
323 | 3 | <data> | 3 | <data noupdate="1"> |
324 | 4 | <record id="ir_model_access_currencyrateupdate0" model="ir.model.access"> | 4 | <record id="ir_model_access_currencyrateupdate0" model="ir.model.access"> |
325 | 5 | <field name="model_id" ref="currency_rate_update.model_currency_rate_update"/> | 5 | <field name="model_id" ref="currency_rate_update.model_currency_rate_update"/> |
326 | 6 | <field eval="1" name="perm_read"/> | 6 | <field eval="1" name="perm_read"/> |
327 | 7 | 7 | ||
328 | === removed directory 'currency_rate_update/wizard' | |||
329 | === removed file 'currency_rate_update/wizard/__init__.py' | |||
330 | --- currency_rate_update/wizard/__init__.py 2011-08-12 12:35:23 +0000 | |||
331 | +++ currency_rate_update/wizard/__init__.py 1970-01-01 00:00:00 +0000 | |||
332 | @@ -1,30 +0,0 @@ | |||
333 | 1 | # -*- coding: utf-8 -*- | ||
334 | 2 | ############################################################################## | ||
335 | 3 | # | ||
336 | 4 | # Copyright (c) 2008 Camtocamp SA | ||
337 | 5 | # @author JB Aubort | ||
338 | 6 | # $Id$ | ||
339 | 7 | # | ||
340 | 8 | # WARNING: This program as such is intended to be used by professional | ||
341 | 9 | # programmers who take the whole responsability of assessing all potential | ||
342 | 10 | # consequences resulting from its eventual inadequacies and bugs | ||
343 | 11 | # End users who are looking for a ready-to-use solution with commercial | ||
344 | 12 | # garantees and support are strongly adviced to contract a Free Software | ||
345 | 13 | # Service Company | ||
346 | 14 | # | ||
347 | 15 | # This program is Free Software; you can redistribute it and/or | ||
348 | 16 | # modify it under the terms of the GNU General Public License | ||
349 | 17 | # as published by the Free Software Foundation; either version 2 | ||
350 | 18 | # of the License, or (at your option) any later version. | ||
351 | 19 | # | ||
352 | 20 | # This program is distributed in the hope that it will be useful, | ||
353 | 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
354 | 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
355 | 23 | # GNU General Public License for more details. | ||
356 | 24 | # | ||
357 | 25 | # You should have received a copy of the GNU General Public License | ||
358 | 26 | # along with this program; if not, write to the Free Software | ||
359 | 27 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
360 | 28 | # | ||
361 | 29 | ############################################################################## | ||
362 | 30 |
Hi Lorenzo,
Thanks for this MP ! It looks good to me.
Regards,
Joël