mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
Merge pull request #226 from akretion/8.0-currency-rate-update-workaround-and-enhance
8.0 workaround bug #151 and fixes the cron
This commit is contained in:
@@ -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": [],
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
@@ -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)
|
||||
|
||||
# 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')
|
||||
|
||||
13
currency_rate_update/security/rule.xml
Normal file
13
currency_rate_update/security/rule.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data noupdate="1">
|
||||
|
||||
<record id="currency_rate_update_service_multicompany_rule" model="ir.rule">
|
||||
<field name="name">Current Rate Update Service multi-company</field>
|
||||
<field name="model_id" ref="model_currency_rate_update_service"/>
|
||||
<field name="global" eval="True"/>
|
||||
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -7,6 +7,8 @@
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Currency update services">
|
||||
<field name="service"/>
|
||||
<field name="company_id" groups="base.group_multi_company"
|
||||
invisible="not context.get('currency_rate_update_main_view')"/>
|
||||
<field name="currency_to_update"/>
|
||||
<field name="interval_type"/>
|
||||
<field name="interval_number"/>
|
||||
@@ -20,25 +22,40 @@
|
||||
<field name="model">currency.rate.update.service</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Currency update services">
|
||||
<group>
|
||||
<group>
|
||||
<group name="main">
|
||||
<group name="left">
|
||||
<field name="service"/>
|
||||
<field name="company_id" groups="base.group_multi_company"
|
||||
invisible="not context.get('currency_rate_update_main_view')"
|
||||
required="context.get('currency_rate_update_main_view')"/>
|
||||
<field name="max_delta_days"/>
|
||||
</group>
|
||||
<group>
|
||||
<group name="right">
|
||||
<field name="interval_type"/>
|
||||
<field name="interval_number"/>
|
||||
<field name="next_run"/>
|
||||
</group>
|
||||
</group>
|
||||
<separator string="Currencies to update with this service" colspan="4"/>
|
||||
<field name="currency_list" invisible="1"/>
|
||||
<field name="currency_to_update" colspan="4" nolabel="1" domain="[('id','in', currency_list[0][2])]"/>
|
||||
<separator string="Logs" colspan="4"/>
|
||||
<field name="note" colspan="4" nolabel="1"/>
|
||||
<group string="Currencies to update with this service">
|
||||
<field name="currency_list" invisible="1"/>
|
||||
<field name="currency_to_update" nolabel="1" domain="[('id','in', currency_list[0][2])]"/>
|
||||
</group>
|
||||
<group string="Logs" name="logs">
|
||||
<field name="note" nolabel="1"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="currency_rate_update_action" model="ir.actions.act_window">
|
||||
<field name="name">Currency Rate Update</field>
|
||||
<field name="res_model">currency.rate.update.service</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="context">{'currency_rate_update_main_view': True}</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="currency_rate_update_menu" action="currency_rate_update_action"
|
||||
parent="account.menu_configuration_misc" sequence="21"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<field name="doall" eval="False"/>
|
||||
<field name="model" eval="'currency.rate.update.service'"/>
|
||||
<field name="function" eval="'_run_currency_update'"/>
|
||||
<field name="args">(None,)</field>
|
||||
<field name="args">()</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
|
||||
Reference in New Issue
Block a user