콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
4 답글
14511 화면

How to hide some groups from user form

For eg: Hiding group named 'Addresses in Sales Orders' from user form

아바타
취소
베스트 답변

Hi,

You can check with "_update_user_groups_view"  function in the res_users.py (base -> res -> res_users.py ).

To hide your group,

field_name = name_boolean_group(g.id)
group_no_one = view.env.ref('base.group_no_one')
your_grp = view.env.ref('module_name.group_name')
if g == group_no_one or g == your_grp:
# make the group_no_one invisible in the form view
xml2.append(E.field(name=field_name, invisible="1", **attrs))
else:
xml2.append(E.field(name=field_name, **attrs))

This is the relevant part of the original code.


UPDATE:

In latest versions, see:https://www.youtube.com/watch?v=zbeBTImPKUw



Thanks

아바타
취소

I tested it in the original code. and its work fine.

작성자

when the function is calling.. i think during create, write and unlink of groups. Then how it will work for existing groups

The function will get called during the create, write and unlink of the model res.groups. IT will affect the all groups , not only newly creating group.

Hello @Niyas Raphy,

Can you please help me inherit this method and hide the group "Use products on vendor bills" from the account module?

Thank you in advance

I saw this too, hoped there would be other way than to duplicate 100lines function just to change 2 lines.

베스트 답변

you can simply create an invisible security category as following

<record model="ir.module.category" id="category_id>
<field name="name">Hidden Category</field>
<field name="visible" eval="0" />
</record> All the security groups that belongs to this category wouldn't be visible to the users
아바타
취소

doesn't work for me with odoo 13. it creates a new category named `hidden category` and the groups still appear on the user form

베스트 답변

Hii,

class ResGroups(models.Model):
_inherit = 'res.groups'


def get_application_groups(self, domain):
sale_receipt_id = self.env.ref('account.group_sale_receipts').id
return super(ResGroups, self).get_application_groups(domain + [('id', '!=', sale_receipt_id)])

Thanks


아바타
취소

I tried on v14 but it didn't work. Do you have a solution?

베스트 답변

 If hiding the whole category works for you,


def_get_hidden_extra_categories(self):

return ['base.module_category_hidden','base.module_category_extra','base.module_category_usability']

You can override this function in res.groups and add your group category to this function so that it will only be visible to base.group_no_one

아바타
취소