Skip to Content
Menu
This question has been flagged
1195 Views

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)
Avatar
Discard
Related Posts Replies Views Activity
3
Oct 23
5973
1
Sep 23
1963
1
May 23
1001
2
Apr 23
1374
1
Mar 23
996