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

how return 3 value in one function?

By
nasim
on 5/15/16, 12:30 AM 270 views

hi

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():

          res[key].update(vals[key])

     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.?!!


Thanks

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

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

Bejaoui Souheil

--Bejaoui Souheil--
808
| 2 1 4
Sousse, Tunisia
--Bejaoui Souheil--

Odoo developer,  functional and technical consultant

souheil_bejaoui@hotmail.fr

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

Hi,

Python ignore the code after "return res".

     for key in vals.keys():

          res[key].update(vals[key])

     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

nasim
on 5/17/16, 12:30 AM
0

Baiju

--Baiju--
3154
| 5 4 8
Kochi, India
--Baiju--
ODOO technical and functional

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

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