From fab1eccb64c418206c9b167d113ccdce497d9704 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 29 May 2015 00:19:30 +0200 Subject: [PATCH 1/4] Add record rule for currency.rate.update.service Workaround for bug #151 Add dedicated menu entry for currency.rate.update.service in Accounting > Config > Misc Fix English mistake Clean-up form view structure of currency.rate.update.service --- currency_rate_update/__openerp__.py | 1 + .../i18n/currency_rate_update.pot | 4 +-- currency_rate_update/model/company.py | 2 +- .../model/currency_rate_update.py | 2 +- currency_rate_update/security/rule.xml | 13 ++++++++ .../view/currency_rate_update.xml | 33 ++++++++++++++----- 6 files changed, 43 insertions(+), 12 deletions(-) create mode 100644 currency_rate_update/security/rule.xml diff --git a/currency_rate_update/__openerp__.py b/currency_rate_update/__openerp__.py index 6a16088c1..a4808596b 100644 --- a/currency_rate_update/__openerp__.py +++ b/currency_rate_update/__openerp__.py @@ -33,6 +33,7 @@ "view/service_cron_data.xml", "view/currency_rate_update.xml", "view/company_view.xml", + "security/rule.xml", "security/ir.model.access.csv", ], "demo": [], diff --git a/currency_rate_update/i18n/currency_rate_update.pot b/currency_rate_update/i18n/currency_rate_update.pot index 78874a702..426acdbb6 100755 --- a/currency_rate_update/i18n/currency_rate_update.pot +++ b/currency_rate_update/i18n/currency_rate_update.pot @@ -27,7 +27,7 @@ msgstr "" #. module: currency_rate_update #: help:res.company,auto_currency_up:0 -msgid "Automatical update of the currencies for this company" +msgid "Automatic update of the currencies for this company" msgstr "" #. module: currency_rate_update @@ -157,7 +157,7 @@ msgstr "" #. module: currency_rate_update #: field:currency.rate.update.service,company_id:0 -msgid "Linked Company" +msgid "Company" msgstr "" #. module: currency_rate_update diff --git a/currency_rate_update/model/company.py b/currency_rate_update/model/company.py index 23ee79467..a71d27987 100644 --- a/currency_rate_update/model/company.py +++ b/currency_rate_update/model/company.py @@ -44,7 +44,7 @@ class res_company(models.Model): # Activate the currency update auto_currency_up = fields.Boolean( string='Automatic Update', - help="Automatical update of the currencies for this company") + help="Automatic update of the currencies for this company") # Function field that allows to know the # multi company currency implementation multi_company_currency_enable = fields.Boolean( diff --git a/currency_rate_update/model/currency_rate_update.py b/currency_rate_update/model/currency_rate_update.py index 8cfe926a7..d877a09b6 100644 --- a/currency_rate_update/model/currency_rate_update.py +++ b/currency_rate_update/model/currency_rate_update.py @@ -212,7 +212,7 @@ class Currency_rate_update_service(models.Model): string='Currencies to update with ' 'this service') # Link with company - company_id = fields.Many2one('res.company', 'Linked Company') + company_id = fields.Many2one('res.company', 'Company') # Note fileds that will be used as a logger note = fields.Text('Update logs') max_delta_days = fields.Integer( diff --git a/currency_rate_update/security/rule.xml b/currency_rate_update/security/rule.xml new file mode 100644 index 000000000..835618857 --- /dev/null +++ b/currency_rate_update/security/rule.xml @@ -0,0 +1,13 @@ + + + + + + Current Rate Update Service multi-company + + + ['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])] + + + + diff --git a/currency_rate_update/view/currency_rate_update.xml b/currency_rate_update/view/currency_rate_update.xml index 166f9325d..e7c5fa62c 100644 --- a/currency_rate_update/view/currency_rate_update.xml +++ b/currency_rate_update/view/currency_rate_update.xml @@ -7,6 +7,8 @@ + @@ -20,25 +22,40 @@ currency.rate.update.service
- - + + + - + - - - - - + + + + + + + + + Currency Rate Update + currency.rate.update.service + tree,form + {'currency_rate_update_main_view': True} + + + + From 9dbbbacf1ab37d60dbef3a81c9a52735d4f98e98 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 29 May 2015 00:27:50 +0200 Subject: [PATCH 2/4] Fix crash "TypeError: _run_currency_update() takes exactly 1 argument (2 given)" --- currency_rate_update/view/service_cron_data.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/currency_rate_update/view/service_cron_data.xml b/currency_rate_update/view/service_cron_data.xml index cfc640849..8577dc632 100644 --- a/currency_rate_update/view/service_cron_data.xml +++ b/currency_rate_update/view/service_cron_data.xml @@ -9,7 +9,7 @@ - (None,) + () From a3d1fa6c985ad5cb0c6b9ed0ed4db1e6dfb41499 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 29 May 2015 00:50:33 +0200 Subject: [PATCH 3/4] Add info log and convert an existing info log to error log --- currency_rate_update/model/currency_rate_update.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/currency_rate_update/model/currency_rate_update.py b/currency_rate_update/model/currency_rate_update.py index d877a09b6..09d911f37 100644 --- a/currency_rate_update/model/currency_rate_update.py +++ b/currency_rate_update/model/currency_rate_update.py @@ -237,6 +237,9 @@ class Currency_rate_update_service(models.Model): @api.one def refresh_currency(self): """Refresh the currencies rates !!for all companies now""" + _logger.info( + 'Starting to refresh currencies with service %s (company: %s)', + self.service, self.company_id.name) factory = Currency_getter_factory() curr_obj = self.env['res.currency'] rate_obj = self.env['res.currency.rate'] @@ -289,6 +292,9 @@ class Currency_rate_update_service(models.Model): 'name': rate_name } rate_obj.create(vals) + _logger.info( + 'Updated currency %s via service %s', + curr.name, self.service.name) # Show the most recent note at the top msg = '%s \n%s currency updated. %s' % ( @@ -303,7 +309,7 @@ class Currency_rate_update_service(models.Model): repr(exc), note ) - _logger.info(repr(exc)) + _logger.error(repr(exc)) self.write({'note': error_msg}) if self._context.get('cron', False): midnight = time(0, 0) @@ -322,4 +328,6 @@ class Currency_rate_update_service(models.Model): @api.model def _run_currency_update(self): + _logger.info('Starting the currency rate update cron') self.run_currency_update() + _logger.info('End of the currency rate update cron') From 1928eae801b9797bfdcb1ba8e117642a3b9e5ba4 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 29 May 2015 14:27:07 +0200 Subject: [PATCH 4/4] Fix log message --- currency_rate_update/model/currency_rate_update.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/currency_rate_update/model/currency_rate_update.py b/currency_rate_update/model/currency_rate_update.py index 09d911f37..9eb75f87d 100644 --- a/currency_rate_update/model/currency_rate_update.py +++ b/currency_rate_update/model/currency_rate_update.py @@ -294,7 +294,7 @@ class Currency_rate_update_service(models.Model): rate_obj.create(vals) _logger.info( 'Updated currency %s via service %s', - curr.name, self.service.name) + curr.name, self.service) # Show the most recent note at the top msg = '%s \n%s currency updated. %s' % (