Skip to content

Commit

Permalink
[MIG] l10n_ar_currency_update: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximiliano Mezzavilla authored and pablohmontenegro committed Jan 19, 2023
1 parent 37816bc commit e1a4a28
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
2 changes: 2 additions & 0 deletions l10n_ar_currency_update/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ To configure this module, you need to:
Usage
=====

Este modulo permite la actualización automática del tipo de cambio de las monedas que esten activadas, tomando la información desde la pagina de AFIP, la cual coincide con la del banco nación, tipo de cambio DIVISA.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: http://runbot.adhoc.com.ar/
Expand Down
4 changes: 2 additions & 2 deletions l10n_ar_currency_update/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
'name': 'Argentinian Currency Rate Update',
'version': "15.0.1.0.0",
'version': "16.0.1.0.0",
'category': 'Localization/Argentina',
'sequence': 14,
'author': 'ADHOC SA,Odoo Community Association (OCA)',
Expand All @@ -35,7 +35,7 @@
'data/res_company_data.xml',
'wizards/res_config_settings_views.xml',
],
'installable': False,
'installable': True,
'auto_install': True,
'application': False,
}
2 changes: 1 addition & 1 deletion l10n_ar_currency_update/data/res_company_data.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<odoo noupdate="1">

<function model="res.company" name="set_special_defaults_on_install"/>
<function model="res.company" name="_compute_currency_provider"/>

</odoo>
15 changes: 8 additions & 7 deletions l10n_ar_currency_update/models/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,20 @@ class ResCompany(models.Model):
)
l10n_ar_last_currency_sync_date = fields.Date(string="AFIP Last Sync Date", readonly=True)

@api.model
@api.model_create_multi
def create(self, values):
""" Overwrite to include new currency provider """
if values.get('country_id') and 'currency_provider' not in values:
country = self.env['res.country'].browse(values['country_id'])
if country.code.upper() == 'AR':
values['currency_provider'] = 'afip'
for index in range(len(values)):
if values[index].get('country_id') and 'currency_provider' not in values[index]:
country = self.env['res.country'].browse(values[index]['country_id'])
if country.code.upper() == 'AR':
values[index]['currency_provider'] = 'afip'
return super().create(values)

@api.model
def set_special_defaults_on_install(self):
def _compute_currency_provider(self):
""" Overwrite to include new currency provider """
super().set_special_defaults_on_install()
super()._compute_currency_provider()
ar_companies = self.search([]).filtered(lambda company: company.country_id.code == 'AR')
if ar_companies:
ar_companies.currency_provider = 'afip'
Expand Down

0 comments on commit e1a4a28

Please sign in to comment.