Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
2 Besvarelser
2485 Visninger

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! 

Avatar
Kassér
Bedste svar

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)

Avatar
Kassér
Bedste svar

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

Avatar
Kassér
Related Posts Besvarelser Visninger Aktivitet
0
jul. 23
1758
3
aug. 23
2986
2
jul. 23
2726
3
feb. 23
11540
1
jan. 23
5070