Odoo Help


how return 3 value in one function?

on 5/15/16, 12:30 AM 657 views


I write this function in account voucher module :



def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id, amount, currency_id, ttype, date,section_id, context=None):

     if not journal_id:

         return {}

     res = self.recompute_voucher_lines(cr, uid, ids, partner_id, journal_id, amount, currency_id, ttype, date, context=context)

     vals = self.recompute_payment_rate(cr, uid, ids, res, currency_id, date, ttype, journal_id, amount, context=context)

     for key in vals.keys():


     return res

     section_id = False

     if partner_id:

          section_id = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context).section_id.id

     return {'value': {'section_id' : section_id}}


but when I test it,

also 'for loop' is run. and 'if partner_id' doesn't run. I don't know what is problem?

I think problem is that I don't know haw can return multi value in one function.?!!


please include which version(v7,v8orv9) are you using?

Baiju KS
on 5/15/16, 3:26 AM

Bejaoui Souheil

--Bejaoui Souheil--
--Bejaoui Souheil--

Odoo developer,  functional and technical consultant


Bejaoui Souheil
On 5/16/16, 9:20 AM


Python ignore the code after "return res".

     for key in vals.keys():


     return res #check where to put this line

     section_id = False

     if partner_id:

Thats why

'for loop' is run. and 'if partner_id' doesn't run

hi yes, I know this problem is from 'return res'. but I don't know how can edit this code that resolve the problem? :( can you help me? Thanks

on 5/17/16, 12:30 AM

Baiju KS

--Baiju KS--
| 5 5 8
Kochi, India
--Baiju KS--
ODOO technical

        I like learning new thing, especially technical thing. I am a quick learner, I can learn technical things very fast. I have good logical skill,  I have immense interest in programming.

e-mail id : baijuks@hotmail.com

Baiju KS
On 5/15/16, 4:14 AM

Hi Nasim,

You are using old API.

onchange method in old API should return a dictionary in following format :-  Eg:


'warning': {'Your Message'},

'value': {'field_name1': VALUE , 'field_name2': VALUE, 'field_name3': VALUE}


Hope this helps.

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: 5/15/16, 12:30 AM
Seen: 657 times
Last updated: 5/16/16, 9:20 AM