Odoo Help


Pb with onchange function

on 3/30/16, 4:27 AM 772 views


I have used onchange to add a new field in the invoice line the pb when I click on save it return to zero

here is my code:

def product_id_change(self, cr, uid, ids, product, uom_id, qty=0, name='', type='out_invoice',

partner_id=False, fposition_id=False, price_unit=False, currency_id=False,

company_id=None, context=None):

res = super(invoice_line, self).product_id_change(cr, uid, ids, product, uom_id, qty=qty, name=name, type=type, partner_id=partner_id,fposition_id=fposition_id, price_unit=price_unit, currency_id=currency_id, company_id=company_id, context=context)

for product_data in self.pool.get('product.product').browse(cr, uid,[product], context=context):

if res:


return res

'available_quantity' : fields.float('Quantité disponible',readonly=True),

Could you help me to figure out what is the pb ???

Nilesh Sheliya
On 3/31/16, 4:31 AM

The value of available_quantity field is not changed because it is readonly. If field is readonly, then we can't set value of that field in onchange.

If you want to change value of readonly field in onchange, then install module web_readonly_bypass. You can download it from link : https://apps.openerp.com/apps/modules/8.0/web_readonly_bypass/

By Installing this module and setting parameter as per explain in module, you can change the value of readonly field in onchange method.


About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 3/30/16, 4:27 AM
Seen: 772 times
Last updated: 6/8/16, 4:10 AM