diff --git a/beesdoo_product/__openerp__.py b/beesdoo_product/__openerp__.py index dfee764..ac8eb60 100644 --- a/beesdoo_product/__openerp__.py +++ b/beesdoo_product/__openerp__.py @@ -20,12 +20,13 @@ 'version': '0.1', # any module necessary for this one to work correctly - 'depends': ['beesdoo_base', 'product', 'point_of_sale'], + 'depends': ['beesdoo_base', 'product', 'point_of_sale','pos_price_to_weight'], # always loaded 'data': [ 'data/product_label.xml', 'data/barcode_rule.xml', + 'data/product_sequence.xml', 'views/beesdoo_product.xml', 'wizard/views/label_printing_utils.xml', 'security/ir.model.access.csv', diff --git a/beesdoo_product/data/product_sequence.xml b/beesdoo_product/data/product_sequence.xml new file mode 100644 index 0000000..59ce1be --- /dev/null +++ b/beesdoo_product/data/product_sequence.xml @@ -0,0 +1,14 @@ + + + + + Internal reference + product.internal.code + + 5 + + 1 + + + + \ No newline at end of file diff --git a/beesdoo_product/models/beesdoo_product.py b/beesdoo_product/models/beesdoo_product.py index a9397ed..858ac32 100644 --- a/beesdoo_product/models/beesdoo_product.py +++ b/beesdoo_product/models/beesdoo_product.py @@ -26,7 +26,7 @@ class BeesdooProduct(models.Model): label_last_printed = fields.Datetime('Label last printed on') note = fields.Text('Comments') - + # S0023 : List_price = Price HTVA, so add a suggested price list_price = fields.Float(string='exVAT Price') suggested_price = fields.Float(string='Suggested exVAT Price', compute='_compute_cost', readOnly=True) @@ -36,15 +36,28 @@ class BeesdooProduct(models.Model): @api.one def generate_barcode(self): - print 'generate barcode', self.barcode, self.barcode == '' - rule = self.env['barcode.rule'].search([('name', '=', 'Beescoop Product Barcodes')])[0] - size = 13 - len(rule.pattern) - ean = rule.pattern + str(uuid.uuid4().fields[-1])[:size] - bc = ean[0:12] + str(self.env['barcode.nomenclature'].ean_checksum(ean)) - # Make sure there is no other active member with the same barcode - while(self.search_count([('barcode', '=', bc)]) > 1): + 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 == '' + rule = self.env['barcode.rule'].search([('name', '=', 'Beescoop Product Barcodes')])[0] + size = 13 - len(rule.pattern) ean = rule.pattern + str(uuid.uuid4().fields[-1])[:size] bc = ean[0:12] + str(self.env['barcode.nomenclature'].ean_checksum(ean)) + # Make sure there is no other active member with the same barcode + while(self.search_count([('barcode', '=', bc)]) > 1): + ean = rule.pattern + str(uuid.uuid4().fields[-1])[:size] + bc = ean[0:12] + str(self.env['barcode.nomenclature'].ean_checksum(ean)) print 'barcode :', bc self.barcode = bc