I am trying to create products directly from code but i am getting this error when doing so.
cls._inherits.update(base._inherits)
ValueError: dictionary update sequence element #0 has length 1; 2 is required
This error goes away when removing the line which inherits product.template
but i need to inherit it anyway to create products directly from code.
here is the code-
from odoo import api,fields,models
class test_custom(models.Model):
_name='test.info'
_inherits='product.template'
mobile_number=fields.Integer(String='mobile')
@api.multi
def order_to_odoo(self):
category_record = self.env['product.public.category']
record_category = category_record.search([])
print record_category
for i in record_category:
if i.name=='room':
category_id=i.id
print "found",type(category_id),"found"
internal_category_record = self.env['product.category']
record_internal_category = internal_category_record.search([])
print record_internal_category
for i in record_internal_category:
if i.name=='All':
internal_category_id=i.id
print "foundinternal", internal_category_id, "foundinternal"
valsproduct = {'name': "new product",
'public_categ_ids': [(0,0,[category_id])],
'categ_id': internal_category_id
}
print valsproduct
super(test_custom, self).create(valsproduct)
here i selected already available records as category_id and internal category .