تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
3484 أدوات العرض

Hi,

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


الصورة الرمزية
إهمال
الكاتب

hii, Sylvain Michel Ratsarafahatra

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

أفضل إجابة

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!

الصورة الرمزية
إهمال

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

أفضل إجابة

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

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
3
سبتمبر 25
3189
0
أغسطس 25
751
1
أغسطس 25
2949
2
يوليو 25
8581
2
يوليو 25
4986