← Back to team overview

openerp-community team mailing list archive

Re: how to access context in my own method/function?

 

Don't expect the string argument to be dynamically executed, because you
provided the argument "2" the function is actually executed when the module
is first loaded and thus the string is static (won't be executed more than
once per database)

You should override the fields_view_get method on your object, see the
documentation here :
http://doc.openerp.com/v6.0/developer/2_5_Objects_Fields_Methods/methods.html#osv.osv.osv.fields_view_get
There you have access to both the context and are allowed (even expected)
to return the view definition to be used by the client.

Regards,
Niels

2011/12/19 Martin Herweg <m.herweg@xxxxxx>

>
> Hi!
>
> I'm using fields.function in a tree view:
>
>  _columns = {
>  'qty2_test' : fields.function(_calc_price, arg=2 , type = 'float', method
> =
> True, string = _get_qty(2) ),
>
>
> in "_calc_price" it is no problem to access the context:
>
> def _calc_price(self, cr, uid, ids, field, arg, context=None):
>        form = context['form']
>
>
> but how can I do it in "_get_qty"  ?
>
> my goal ist to have different healines/labels for the colums depending on
> the
> context.
>
>
> thank you for any help & hints,
>
> Martin
>
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~openerp-community
> Post to     : openerp-community@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~openerp-community
> More help   : https://help.launchpad.net/ListHelp
>



-- 
Niels Huylebroeck
Lead Architect   --   Agaplan
Tel. : +32 (0) 93 95 98 90
Web : http://www.agaplan.eu

Follow ups

References