Skip to Content
Menu
This question has been flagged
2 Replies
3139 Views

Hi,

I want to hide edit button, when state changed to done(without putting attrs in each field) 


Avatar
Discard
Author

hii, Sylvain Michel Ratsarafahatra

Thanks for your response, i already try that solution but it's not working for me

Best Answer

Hi,

I suggest you to do like the bellow code by creating a computed field, adapt it as you need.

# Hide edit button
edit_hide_css = fields.Html(string='CSS', sanitize=False, compute='_compute_edit_hide_css')

@api.depends('state')
def _compute_edit_hide_css(self):
for rec in self:
if rec.state in ['done']:
rec.edit_hide_css = '<style>.o_form_button_edit {display: none !important;}</style>'
else:
rec.edit_hide_css = False

Best regards!

Avatar
Discard

that does not prevent a user from re-activating the button with the browser inspector; It should be recommended for permissions.

Best Answer

Have a look at this module https://odoo-community.org/shop/product/web-action-conditionable-2608#attr=8636, you can set the attribute `edit` base on the value of a field

Avatar
Discard
Related Posts Replies Views Activity
2
Jun 25
1619
0
May 25
14
2
Jan 25
3238
1
Dec 24
6805
1
Nov 24
3208