Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
2482 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona
Risposta migliore

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
0
lug 23
1756
3
ago 23
2984
2
lug 23
2726
3
feb 23
11539
1
gen 23
5067