[FIX] base, account: usability on company currency selection.
We now display all the existing currencies (even the unactivated) instead of a link to activate more of them, and upon the save we make sure to activate the selected currency if it's not yet the case. That's better from a point of view since it avoids jumping off of the screen then come back to make this setting
This commit is contained in:
@@ -146,7 +146,7 @@
|
|||||||
<div class="content-group">
|
<div class="content-group">
|
||||||
<div class="row mt16">
|
<div class="row mt16">
|
||||||
<label for="currency_id" class="col-md-3 o_light_label"/>
|
<label for="currency_id" class="col-md-3 o_light_label"/>
|
||||||
<field name="currency_id" options="{'no_create_edit': True, 'no_open': True}"/>
|
<field name="currency_id" options="{'no_create_edit': True, 'no_open': True}" context="{'active_test': False}"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -221,11 +221,22 @@ class Company(models.Model):
|
|||||||
# The write is made on the user to set it automatically in the multi company group.
|
# The write is made on the user to set it automatically in the multi company group.
|
||||||
self.env.user.write({'company_ids': [(4, company.id)]})
|
self.env.user.write({'company_ids': [(4, company.id)]})
|
||||||
partner.write({'company_id': company.id})
|
partner.write({'company_id': company.id})
|
||||||
|
|
||||||
|
# Make sure that the selected currency is enabled
|
||||||
|
if vals.get('currency_id'):
|
||||||
|
currency = self.env['res.currency'].browse(vals['currency_id'])
|
||||||
|
if not currency.active:
|
||||||
|
currency.write({'active': True})
|
||||||
return company
|
return company
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def write(self, values):
|
def write(self, values):
|
||||||
self.clear_caches()
|
self.clear_caches()
|
||||||
|
# Make sure that the selected currency is enabled
|
||||||
|
if values.get('currency_id'):
|
||||||
|
currency = self.env['res.currency'].browse(values['currency_id'])
|
||||||
|
if not currency.active:
|
||||||
|
currency.write({'active': True})
|
||||||
return super(Company, self).write(values)
|
return super(Company, self).write(values)
|
||||||
|
|
||||||
@api.constrains('parent_id')
|
@api.constrains('parent_id')
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
<field name="email"/>
|
<field name="email"/>
|
||||||
<field name="vat"/>
|
<field name="vat"/>
|
||||||
<field name="company_registry"/>
|
<field name="company_registry"/>
|
||||||
<field name="currency_id" options="{'no_create': True, 'no_open': True}" id="company_currency"/>
|
<field name="currency_id" options="{'no_create': True, 'no_open': True}" id="company_currency" context="{'active_test': False}"/>
|
||||||
<field name="parent_id" groups="base.group_multi_company"/>
|
<field name="parent_id" groups="base.group_multi_company"/>
|
||||||
<field name="sequence" invisible="1"/>
|
<field name="sequence" invisible="1"/>
|
||||||
<field name="report_footer" placeholder="e.g. Your Bank Accounts, one per line"/>
|
<field name="report_footer" placeholder="e.g. Your Bank Accounts, one per line"/>
|
||||||
|
|||||||
@@ -171,20 +171,5 @@
|
|||||||
<field name="context">{'active_test': False}</field>
|
<field name="context">{'active_test': False}</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- We override the view res_company here because the action wasn't defined before -->
|
|
||||||
<record id="action_view_company_form_link_2_currencies" model="ir.ui.view">
|
|
||||||
<field name="name">res.company.form</field>
|
|
||||||
<field name="model">res.company</field>
|
|
||||||
<field name="inherit_id" ref="base.view_company_form"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<xpath expr="//field[@id='company_currency']" position="after">
|
|
||||||
<label for="id" invisible="1"/>
|
|
||||||
<p class="text-muted">
|
|
||||||
<a href="" type="action" name="%(base.action_currency_all_form)d">Activate more currencies</a>.
|
|
||||||
</p>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
Reference in New Issue
Block a user