Odoo Help


how to write multiple value in dictionary ???

mihir shah
on 5/8/14, 12:46 PM 1,300 views

hi there

metal_vals = {'die_variant_id': []}

      for revision in die.die_line_id:
      for metal in revision.metal_lines:
          metal_vals['die_variant_id'] += [[0,0, {'revision_id': revision.id}]]
              metal_vals['die_variant_id'] += [[0,0, {'metal_id': metal.metal_id.id}]]

      self.write(cr, uid, [die.id], metal_vals, context=context)

i want to write both revision_id and metal_id in in same variable i.e metal_vals

What would be the proper syntax for the same

Could you be more specific? What kind of data structure do you have? What's up with the list of list with two zeros and a dict?

Miku Laitinen
on 5/8/14, 1:32 PM
On 5/8/14, 1:58 PM

you can create a list variable and add different elements to it inside the for loop like so

complete_list = []
for metal in revision.metal_lines:
    revision_list = [0,0, {'revision_id': revision.id}]
    metal_list = [0,0, {'metal_id': metal.metal_id.id}]
    group_list = [revision_list, metal_list]
    complete_list.append( group_list )

Then you can add the complete list to your dictionary variable like this:

metal_vals = { 'die_variant_id': complete_list }

Is this what you are looking for? Hope it helps

But group_list will print same thing i guess:

>> [[0, 0, {'revision_id': 1}], [0, 0, {'metal_id': 2}]]}

so again metal_vals={'die_variant_id': [[0, 0, {'revision_id': 1}], [0, 0, {'metal_id': 2}]]}

;-) ;-)

shashank verma
on 5/8/14, 2:08 PM
shashank verma
On 5/8/14, 1:40 PM


metal_vals has following O/P->

{'die_variant_id': [[0, 0, {'revision_id': 1}], [0, 0, {'metal_id': 2}]]}

So what exactly you wan to write ? you already have 2ids in your dictionary

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

0 follower(s)


Asked: 5/8/14, 12:46 PM
Seen: 1300 times
Last updated: 3/16/15, 8:10 AM