on_change event does not pass context to the method!

Bug #537858 reported by Dharmesh PATEL@Axelor SARL
26
This bug affects 5 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Won't Fix
Low
Unassigned
Nominated for Extra-trunk by Numérigraphe
Nominated for Trunk by Numérigraphe
Odoo GTK Client (MOVED TO GITHUB)
Won't Fix
Low
Unassigned
Odoo Server (MOVED TO GITHUB)
Won't Fix
Low
Unassigned
Odoo Web Client
Won't Fix
Low
Unassigned

Bug Description

I wrote on_change event on product_id field in my object form to fill up another 'Description' field value with product name but what I notice it product name can not fetch according to language selected in preferences it fetch only English name.

    def onchange_product_id(self, cr, uid, ids, product_id, context={}):
        res = {'desc': ''}
        if product_id:
            product = self.pool.get('product.product').read(cr, uid, product_id, ['name'], context)
            res['desc'] = product['name'] and product['name'] or ''
        return {'value':res}

I also try to print context which I passed in 'onchange_product_id' and its print blank dictionary and there for it can not pass in product object's read method and product name cant fetch according to context language.

Revision history for this message
Dharmesh PATEL@Axelor SARL (dpa-axelor) wrote :

I am using latest stable version

Revision history for this message
Numérigraphe (numerigraphe) wrote : Re: [Bug 537858] Re: context not pass in on_change event

If I'm not misunderstanding, I'm afraid you can't fix this bug without
fixing that one first:
https://bugs.launchpad.net/openobject-addons/+bug/535174
And I suspect there are plenty of other similar bugs.
Lionel

Revision history for this message
Numérigraphe (numerigraphe) wrote : Re: context not pass in on_change event

On a side note, I humbly suggest you use None as a default context as stated in https://bugs.launchpad.net/openobject-server/+bug/525808.
Lionel

Revision history for this message
Stephane Wirtel (OpenERP) (stephane-openerp) wrote :

The default value of the context argument in the declaration of the function must be None.

I confirm this point !

We will refuse the future code with context={} or any others variables.

summary: - context not pass in on_change event
+ on_change event does not pass context to the method!
Revision history for this message
Stephane Wirtel (OpenERP) (stephane-openerp) wrote :

Hi all,

I disagree with this feature request for the stable version.

Why.
1. Add the support of the context in the framework
2. Add the support of the context in the clients (Web and GTK, and KOO (maybe))
3. If we want to pass the context to the on_change function, we have to change the other "on_change" functions in the entire code of OpenERP addons/extra-addons

Changed in openobject-server:
milestone: none → 6.0
status: New → Confirmed
Revision history for this message
Numérigraphe (numerigraphe) wrote :

I marked other bugs as duplicates of this one since you agree to make the change in the whole code base.
Interesting comments had already been posted on those bugs, please make sure you read them.
Lionel.

Changed in openobject-addons:
status: New → Confirmed
Changed in openobject-client-web:
status: New → Confirmed
Changed in openobject-client:
status: New → Confirmed
Revision history for this message
Stephane Wirtel (OpenERP) (stephane-openerp) wrote :

Lionel,

I confirm for Trunk, not for stable.

tfr (Openerp) (tfr)
Changed in openobject-client:
importance: Undecided → Wishlist
importance: Wishlist → Undecided
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

I propose to drop this request for 6.0, as it's out of the scope and would imply a risky refactoring of all addons.
Instead, we plan to implement a better and more extensible mechanism for on_change parameters after v6.0, and it makes sense to do this at the same time. This is part of the product backlog post-v6, so it won't be forgotten.

Changed in openobject-addons:
importance: Undecided → Low
status: Confirmed → Won't Fix
Changed in openobject-client:
importance: Undecided → Low
status: Confirmed → Won't Fix
Changed in openobject-server:
importance: Undecided → Low
status: Confirmed → Won't Fix
Changed in openobject-client-web:
importance: Undecided → Low
status: Confirmed → Won't Fix
Revision history for this message
Hannes (Neobis) (nb2) wrote :

in 7.0 you have to add context as a parameter in the xml view field.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.