Skip to Content
Menu
This question has been flagged
2167 Views

Hello,

I have a table named "miadi.poidsconditionnement" :

class miadi_poidsConditionnement(models.Model):
_name = 'miadi.poidsconditionnement'
conditionnement_id = fields.Many2one('miadi.packaging', 'Packaging', default='', required=True)
produit_id = fields.Many2one('product.product', 'Product', default='', required=True, ondelete='cascade')
nb_articles = fields.Integer(string='Number of products', default=0)
poids = fields.Float(string='Packaging Weight', default=0)

_sql_constraints = [
('uniq_id', 'unique(produit_id, conditionnement_id)', 'A product already exists with this packaging !'),
]

In this table, I have some records depends of the number of products variants (product.product) and the number of records in another table (miadi.packaging) --> Check the two fields Many2one.

Example : If I have 40 products variants (product.product) and 2 records in miadi.packaging, I will have 80 records in the miadi.poidsconditionnement table (each packaging with each product variant).


If you understand this, you should be able to help me because what I want is to create a page (named Packaging) in product variants form view and in this page, I want to display a tree view with records took in the "miadi.poidsconditionnement" table for the product where I'm in the form view.

Example :

If I go to the product variant "iPod (16Go)", when I go to my created page, I want to have a treeview with all the records that they are in the miadi.poidsconditionnement table for the product "iPod(16Go)".

If I go to the product variant "iMac", when I go to my created page, I want to have a treeview with all the records that they are in the miadi.poidsconditionnement table for the product "iMac". 

PS : I'm on Odoo 10.


Thanks for answers.

Avatar
Discard