i have the following button in my form:
xml
<button
name="button_approve" string="Approve order" attrs="{'invisible':['|',
('manager_id', '=','current_user'),('state' , 'not in', ['to
approve'])]}
<field name="dept_manager_id"/>
<field name="current_user"/>
python
manager_id = fields.Many2one('res.users'
current_user = fields.Many2one('res.users', compute='_get_current_user')
@api.depends()
def _get_current_user(self):
for rec in self:
rec.current_user = self.env.user
self.write({'current_user': self.env.user.id})
The
attrs is designed to show the button only for orders if 'current_user' =
'manager_id' , with a status of 'to approve', however only the second
part of the condition (status of 'to approve') was being evaluated
correctly.