Odoo Help

Welcome!

This community 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.

0

Pb with onchange function

By
Jihen BEN ALI
on 3/30/16, 4:27 AM 336 views

Hi,

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:

res['value'].update({available_quantity':product_data.qty_available})

return res

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

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

0
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.

 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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