Skip to Content
Menu
This question has been flagged
1 Reply
3137 Views

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 .



Avatar
Discard
Best Answer

Hello Abhijith,

Instead of inherits='product.template' replace by inherit='product.template'


Regards,

Mayank Gosai

Avatar
Discard
Related Posts Replies Views Activity
2
Nov 24
25064
2
May 24
5512
3
Mar 24
4961
0
Mar 24
261
3
Feb 24
11415