<a class="reference external image-reference" href="http://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="custom-domain-operators"></a>
<h2>Custom domain operators</h2>
<p>This module was written to allow developers to define custom domain operators. This can be very helpful for complicated selections or ir.rules.</p>
<a name="currently-implemented-operators"></a>
<h3>Currently implemented operators</h3>
<dl class="docutils">
<dt><code>parent_of</code></dt>
<dd><p class="first">The inverse of <code>child_of</code>: Searches for the parents of given records in the hierarchy, including the records themselves:</p>
<pre class="last">
<code class="last">[('id', 'parent_of', [42])]</code>
</pre>
</dd>
<dt><code>substring_of</code></dt>
<dd><p class="first">The inverse of <code>like</code>: Searches for values that are a substring of the value given. Note that this is very inefficient in general:</p>
<pre class="last">
<code class="last">[('ref', 'substring_of', 'long string')]</code>
</pre>
</dd>
</dl>
<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 one of the operators explained above in any of your domains</li>
</ol>
<p>To add your own operators:</p>
<ol class="arabic simple">
<li>in <code>base.domain.operator</code>, define a function <code>_operator_${your_operator}</code> with decorator <code>@api.model</code> and signature <code>leaf, expression</code></li>
<li><code>leaf</code> is a 3-tuple of a domain proposition, <code>expression</code> an instance of <code>odoo.osv.expression.expression</code></li>
<li>return a list of <code>odoo.osv.expression.ExtendedLeaf</code> instances that maps your operator to some expressions the original domain parser can evaluate</li>
<li>note that you can use the internal <code>inselect</code> operator here if you pass <code>internal=True</code> to <code>ExtendedLeaf</code>'s constructor</li>
<li>be careful with using the ORM in those handlers to avoid infinite loops</li>
<li>take good care that you don't introduce SQL injections and other security problems</li>
</ol>
<a name="known-issues-roadmap"></a>
<h3>Known issues / Roadmap</h3>
<ul class="simple">
<li>given the upstream code is not exactly extension friendly, we'll have to reimplement a bunch of helper functions</li>
<li><code>parent_of</code> currently doesn't support dotted paths and searching for names (<code>name_get</code>), this needs to be amended as needed</li>
<li>another nice operator would be <code>indomain</code>, probably also with a way to refer to the table's columns in the right hand side of expressions</li>
</ul>
<a name="bug-tracker"></a>
<h3>Bug Tracker</h3>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-tools/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 <<a class="reference external" href="mailto:hbrunn@therp.nl">hbrunn@therp.nl</a>></li>
<li>George Daramouskas <<a class="reference external" href="mailto:gdaramouskas@therp.nl">gdaramouskas@therp.nl</a>></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@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>