Hello,
I´m importing with my own python code products and have the problem to update products, which are archived with barcodes.
snippet code:
for row in data['product']:
...
# check if product exists
product_tmpl_id = self.env['product.product'].search([('barcode', '=ilike', row['barcode'])], limit=1).product_tmpl_id
if not product_tmpl_id:
product_tmpl_id = self.env['product.product'].search([('barcode', '=ilike', row['barcode']), ('active', '=', False)], limit=1).product_tmpl_id
if not product_tmpl_id:
prod = self.env['product.template'].search([('default_code', '=ilike', row['internalReference'])], limit=1)
if not prod:
prod = self.env['product.template'].search([('default_code', '=ilike', row['internalReference']), ('active', '=', False)], limit=1)
else:
logger.info('###### found in second try id %s #######' % product_tmpl_id)
prod = self.env['product.template'].browse(product_tmpl_id)
else:
logger.info('###### found in first try id %s #######' % product_tmpl_id)
prod = self.env['product.template'].browse(product_tmpl_id)
I want to search first, if a product in products.products with Barcode exists.
If yes, he should load the product from product.template
If not, he should check if archived and load then the correct product
if not, he should check for default_code
But this is not working.
How