[IMP] Port to V9

This commit is contained in:
vrenaville
2015-10-30 13:33:03 +01:00
committed by Yannick Vaucher
parent 02d0c49257
commit 53c36243f8
6 changed files with 17 additions and 52 deletions

View File

@@ -74,8 +74,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-tools/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 <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20currency_rate_update%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback.
Credits
@@ -92,6 +91,7 @@ Contributors
* Agustin Cruz <openpyme.mx> (BdM)
* Dorin Hongu <dhongu@gmail.com> (BNR)
* Fekete Mihai <feketemihai@gmail.com> (Port to V8)
* Vincent Renaville <vincent.renaville@camptocamp.com> (Port to V9)
Maintainer
----------

View File

@@ -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
}

View File

@@ -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',

View File

@@ -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!'))

View File

@@ -9,7 +9,6 @@
<page string="Currency update configuration">
<group>
<field name="auto_currency_up"/>
<field name="multi_company_currency_enable"/>
</group>
<separator string="Currency update services" colspan="4"/>
<field name="services_to_use" colspan="4" nolabel="1"/>

View File

@@ -55,7 +55,7 @@
</record>
<menuitem id="currency_rate_update_menu" action="currency_rate_update_action"
parent="account.menu_configuration_misc" sequence="21"/>
parent="account.menu_finance_configuration" sequence="21"/>
</data>
</openerp>