I know I can set create=False to hide it from everyone but I would like to be able to see it when I'm in certain group. How can I do it?
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ờ
Hello dohn_joe,
You can do by overriding fields_view_get method.
here I give you the example of fields_view_get:
For E.g:
from lxml import etree
def fields_view_get(self, cr, uid, view_id=None, view_type='tree',
context=None, toolbar=False, submenu=False):
if context is None:context = {}
res = super(class_name, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type,
context=context, toolbar=toolbar, submenu=False)
group_id = self.pool.get('res.users').has_group(cr, uid, 'modulename.group_xml_id')
doc = etree.XML(res['arch'])
if group_id:
if view_type == 'tree':
nodes = doc.xpath("//tree[@string='Test Tree']")
for node in nodes:
node.set('create', '0')
res['arch'] = etree.tostring(doc)
return res
I hope this will helpful for you.
thanks
Thanks a lot! It worked exactly as I wanted.
Always welcome john_joe :) 👍
this has change a bit in Odoo 16 and looks more like this:
def_get_view(self, view_id=None, view_type='form', **options):
arch, view = super()._get_view(view_id, view_type, **options)
if view_type in ('tree'):
nodes = arch.xpath("//tree")
for node in nodes:
# logic needed to switch create on or off
if True:
node.set('create', '1')
return arch, view
thanks!
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 | |
---|---|---|---|---|
|
2
thg 8 21
|
13515 | ||
|
5
thg 8 20
|
7464 | ||
|
1
thg 12 19
|
5363 | ||
|
0
thg 9 17
|
3507 | ||
|
0
thg 8 17
|
2860 |