I'm trying to create a product bundle(creating a list of products inside a product) using one2many-many2one relation,
everything works fine no compiling errors while running the server but in product form view when i add a
new product
in the list an error pops:
ValueError: Wrong value for product.template.type: 'product'
here is my 2 models:class Product(models.Model):
_inherit = 'product.template'
puissance = fields.Integer(string='Puissance(W)')
categ_name = fields.Char(string ='category name',related='categ_id.name')
is_bundled = fields.Boolean(string='Est un ensemble de produits',default=False)
product_ids = fields.One2many('product.bundle', 'ref_id', string="Ensemble Produits")
class Bundle(models.Model):
_name="product.bundle"
_description="adds products bundle "
ref_id = fields.Many2one('product.template',string='Nom article', domain=[('sale_ok', '=', True)])
qty = fields.Integer('Quantité', default=1)
price_unit = fields.Float('Prix unitaire', related='ref_id.list_price')
remise = fields.Integer('Remise %')
price_htva = fields.Float('Prix TT HTVA', compute='_calcul_prix')
@api.depends('qty', 'price_unit', 'remise')
def _calcul_prix(self):
for rec in self:
rec.price_htva = (qty*price_unit) - (((qty*price_unit)*remise)/100)