Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet

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
Verwerfen
Beste Antwort

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
Verwerfen
Beste Antwort

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
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
0
Juli 23
1758
3
Aug. 23
2986
2
Juli 23
2726
3
Feb. 23
11540
1
Jan. 23
5070