openerp-community team mailing list archive
-
openerp-community team
-
Mailing list archive
-
Message #06822
Re: Reclaiming context
On 28/08/2014 18:04, Sandy Carter wrote:
> Hello community,
>
>
> While debugging yet another translation error in Odoo 7.0, I came up
> with a simple way to reclaim lost contexts in functions.
>
> The bug I was fighting is one where workflow actions do not pass any
> contexts. This bug manifests as chattr messages in english when using
> the workflows.
>
> As I don't have the time to fix it in the server, nor am I ready to jump
> through the hoops to get that fix integreated in the Odoo, I found a way
> to fix this bug in my module.
>
> The way I countered the bug in my module is in the write function where
> I would usually start with
>
> if context is None:
> context = {}
>
> or
>
> context = context or {}
>
> In this case it was None since the workflow mechanism would not have a
> context. I saw that since I have the user id, I can still get the
> context for this user.
>
> I replaced the familiar context check with:
>
> context = context or self.pool['res.users'].context_get(cr, uid)
>
Ideally this would be done by the workflow engine, but I'm pretty sure
this won't make it to official 7.0 and not sure for OCB. But I do like
the version you propose *a lot*. Let's use it more!
--
Alexandre Fayolle
Chef de Projet
Tel : + 33 (0)4 79 26 57 94
Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac Cedex
http://www.camptocamp.com
Follow ups
References