Odoo Help


Odoo 8 - wizard not showing one2many elements

Salim Rahal
on 11/16/16, 10:35 AM 874 views

I'm trying to populate a one2many relationship in a Wizard, the wizard contains a reference one2many to product categories(a Model). The Scenario is when I open the Wizard and I hit on a button (fill_product_category) it fill the list of product category in the tree view.

Hitting the button will build a list of product category in Backend and then assign it to the Wizard

The result is that only the first element of product category list is rendered in the wizard, whereas the others are not rendered. My code shows two static product categories but only the first one is rendered.

I need to show all the list what I should do?

thank you

1- The Wizard includs one2many relationship


  class wizard(models.TransientModel):

    _name = 'simulator.wizard'

    y_product_category_disc_ids = fields.One2many("category.model", "id",string="Product Category")

  class CategoryModel(models.Model):

       _name = "category.model"

        y_product = fields.Char(string="Product Cat",readonly=True)


2- Snippet of the Wizard Data file

       <field name="y_product_category_disc_ids"> <tree string="Product Category Tree"> <field name="y_product"/> </tree>

       </field> <button name="fill_product_category" string="Fill product category" type="object" />

3- function that handle the button fill_product_category

@api.multi def fill_one2many(self):


    res_record1 = self.env["purchase.product.categorydisc"].\

create({"y_product": p1 })

res_record2 = self.env["purchase.product.categorydisc"].\

create({"y_product": p2 })



self.y_product_category_disc_ids = listProdIds

return {

'context': self.env.context,

'view_type': 'form',

'view_mode': 'form',

'res_model': 'simulator.wizard',

'res_id': self.id, 'view_id': False,

'type': 'ir.actions.act_window',

'target': 'new',


p1 and p2 are variables or string values?

Axel Mendoza
on 11/16/16, 2:44 PM

p1 and p2 are String

Salim Rahal
on 11/16/16, 3:57 PM

Axel Mendoza

--Axel Mendoza--
| 7 8 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full-time employee trying to understand what to do and how

Reach me at aekroft@gmail.com

Axel Mendoza
On 11/16/16, 2:41 PM

You need to use a Many2many field because One2many fields need a Many2one relation field to the current model in the target model of the One2many. With Many2Many fields you remove that contraints  

yes it works with many2many relation and the tree view of the sub elements is rendered. note that I couldn't define the two way references of many2one and one2many because a Model (e.g. CategoryModel) cannot define a reference to a Tranient Model, but a transient model can do it. any way thank you @Axel

Salim Rahal
on 11/16/16, 4:46 PM

Please then upvote the answer to help others

Axel Mendoza
on 11/16/16, 5:36 PM

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: 11/16/16, 10:35 AM
Seen: 874 times
Last updated: 11/16/16, 4:46 PM