Odoo Help


2 Answers

Parth Gajjar India

--Parth Gajjar--

| 4 4 7
Gandhinagar, India
--Parth Gajjar--

Parth Gajjar India
3/28/13, 10:14 AM

Return List of Dictionary In Onchange of your field

Inside your onchange_division function do this kind of thing

        //first pool your worker object
    w_ids=your_pooled_worker_object.search(cr, uid ,"your search condition")
    for w_id in w_ids:
        list_of_dict.append({"your worker one2many field name":w_id})
    return {'value': {"selected_tea_workers_update_line_ids":list_of_dict}}

This will works 100% sure :p Hope this will work

Try This One

def on_change_division(self, cr, uid, ids, division_id, context=None):
    worker_ids=worker.search(cr, uid, [("bpl_division_id","=", division_id)])
    for worker_id in worker_ids:
    return {'value': {"selected_tea_workers_update_line_ids":list_of_dict}}
1 Comment
priyankahdp Sri Lanka
3/28/13, 10:51 AM

@parth, thanks Parth. i changed my function.but another error occur. can u please see my updated class & view.xml from this location & advice me to sort this out.. https://github.com/priyankahdp/openerp

[post updated]


Andreas Brueckl Austria

--Andreas Brueckl--

| 8 8 9
Vienna, Austria
--Andreas Brueckl--
OpenERP Consulting and Development
Andreas Brueckl Austria
3/27/13, 11:06 AM

Try to return the following in your function onchange_division:

def onchange_division(self, cr, uid, ids, division_id, context=None):
    res = {}
    if division_id:
        res['domain'] = {'selected_tea_workers_line_ids': [('bpl_division_id','=', division_id)]}
    return res

For further information regarding the onchange functionality see the developer docu.

This sets a domain for field selected_tea_workers_line_ids in the view and the view should then limit the records according to this domain. But then the domain is only valid if you have changed the division explicitly. I am not 100% sure whether this works in your case but you can try it.

If it does not work you can take a look to the following question:


priyankahdp Sri Lanka
3/27/13, 12:28 PM

Thanks Andreas.i'm confused with how to code that in view.xml file.can give me a suggestion please

Andreas Brueckl Austria
3/27/13, 12:29 PM

You only have to update your onchange_division function, not the view.

priyankahdp Sri Lanka
3/27/13, 1:19 PM

then which field i need to map.? 'selected_tea_workers_line_ids' ?

priyankahdp Sri Lanka
3/27/13, 2:52 PM

no error comes but data not loading friend

Ask a Question
Keep Informed
0 follower(s)
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