hi
(odoo11)
I have a "state" field and some button on it. I want a button invisible in a specific state .
----------------------
@api.depends('parent_id')
def _compute_is_valid(self):
for order in self:
order.is_valid = False
if order.parent_id.user_id.id == self.env.uid:
order.is_valid = True
else:
order.is_valid = False
parent_id = fields.Many2one('hr.employee', 'Manager', readonly=True)
state = fields.Selection([('draft', 'Draft'), ('manager_approve','Manager Approved'),
('validate_special_access','Validate Special Access'), ('support_team_approve','Support Agent Validated'),
('support_manager_done','Support Manager Validated/Done'),('cancel', 'Cancelled')],
'Status', track_visibility=True, required=True,
copy=False, default='draft')
is_valid = fields.Boolean(compute="_compute_is_valid")
in xml :
<button name="action_validate_special_access" attrs="{'invisible': [('is_valid','=',True)]}" groups="support_services.group_sspecial_manager" states="manager_approve" string="Validate Special Access" type="object"/>
(attrs="{'invisible': [('is_valid','=',True)]}")
the "is_valid" field automaticaly compute ,
but this "invisible attr" only work when I change "parent_id" manualy.then the button "Validate Special Access" visible or invisible
what is problem? it is related to @api in my function? or what?
thanks
Hi,
If you need to make a button on specific states then use states="the states which you need the button visible"
for eg: <button name="action_invoice_cancel" states="draft,open"/> , here the button will visible on the states draft and open
Check odoo tips: https://goo.gl/8HgnCF