I am working with stock.move
model. This model has a Many2one field named picking_type_id
. I know this is not the best way, but I use attrs="{'invisible': [('picking_type_id', '=', 1)]}"
expression to hide elements in incoming stock moves (I am pretty sure that incoming type ID is not going to be modified).
But this expression is only working in form views, it does not work for tree views. This would be comprensible if the element is a field, but if not (for example a button), it should work, shouldn't it?
<field name="picking_type_id" invisible="0"/>
<button name="open_lots_manager_wizard"
string="Select lots" type="object"
icon="terp-accessories-archiver+"
attrs="{'invisible': [('picking_type_id', '=', 1)]}"
groups="stock.group_stock_user"/>
For example if I modify the above attrs
expression and turn it into the below one, it works (if I set a quantity over 3, the button disappears, and it appears again if I set a quantity under or equal to 3):
<field name="picking_type_id" invisible="0"/>
<button name="open_lots_manager_wizard"
string="Select lots" type="object"
icon="terp-accessories-archiver+"
attrs="{'invisible': [('product_uom_qty', '>', 3)]}"
groups="stock.group_stock_user"/>
Can anyone explain me the reason of this? Do I have to create a related field pointing to the picking type code (for example) only to achieve my purpose?