Hi,
we use odoo 9 community,
I want import field category(many2many) in product.template, but if cloumn category containing comma not working.
python code:
@api.multi
def import_file(self):
file = StringIO.StringIO(base64.decodestring(self.file))
reader = csv.reader(file, delimiter=',')
csv.field_size_limit(sys.maxsize)
skip_header = True
for row in reader:
if skip_header:
skip_header = False
continue
product = row[0]
categ_ids = row[1]
if product:
product_obj = self.env['product.template']
product_id = product_obj.search([('id', '=', product)])
product_public_obj = self.env['product.public.category']
public_categ_id = product_public_obj.search([('id', '=', categ_ids)])
if product_id and public_categ_id:
product_id.write({'public_categ_ids': [(4,int(categ_ids) )] })
In this code, if the column category does not have a comma , it will work.
file example:
id:1 categ_ids : 25,26,37
but by comma not working: (IndexError: list index out of range)