Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
2472 Lượt xem

Hi, i'm trying to set the possibility for my internal users to create anonymous claims, but I can always see who created the record through metadatas with the developers mode activated.


How can I hide this fields? Or how can I override these?


I tried with this code, I override the create method, but it's not working:


@api.model  

defcreate(self, vals):

        res = super(HrComplaint, self).create(vals)
    
        res.write({'create_uid': 13})


        return res


any suggestion would be really appreciated, thanks in advance! 

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

I would suggest:

- Create an user for that in your Odoo and give that user the needed permissions

- Extend the create method and force that user to be the creator, like:

res = super(HrComplaint, self).with_user().create(vals)

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

To hide the 'create_uid' field, you can override the 'fields_get' method of the model and remove it from the returned fields. 

class HrComplaint(models.Model):
_inherit = 'hr.complaint'

@api.model
def fields_get(self, allfields=None, attributes=None):
res = super(HrComplaint, self).fields_get(allfields=allfields, attributes=attributes)
if not self.env.user.has_group('base.group_system'):
# Remove the create_uid field for non-system users
res.pop('create_uid', None)
return res


In this 'fields_get' method of the 'hr.complaint' model and remove the 'create_uid' field from the returned fields if the current user is not a member of the 'base.group_system' group.


Hope this will help you
Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 7 23
1756
3
thg 8 23
2981
2
thg 7 23
2725
3
thg 2 23
11536
1
thg 1 23
5059