Author: |
NDP Systèmes |
License: |
AGPL-3 |
Branch: |
8.0 |
Repository: |
appnessgit/odoo-addons |
Dependencies: |
product,
and
web |
Languages: |
JavaScript (10, 5.3%),
Markdown (70, 37.4%),
PO File (14, 7.5%),
Python (83, 44.4%),
and
XML (10, 5.3%) |
Other branches: |
8.0-entrepot-production,
8.0-entrepot-qualif,
8.0-sirail-de-qualif,
8.0-sirail-production,
8.0-sirail-qualif,
8.0-thomas-sirail-production,
and
8.0-thomas-sirail-qualif |
Other repositories: |
aaltinisik/odoo-addons,
gitstalker/odoo-addons,
kit9/odoo-addons-3,
loftwah/odoo-addons,
marcelsavegnago/odoo-addons-4,
ndp-systemes/odoo-addons,
quadit-dev/odoo-addons,
suningwz/odoo-addons-5,
tate11/odoo-addons-2,
thomas-tankengine/odoo-addons,
and
vidtsin/odoo-addons-8 |
<h1>Feature :</h1>
<h2>Improved on change feature</h2>
<h5>Possibity to return a custom action to triggers in the on_change method</h5>
<h5>add 2 decorator</h5>
<h6>@api.onchange<em>action('field</em>name')</h6>
<p>Return a decorator to decorate an onchange action method for given fields.</p>
<p>Each argument must be a field name</p>
<p><code>
@api.onchange_action('partner_id')
def _onchange_partner_action(self):
return <your action def here>
</code></p>
<p>The method may return action dict
<code>
ctx = dict(self.env.context)
return {
'name': _('My Wizard name'),
'view_type': 'form',
'view_mode': 'form',
'res_model': 'my.model.wizard',
'domain': [],
'context': ctx,
'views': [[False, 'form']],
'type': 'ir.actions.act_window',
'target': 'new'
}
</code>
The method may return action ID</p>
<p><code>return self.['ir.ui.act_window'].search((['your', 'domain', 'here'])).id</code></p>
<p>or The method may return action xmlID</p>
<p><code>return self.['ir.model.data'].search((['your', 'domain', 'here'])).name</code>
.. warning::</p>
<p><code>@onchange_action</code> only supports simple field names, dotted names
(fields of relational fields e.g. <code>partner_id.tz</code>) are not
supported and will be ignored</p>
<h6>@api.onchange<em>action</em>id</h6>
<p>Return a decorator to decorate an onchange action method for given fields.
The argument can be an xml id
<code>
@api.onchange('partner_id')
@api.onchange_action_id('my_module.my_xml_id')
def _onchange_partner(self):
self.message = "Dear %s" % (self.partner_id.name or "")
</code></p>
<p>Or the argument can be a hard coded Database action id
<code>
@api.onchange('partner_id')
@api.onchange_action_id(123)
def _onchange_partner(self):
self.message = "Dear %s" % (self.partner_id.name or "")
</code></p>
<h6>The model 'on_change.action'</h6>
<p>It's a abstract model that offer all the facility see above
```
class MyNewModel(models.Models):
<em>name = 'my.model'
_inherit = 'on</em>change.action'</p>
<p><code>
You can define a new method called `_action_on_change_action_on_change(self, field_name, field_values)`
This method return a dict.
The dict can take 2 defferente strucure
</code>
mdict = {
'field<em>name</em>1' : {<my action dict>},
'field<em>name</em>2' : {<my action dict>}
}
<code>
Or only</code>mdict = <my action dict>```</p>
<p>If you want you can return directly an xml ID or a DB id
instead of the <code><my action dict></code></p>