Community mailing list archives

community@mail.odoo.com

Re: cache gone with sudo()

by
Andre Kurniawan
- 05/18/2016 04:42:44
Hello Holger,

I'll try your suggestion with `compute_sudo`. Thank you.

On 05/18/2016 03:22 PM, Holger Brunn wrote:
> > I want to fetch some fields from related field, for example:> |record.new_field = record.relation1_id.this_field|, since the model 
> for > |relation1_id| have some other relation fields that have no 
> security > access for the current user.
>
> just some relation field that's not accessible on the record shouldn't
> prevent you from accessing other ones, so if it's only that, you don't
> need sudo at all.
>
> If you need to go through some chain where you indeed don't have access
> with the current user, say compute_sudo=True on the field definition, or
> do something like
>
>
> record.new_field = self.env['new.field.model'].browse(
>      self.env['relation1_id.model'].sudo()
>      .browse(record.relation1_id.ids).this_field.ids
> )
> -- Therp - Maatwerk in open ontwikkeling Holger Brunn - Ontwerp en 
> implementatie mail: holger@therp.nl web: http://therp.nl phone: +31 
> (0)20 3093096
>
>
> _______________________________________________
> Mailing-List: https://www.odoo.com/groups/community-59
> Post to: mailto:community@mail.odoo.com
> Unsubscribe: https://www.odoo.com/groups?unsubscribe
>
>
>
>


-- 
Regards,
Andre