Commit 71466100 by François C.

Add barcode rules to take multibarcodes into account

parent 6a11389e
Pipeline #2556 passed with stage
in 2 minutes 8 seconds
...@@ -536,6 +536,17 @@ class CagetteProducts(models.Model): ...@@ -536,6 +536,17 @@ class CagetteProducts(models.Model):
result['aliases'][alias_bc] = r['alias'] result['aliases'][alias_bc] = r['alias']
elif '{' in r['pattern'] or '.' in r['pattern']: elif '{' in r['pattern'] or '.' in r['pattern']:
result['patterns'].append(r) result['patterns'].append(r)
if getattr(settings, 'WITH_MULTI_BARCODE_ODOO_MODULE', False):
multi_barcodes = OdooAPI().search_read('product.multi.barcode', [],['product_id', 'barcode'])
product_ids = []
product_barcodes = {}
for mb in multi_barcodes:
product_ids.append(mb['product_id'][0])
products = OdooAPI().search_read('product.product', [['id', 'in', product_ids]],['barcode'])
for p in products:
product_barcodes[p['id']] = p['barcode']
for mb in multi_barcodes:
result['aliases'][mb['barcode']] = product_barcodes[mb['product_id'][0]]
except Exception as e: except Exception as e:
result['error'] = str(e) result['error'] = str(e)
coop_logger.error("Get Barcode Rules : %s", str(e)) coop_logger.error("Get Barcode Rules : %s", str(e))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment