Search 1.9 billion lines of Odoo code on GitHub

web_trash_condition

Author: Numigi
License: LGPL-3
Branch: TA#47984
Repository: Numigi/odoo-web-addons
Dependencies: web
Languages: JavaScript (21, 33.9%), Python (15, 24.2%), XML (8, 12.9%), and reStructuredText (18, 29.0%)
Other branches: 12.0, 12.0-web_list_column_text_align, 14.0, TA#48575, and TA#48575-1

<h1 class="title">Web Trash Condition</h1> <p>This module adds the possibility to make the trash widget invisible under a given condition.</p> <a name="usage"></a> <h2>Usage</h2> <p>By itself, this module does not modify the behavior of Odoo.</p> <p>To use the feature for a given model, you must define a boolean field <code>trash_widget_invisible</code> on it. Typically, it is a computed field.</p> <p>Here is an example with a sale order line.</p> <pre> <code lang="python">from odoo import api, fields, models class SaleOrderLine(models.Model): _inherit = 'sale.order.line' trash_widget_invisible = fields.Boolean(compute=&quot;_compute_trash_widget_invisible&quot;) &#64;api.depends('qty_delivered') def _compute_trash_widget_invisible(self): for line in self: line.trash_widget_invisible = bool(line.qty_delivered)</code> </pre> <p>In this example, the widget is invisible if the product was delivered (fully or partially).</p> <p>In the list view, you must add the field <code>trash_widget_invisible</code>, otherwise, it will not be used.</p> <pre> <code lang="xml">&lt;record id=&quot;sale_order_form&quot; model=&quot;ir.ui.view&quot;&gt; &lt;field name=&quot;name&quot;&gt;sale.order.form&lt;/field&gt; &lt;field name=&quot;model&quot;&gt;sale.order&lt;/field&gt; &lt;field name=&quot;inherit_id&quot; ref=&quot;sale.view_order_form&quot;/&gt; &lt;field name=&quot;arch&quot; type=&quot;xml&quot;&gt; &lt;xpath expr=&quot;//field[&#64;name='order_line']/tree&quot; position=&quot;inside&quot;&gt; &lt;field name=&quot;trash_widget_invisible&quot; invisible=&quot;1&quot;/&gt; &lt;/xpath&gt; &lt;/field&gt; &lt;/record&gt;</code> </pre> <p>Here is the result:</p> <img alt="web_trash_condition/static/description/sale_order_form.png" src="web_trash_condition/static/description/sale_order_form.png" /> <a name="contributors"></a> <h2>Contributors</h2> <ul class="simple"> <li>Numigi (tm) and all its contributors (<a class="reference external" href="https://bit.ly/numigiens">https://bit.ly/numigiens</a>)</li> </ul> <a name="more-information"></a> <h2>More information</h2> <ul class="simple"> <li>Meet us at <a class="reference external" href="https://bit.ly/numigi-com">https://bit.ly/numigi-com</a></li> </ul>