Odoo Help


How to use Onchange function in one2many

Swalih muhammed
on 6/27/14, 1:34 AM 1,083 views

class order_details(osv.osv):
              'name':fields.char('Name of Customer'),
class order_details_line(osv.osv):
    def onchange_name(self, cr, uid, ids,name_id, context=None):
        res = {}
        if name_id:
            dish = self.pool.get('dish.dish')
            dish_obj=dish.browse(cr, uid,name_id, context=context)
            res['value'] = {'o_chef':dish_obj.d_chef.id,'o_category':dish_obj.d_category.id, 'o_price': dish_obj.d_price,}
        return res
    def _get_total(self, cr, uid, ids, fields, args, context=None):
        ttl = {}
        for x in self.browse(cr, uid, ids, context=context):
                ttl[x.id]['o_total'] = x.o_price - x.o_discount
        return ttl
             'name_id':fields.many2one('dish.dish','Name of Dish'),
             'o_chef':fields.many2one('chef.chef','Name of Chef'),
             'o_total':fields.function(_get_total, string='Total', type='float', multi="o_total",store=True),



This is my code.here the  "def onchange_name" function is not working.give me a solutions

What problem you facing ?

Jagdish Panchal
on 6/27/14, 1:40 AM

Jagdish Panchal

--Jagdish Panchal--
Jagdish Panchal
| 5 4 6
Gandhinagar, India
--Jagdish Panchal--

OpenERP Developer

Jagdish Panchal
On 6/27/14, 1:44 AM


Refere this link may help you


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 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: 6/27/14, 1:34 AM
Seen: 1083 times
Last updated: 3/16/15, 8:10 AM