Browse Source

[IMP] implement barcode generation for price to weight barcode module of

la louve
pull/16/head
houssine 8 years ago
parent
commit
d405574c58
  1. 3
      beesdoo_product/__openerp__.py
  2. 14
      beesdoo_product/data/product_sequence.xml
  3. 13
      beesdoo_product/models/beesdoo_product.py

3
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',

14
beesdoo_product/data/product_sequence.xml

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="seq_ean_product_internal_ref" model="ir.sequence">
<field name="name">Internal reference</field>
<field name="code">product.internal.code</field>
<field name="prefix"></field>
<field name="padding">5</field>
<field name="suffix"></field>
<field name="number_next">1</field>
<field name="barcode_sequence" eval="True"/>
</record>
</data>
</odoo>

13
beesdoo_product/models/beesdoo_product.py

@ -36,6 +36,19 @@ class BeesdooProduct(models.Model):
@api.one
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 == ''
rule = self.env['barcode.rule'].search([('name', '=', 'Beescoop Product Barcodes')])[0]
size = 13 - len(rule.pattern)

Loading…
Cancel
Save