Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged

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
Opusti
Best Answer

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
Opusti
Best Answer

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
Opusti
Related Posts Odgovori Prikazi Aktivnost
0
jul. 23
1756
3
avg. 23
2984
2
jul. 23
2725
3
feb. 23
11539
1
jan. 23
5065