|
@ -36,6 +36,19 @@ class BeesdooProduct(models.Model): |
|
|
|
|
|
|
|
|
@api.one |
|
|
@api.one |
|
|
def generate_barcode(self): |
|
|
def generate_barcode(self): |
|
|
|
|
|
if self.to_weight: |
|
|
|
|
|
print 'generate to weight barcode', self.barcode, self.barcode == '' |
|
|
|
|
|
seq_internal_code = self.env.ref('beesdoo_product.seq_ean_product_internal_ref') |
|
|
|
|
|
bc = '' |
|
|
|
|
|
if not self.default_code: |
|
|
|
|
|
rule = self.env['barcode.rule'].search([('name', '=', 'Price Barcodes (Computed Weight) 2 Decimals')])[0] |
|
|
|
|
|
default_code = seq_internal_code.next_by_id() |
|
|
|
|
|
while(self.search_count([('default_code', '=', default_code)]) > 1): |
|
|
|
|
|
default_code = seq_internal_code.next_by_id() |
|
|
|
|
|
self.default_code = default_code |
|
|
|
|
|
ean = '02' + self.default_code[0:5] + '000000' |
|
|
|
|
|
bc = ean[0:12] + str(self.env['barcode.nomenclature'].ean_checksum(ean)) |
|
|
|
|
|
else: |
|
|
print 'generate barcode', self.barcode, self.barcode == '' |
|
|
print 'generate barcode', self.barcode, self.barcode == '' |
|
|
rule = self.env['barcode.rule'].search([('name', '=', 'Beescoop Product Barcodes')])[0] |
|
|
rule = self.env['barcode.rule'].search([('name', '=', 'Beescoop Product Barcodes')])[0] |
|
|
size = 13 - len(rule.pattern) |
|
|
size = 13 - len(rule.pattern) |
|
|