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="_compute_trash_widget_invisible")
@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"><record id="sale_order_form" model="ir.ui.view">
<field name="name">sale.order.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='order_line']/tree" position="inside">
<field name="trash_widget_invisible" invisible="1"/>
</xpath>
</field>
</record></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>