I want to use fields_view_get() method to make invisible the edit button for a specific user for a specific condition.
But I couldn't get the model data in in this method.
suppose I'm using this method in " hr.applicant " model. And this model has a field stage_id . When is method is executing I want the values of stage_id. I'm using odoo 15
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
Hi,
You cannot get the model data or record data inside the fields_view_,get or get_view method.
If you check the execution of the function, it execute only when the view is loaded initially and won't get executed on switching between records.
if you can tell us, the condition that you are trying to add, lets see if we can do with any approach.
Thanks
I want this condition. I added the full code. Please check
@api.model
def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
result = super(Applicant, self).fields_view_get(view_id=view_id, view_type=view_type,
toolbar=toolbar,
submenu=submenu)
# Disabling the edit button for vendor user not in "New" stage
if view_type == 'form':
doc = etree.XML(result['arch'])
user = self.env.user
if self.stage_id.name != 'New' and user.partner_id.is_vendor and user.has_group('recruitment_extension.group_hr_recruitment_vendor'):
# When the user is 'Vendor' and the stage is not 'New' then the edit button will be invisible
for node in doc.xpath("//form"):
# Set the edit to false
node.set('edit', "false")
result['arch'] = etree.tostring(doc)
return result
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
1
thg 6 25
|
1556 | ||
|
3
thg 7 25
|
3225 | ||
|
1
thg 5 25
|
1374 | ||
|
1
thg 5 25
|
1624 | ||
|
4
thg 5 25
|
2773 |