This does not work
field name="price_unit" attrs={'readonly': [('groups_id', 'not in', [ref('purchase.group_purchase_manager')])]}
error
Field 'groups_id' used in attrs ({'readonly': [('groups_id', 'not in', [ref('purchase.group_purchase_manager')])]}) must be present in view but is missing.
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,
If you are using odoo 15 or below, you can achieve this by creating a inherited view for this user group and setting readonly for the field from that view.
* Create new inherited view
* assign user group for the view
* xpath the field and make it readonly
Doing this, field will get readonly for the users in this group.
For more, see: https://www.youtube.com/watch?v=Fsp6lAPHz08
Thanks
Hi. This solution no longer works for V17. I get this error
Inherited view cannot have 'Groups' define on the record. Use 'groups' attributes inside the view definition
Any Ideas? Thanks.
I was able to figure it out. For anyone in my situation, I achieved this in odoo17 by first creating a new user group that inherited from existing user that can edit the field and created a new view like this.
<xpath expr="//sheet/notebook/page/field[2]/tree/field[@name='price_unit']" position="attributes">
<attribute name="groups">purchase.group_purchase_user</attribute>
</xpath>
<xpath expr="//sheet/notebook/page/field[2]/tree/field[@name='price_unit']" position="after">
<field name="price_unit"
readonly="1"
groups="new_module.new_group,!purchase.group_purchase_user"/>
</xpath>
Notice that I now have 2 price_unit fields.
I believe this works because since the new group inherits the existing group, we have to explicitly specify that the inherited group is not allowed to view this new price_unit field. Hence, !purchase.group_purchase_user
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 2 24
|
2717 | ||
|
0
thg 2 24
|
10 | ||
|
1
thg 3 15
|
4889 | ||
|
1
thg 3 25
|
1250 | ||
|
0
thg 11 24
|
972 |