product_usability: add support for GTIN-14 in barcode type
This commit is contained in:
@@ -29,12 +29,15 @@ class ProductProduct(models.Model):
|
|||||||
@api.model
|
@api.model
|
||||||
def _get_barcode_type(self, barcode):
|
def _get_barcode_type(self, barcode):
|
||||||
barcode_type = False
|
barcode_type = False
|
||||||
|
size2label = {
|
||||||
|
8: 'EAN-8',
|
||||||
|
13: 'EAN-13',
|
||||||
|
14: 'GTIN-14',
|
||||||
|
}
|
||||||
if barcode:
|
if barcode:
|
||||||
size = len(barcode)
|
size = len(barcode)
|
||||||
if size == 13 and is_valid(barcode):
|
if size in size2label and is_valid(barcode):
|
||||||
barcode_type = 'EAN13'
|
barcode_type = size2label[size]
|
||||||
elif size == 8 and is_valid(barcode):
|
|
||||||
barcode_type = 'EAN8'
|
|
||||||
return barcode_type
|
return barcode_type
|
||||||
|
|
||||||
@api.depends('barcode')
|
@api.depends('barcode')
|
||||||
|
|||||||
Reference in New Issue
Block a user