Search 1.9 billion lines of Odoo code on GitHub

onchange_action

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(&#39;field</em>name&#39;)</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(&#39;partner_id&#39;) def _onchange_partner_action(self): return &lt;your action def here&gt; </code></p> <p>The method may return action dict <code> ctx = dict(self.env.context) return { &#39;name&#39;: _(&#39;My Wizard name&#39;), &#39;view_type&#39;: &#39;form&#39;, &#39;view_mode&#39;: &#39;form&#39;, &#39;res_model&#39;: &#39;my.model.wizard&#39;, &#39;domain&#39;: [], &#39;context&#39;: ctx, &#39;views&#39;: [[False, &#39;form&#39;]], &#39;type&#39;: &#39;ir.actions.act_window&#39;, &#39;target&#39;: &#39;new&#39; } </code> The method may return action ID</p> <p><code>return self.[&#39;ir.ui.act_window&#39;].search(([&#39;your&#39;, &#39;domain&#39;, &#39;here&#39;])).id</code></p> <p>or The method may return action xmlID</p> <p><code>return self.[&#39;ir.model.data&#39;].search(([&#39;your&#39;, &#39;domain&#39;, &#39;here&#39;])).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(&#39;partner_id&#39;) @api.onchange_action_id(&#39;my_module.my_xml_id&#39;) def _onchange_partner(self): self.message = &quot;Dear %s&quot; % (self.partner_id.name or &quot;&quot;) </code></p> <p>Or the argument can be a hard coded Database action id <code> @api.onchange(&#39;partner_id&#39;) @api.onchange_action_id(123) def _onchange_partner(self): self.message = &quot;Dear %s&quot; % (self.partner_id.name or &quot;&quot;) </code></p> <h6>The model &#39;on_change.action&#39;</h6> <p>It&#39;s a abstract model that offer all the facility see above ``` class MyNewModel(models.Models): <em>name = &#39;my.model&#39; _inherit = &#39;on</em>change.action&#39;</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 = { &#39;field<em>name</em>1&#39; : {<my action dict>}, &#39;field<em>name</em>2&#39; : {<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>&lt;my action dict&gt;</code></p>