Search 1.9 billion lines of Odoo code on GitHub

web_widget_many2one_polymorphic

Author: Elico Corp,Therp BV,Odoo Community Association (OCA)
License: AGPL-3
Branch: 10.0-web_widget_many2one_polymorphic
Repository: hbrunn/web
Dependencies: base, and web
Languages: JavaScript (33, 45.8%), Python (16, 22.2%), and XML (23, 31.9%)

<a class="reference external image-reference" href="https://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.svg"> </a> <a name="polymorphic-many2one-widget"></a> <h2>Polymorphic many2one widget</h2> <p>The polymorphic field allows to dynamically store an id linked to any model in Odoo instead of the usual fixed one in the view definition, allowing comfortable editing in cases where you'd have to craft a reference field.</p> <p>A notorious case is mail.message with fields <code>res_id</code> and <code>res_model</code>:</p> <pre> <code>'res_model': fields.char(), 'res_id': fields.integer('Resource')</code> </pre> <p>Then in your view, you can say:</p> <pre> <code>&lt;field name=&quot;res_model&quot; invisible=&quot;1&quot; /&gt; &lt;field name=&quot;res_id&quot; widget=&quot;many2one_polymorphic&quot; options='{&quot;model_field&quot;: &quot;res_model&quot;}' /&gt;</code> </pre> <p>This way, the user gets the full featured many2one widget for the model in question.</p> <a name="usage"></a> <h3>Usage</h3> <p>To use this module, you need to:</p> <ol class="arabic simple"> <li>depend on it</li> <li>use the widget in the integer field and pass the field to be used for the model in the options dictionary</li> </ol> <a class="reference external image-reference" href="https://runbot.odoo-community.org/runbot/162/10.0"><img alt="Try me on Runbot" src="https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas" /></a> <a name="bug-tracker"></a> <h3>Bug Tracker</h3> <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web_widget_many2one_polymorphic/issues">GitHub Issues</a>. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed feedback.</p> <a name="credits"></a> <h3>Credits</h3> <a name="images"></a> <h4>Images</h4> <ul class="simple"> <li>Odoo Community Association: <a class="reference external" href="https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg">Icon</a>.</li> </ul> <a name="contributors"></a> <h4>Contributors</h4> <ul class="simple"> <li>Holger Brunn &lt;<a class="reference external" href="mailto:hbrunn&#64;therp.nl">hbrunn&#64;therp.nl</a>&gt;</li> <li>Augustin Cisterne-Kaas &lt;<a class="reference external" href="mailto:augustin.cisternekaas&#64;elico-corp.com">augustin.cisternekaas&#64;elico-corp.com</a>&gt;</li> </ul> <p>Do not contact contributors directly about help with questions or problems concerning this addon, but use the <a class="reference external" href="mailto:community&#64;mail.odoo.com">community mailing list</a> or the <a class="reference external" href="https://odoo-community.org/groups">appropriate specialized mailinglist</a> for help, and the bug tracker linked in <a class="reference internal" href="#bug-tracker">Bug Tracker</a> above for technical issues.</p> <a name="maintainer"></a> <h4>Maintainer</h4> <a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a> <p>This module is maintained by the OCA.</p> <p>OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.</p> <p>To contribute to this module, please visit <a class="reference external" href="https://odoo-community.org">https://odoo-community.org</a>.</p>