Hello,
In a module that I've created (class miadi_packaging), I want to do take the name and the variants of a product which is in the product.product table.
I want to have in result : "iPod (16Go)" and iPod (32Go)".
I've tried two things but foreach, I haven't the result that I want.
First way :
productVariants = self.env['product.product']
products = productVariants.search([])
for rec in products:
nom_produit = rec.name
#Do something with the nom_produit
But this way gives me : "iPod" and "iPod" (without the variants but it gives me as many times the product that there are variants for this product)
The second way is :
produits = self._cr.execute("SELECT name FROM product_template")
for produits in self.env.cr.dictfetchall():
nom_produit = produits['name']
#Do something with nom_produit
But this way gives me : "iPod" (without the variants and it gives me only once the product, even if there are variants for this product).
How can I get the name of the product and his variants please ?
Thanks for answer