Hi,
I need some help to hide a column in a treeview in some cases.
I defined a button for a custom wizard on outgoing assigned inventory moves (customer shipment).
class Move(metaclass=PoolMeta):
__name__ = 'stock.move'
@classmethod
def __setup__(cls):
super().__setup__()
cls._buttons.update({
'update_quantity_wizard': {
'invisible': ~Eval('state').in_(['assigned']),
'depends': ['state'],
},
})
@classmethod
@ModelView.button_action('module.wizard_update_quantity')
def update_quantity_wizard(cls, moves):
pass
Updating stock.move_list_shipment.xml:
<data>
<xpath expr="/tree" position="inside">
<button name="update_quantity_wizard" string="Pick"/>
</xpath>
</data>
With this result:
Button is visible when move state is âAssignedâ:
Button is invisible for other states:
Until now, everything is ok
But this button is specific to Customer Shipment. So i donât want to display the column âPickâ in Supplier Shipment model.
After a discuss on Irc, the suggestion was to use view_attributes and context to hide the column.
class Move(metaclass=PoolMeta):
__name__ = 'stock.move'
@classmethod
def view_attributes(cls):
return super().view_attributes() + [
('/tree/button[@name="update_quantity_wizard"]', 'tree_invisible',
Eval('context', {}).get('shipment_in', False)),
]
And adding a variable in the action context:
<?xml version="1.0"?>
<tryton>
<data>
<record model="ir.action.act_window" id="stock.act_shipment_in_form">
<field name="context" eval="{'shipment_in': True}" pyson="1"/>
</record>
</data>
</tryton>
But, this is not working and iâm still viewing the column âPickâ in the supplier shipment form:
Thanks for your help