context dict in fields and window actions

Asked by vrsb

Hello.
I try do display product name different ways in some different views.
In name_get i have something like:
if context.get('only_code'):
  name=d['variants']

It works well when i add conext to window action:
<act_window
            ........
            res_model="product_product"
            context="{'only_code': True}" />

I wonder, why doesn't it work when adding context to a field(where i want do display variant) of the list view?
<field name="product_id" context="{'only_code': True} "/>

Question information

Language:
English Edit question
Status:
Answered
For:
Odoo Server (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Quentin THEURET @Amaris (qtheuret) said :
#1

Hello,

It doesn't work on the second case because the context is send to the
function when you click on the field 'product_id' !

On the first case, the context is send to the view when the view is
created. To more understant how it works, try to override the
fields_view_get method of the 'product.product' object.

P.S : On your act_window, res_model isn't 'product_product', but
'product.product' !

Quentin THEURET
<email address hidden>
06 33 23 20 84

Le 04/02/2011 07:45, vrsb a écrit :
> Question #144051 on OpenERP Server changed:
> https://answers.launchpad.net/openobject-server/+question/144051
>
> Description changed to:
> Hello.
> I try do display product name different ways in some different views.
> In name_get i have something like:
> if context.get('only_code'):
> name=d['variants']
>
> It works well when i add conext to window action:
> <act_window
> ........
> res_model="product_product"
> context="{'only_code': True}" />
>
> I wonder, why doesn't it work when adding context to a field(where i want do display variant) of the list view?
> <field name="product_id" context="{'only_code': True} "/>
>

Can you help with this problem?

Provide an answer of your own, or ask vrsb for more information if necessary.

To post a message you must log in.