diff --git a/currency_rate_update/README.rst b/currency_rate_update/README.rst index 02354a574..a37770889 100644 --- a/currency_rate_update/README.rst +++ b/currency_rate_update/README.rst @@ -74,8 +74,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and welcomed feedback -`here `_. +If you spotted it first, help us smashing it by providing a detailed and welcomed feedback. Credits @@ -92,6 +91,7 @@ Contributors * Agustin Cruz (BdM) * Dorin Hongu (BNR) * Fekete Mihai (Port to V8) +* Vincent Renaville (Port to V9) Maintainer ---------- diff --git a/currency_rate_update/__openerp__.py b/currency_rate_update/__openerp__.py index b72ba737b..5fe2bf232 100644 --- a/currency_rate_update/__openerp__.py +++ b/currency_rate_update/__openerp__.py @@ -20,7 +20,7 @@ ############################################################################## { "name": "Currency Rate Update", - "version": "8.0.0.7.0", + "version": "9.0.1.0.0", "author": "Camptocamp,Odoo Community Association (OCA)", "website": "http://camptocamp.com", "license": "AGPL-3", @@ -38,5 +38,5 @@ ], "demo": [], "active": False, - 'installable': False + 'installable': True } diff --git a/currency_rate_update/model/company.py b/currency_rate_update/model/company.py index a71d27987..d7e5708a1 100644 --- a/currency_rate_update/model/company.py +++ b/currency_rate_update/model/company.py @@ -22,37 +22,21 @@ from openerp import models, fields, api -class res_company(models.Model): +class ResCompany(models.Model): """override company to add currency update""" - @api.multi - def _compute_multi_curr_enable(self): - "check if multi company currency is enabled" - company_currency = self.env['res.currency'].search([('company_id', - '!=', False)]) - for company in self: - company.multi_company_currency_enable = \ - 1 if company_currency else 0 - - @api.one - def button_refresh_currency(self): - """Refresh the currencies rates !!for all companies now""" - self.services_to_use.refresh_currency() - _inherit = "res.company" + @api.multi + def button_refresh_currency(self): + """Refresh the currencies rates""" + self.ensure_one() + self.services_to_use.refresh_currency() + # Activate the currency update auto_currency_up = fields.Boolean( string='Automatic Update', 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( - string='Multi company currency', translate=True, - compute="_compute_multi_curr_enable", - help="When this option is unchecked it will allow users " - "to set a distinct currency updates on each company." - ) # List of services to fetch rates services_to_use = fields.One2many( 'currency.rate.update.service', diff --git a/currency_rate_update/model/currency_rate_update.py b/currency_rate_update/model/currency_rate_update.py index b0e6f1a45..dc50f478f 100644 --- a/currency_rate_update/model/currency_rate_update.py +++ b/currency_rate_update/model/currency_rate_update.py @@ -164,19 +164,9 @@ class Currency_rate_update_service(models.Model): if self.service: currencies = [] currency_list = supported_currency_array - company_id = False - if self.company_id.multi_company_currency_enable: - company_id = self.company_id.id currency_list = supported_currecies[self.service] - if company_id: - currencies = self.env['res.currency'].search( - [('name', 'in', currency_list), - '|', ('company_id', '=', company_id), - ('company_id', '=', False)]) - else: - currencies = self.env['res.currency'].search( - [('name', 'in', currency_list), - ('company_id', '=', False)]) + currencies = self.env['res.currency'].search( + [('name', 'in', currency_list)]) self.currency_list = [(6, 0, [curr.id for curr in currencies])] # List of webservicies the value sould be a class name @@ -244,23 +234,15 @@ class Currency_rate_update_service(models.Model): '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'] company = self.company_id # The multi company currency can be set or no so we handle # The two case if company.auto_currency_up: - main_currency = curr_obj.search( - [('base', '=', True), ('company_id', '=', company.id)], - limit=1) + main_currency = self.company_id.currency_id if not main_currency: - # If we can not find a base currency for this company - # we look for one with no company set - main_currency = curr_obj.search( - [('base', '=', True), ('company_id', '=', False)], - limit=1) - if not main_currency: - raise exceptions.Warning(_('There is no base currency set!')) + raise exceptions.Warning(_('There is no main \ + currency defined!')) if main_currency.rate != 1: raise exceptions.Warning(_('Base currency rate should ' 'be 1.00!')) diff --git a/currency_rate_update/view/company_view.xml b/currency_rate_update/view/company_view.xml index 60ebb8a27..1700f10cf 100644 --- a/currency_rate_update/view/company_view.xml +++ b/currency_rate_update/view/company_view.xml @@ -9,7 +9,6 @@ - diff --git a/currency_rate_update/view/currency_rate_update.xml b/currency_rate_update/view/currency_rate_update.xml index e7c5fa62c..c977e91b0 100644 --- a/currency_rate_update/view/currency_rate_update.xml +++ b/currency_rate_update/view/currency_rate_update.xml @@ -55,7 +55,7 @@ + parent="account.menu_finance_configuration" sequence="21"/>