mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
Merge pull request #2 from akretion/10.0-fix-currency_rate_update-domain
[FIX] Crash when you add currencies to "Currencies to update with this service"
This commit is contained in:
@@ -30,6 +30,7 @@ class CurrencyRateUpdateService(models.Model):
|
||||
have to be updated"""
|
||||
_name = "currency.rate.update.service"
|
||||
_description = "Currency Rate Update"
|
||||
_rec_name = "service"
|
||||
|
||||
@api.multi
|
||||
@api.constrains('max_delta_days')
|
||||
@@ -56,13 +57,20 @@ class CurrencyRateUpdateService(models.Model):
|
||||
@api.onchange('service')
|
||||
def _onchange_service(self):
|
||||
currency_list = ''
|
||||
res = {'domain': {
|
||||
'currency_to_update': "[('id', '=', False)]",
|
||||
}}
|
||||
if self.service:
|
||||
currencies = []
|
||||
getter = CurrencyGetterType.get(self.service)
|
||||
currency_list = getter.supported_currency_array
|
||||
currencies = self.env['res.currency'].search(
|
||||
[('name', 'in', currency_list)])
|
||||
self.currency_list = [(6, 0, [curr.id for curr in currencies])]
|
||||
currency_list = [(6, 0, currencies.ids)]
|
||||
res['domain']['currency_to_update'] =\
|
||||
"[('id', 'in', %s)]" % currencies.ids
|
||||
self.currency_list = currency_list
|
||||
return res
|
||||
|
||||
def _selection_service(self, *a, **k):
|
||||
res = [(x.code, x.name) for x in CurrencyGetterType.getters.values()]
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
<group name="main">
|
||||
<group name="left">
|
||||
<field name="service"/>
|
||||
<field name="currency_list" invisible="1"/>
|
||||
<field name="currency_list_readonly" widget="many2many_tags"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
</group>
|
||||
@@ -40,8 +41,7 @@
|
||||
</group>
|
||||
<group string="Currencies to update with this service" name="currencies">
|
||||
<!-- I need to have currency_list as r+w for the on_change -->
|
||||
<field name="currency_list" invisible="1"/>
|
||||
<field name="currency_to_update" nolabel="1" domain="[('id','in', currency_list[0][2])]"/>
|
||||
<field name="currency_to_update" nolabel="1"/>
|
||||
</group>
|
||||
<group string="Logs" name="logs">
|
||||
<field name="note" nolabel="1"/>
|
||||
|
||||
Reference in New Issue
Block a user