def validate_barcode(self, barcode):
     bcc = getCodes()[self.get_barcode_format()](value=barcode[:-1])
     bcc.validate()
     bcc.encode()
     if bcc.encoded[1:-1] != barcode:
         raise ValidationError(_('CRC is not valid'))
     return barcode[:-1]
 def _recompute_barcode(self, barcode):
     if self.env['ir.config_parameter'].sudo().get_param(
             'stock_request_kanban.crc', default='1') == '0':
         return barcode
     bcc = getCodes()[self.get_barcode_format()](value=barcode[:-1])
     bcc.validate()
     bcc.encode()
     if bcc.encoded[1:-1] != barcode:
         raise ValidationError(_('CRC is not valid'))
     return barcode[:-1]
 def _recompute_barcode(self, barcode):
     if (self.env["ir.config_parameter"].sudo().get_param(
             "stock_request_kanban.crc", default="1") == "0"):
         return barcode
     if (self.env["ir.config_parameter"].sudo().get_param(
             "stock_request_kanban.ignore_crc", default="0") == "0"):
         bcc = getCodes()[self.get_barcode_format()](value=barcode[:-1])
         bcc.validate()
         bcc.encode()
         if bcc.encoded[1:-1] != barcode:
             raise ValidationError(_("CRC is not valid"))
     return barcode[:-1]
Beispiel #4
0
    def __init__(self, node, styles, value, encoding):
        Flowable.__init__(self)

        self.node = node
        self.styles = styles
        self.value = value
        self.encoding = encoding
        self.xpos = utils.unit_get(node.getAttribute('x'))
        self.ypos = utils.unit_get(node.getAttribute('y'))
        self.width = utils.unit_get(node.getAttribute('width'))
        self.height = utils.unit_get(node.getAttribute('height'))
        self.code_name = node.getAttribute('code')
        self.codes = getCodes()

        from trml2pdf.parser import ParserError
        try:
            self.codes[self.code_name]
        except KeyError, msg:
            raise ParserError("Unknown barcode name '%s'." % self.code_name)
 def test0(self):
     from reportlab.graphics.shapes import Drawing
     outDir = self.outDir
     html = ['<html><head></head><body>']
     a = html.append
     formats = ['gif','pict','pdf']
     from reportlab.graphics.barcode import getCodes
     CN = list(getCodes().items())
     for name,C in CN:
         i = C()
         D = Drawing(100,50)
         D.add(i)
         D.save(formats=formats,outDir=outDir,fnRoot=name)
         a('<h2>%s</h2><img src="%s.gif"><br>' % (name, name))
         for fmt in formats:
             efn = os.path.join(outDir,'%s.%s' % (name,fmt))
             self.assertTrue(os.path.isfile(efn),msg="Expected file %r was not created" % efn)
     a('</body></html>')
     open(os.path.join(outDir,'index.html'),'w').write('\n'.join(html))
Beispiel #6
0
    def __init__(self, node, styles, value, encoding):
        Flowable.__init__(self)

        self.node = node
        self.styles = styles
        self.value = value
        self.encoding = encoding
        self.xpos = utils.unit_get(node.getAttribute('x'))
        self.ypos = utils.unit_get(node.getAttribute('y'))
        self.width = utils.unit_get(node.getAttribute('width'))
        self.height = utils.unit_get(node.getAttribute('height'))
        self.code_name = node.getAttribute('code')
        self.codes = getCodes()

        from trml2pdf.parser import ParserError
        try:
            self.codes[self.code_name]
        except KeyError, msg:
            raise ParserError("Unknown barcode name '%s'." % self.code_name)
 def test0(self):
     from reportlab.graphics.shapes import Drawing
     outDir = self.outDir
     html = ['<html><head></head><body>']
     a = html.append
     formats = ['gif','pict','pdf']
     from reportlab.graphics.barcode import getCodes
     CN = list(getCodes().items())
     for name,C in CN:
         i = C()
         x0,y0,x1,y1 = i.getBounds()
         D = Drawing(x1-x0,y1-y0)
         D.add(i)
         D.save(formats=formats,outDir=outDir,fnRoot=name)
         a('<h2>%s</h2><img src="%s.gif"><br>' % (name, name))
         for fmt in formats:
             efn = os.path.join(outDir,'%s.%s' % (name,fmt))
             self.assertTrue(os.path.isfile(efn),msg="Expected file %r was not created" % efn)
     a('</body></html>')
     open(os.path.join(outDir,'index.html'),'w').write('\n'.join(html))
    def test0(self):
        from reportlab.graphics.shapes import Drawing

        outDir = self.outDir
        html = ["<html><head></head><body>"]
        a = html.append
        formats = ["gif", "pict", "pdf"]
        from reportlab.graphics.barcode import getCodes

        CN = list(getCodes().items())
        for name, C in CN:
            i = C()
            x0, y0, x1, y1 = i.getBounds()
            D = Drawing(x1 - x0, y1 - y0)
            D.add(i)
            D.save(formats=formats, outDir=outDir, fnRoot=name)
            a('<h2>%s</h2><img src="%s.gif"><br>' % (name, name))
            for fmt in formats:
                efn = os.path.join(outDir, "%s.%s" % (name, fmt))
                self.assertTrue(os.path.isfile(efn), msg="Expected file %r was not created" % efn)
        a("</body></html>")
        open(os.path.join(outDir, "index.html"), "w").write("\n".join(html))
Beispiel #9
0
def _get_code(self, cr, uid, context=None):
    """get availble code """
    return [(r, r) for r in getCodes()]
Beispiel #10
0
def _get_code(self, cr, uid, context=None):
    """get availble code """
    codes = [(r, r) for r in getCodes()]
    codes.append(('qrcode', 'QR'))
    return codes
Beispiel #11
0
def _get_code(self, cr, uid, context=None):
    """get availble code """
    codes = [(r, r) for r in getCodes()]
    codes.append(('qrcode', 'QR'))
    return codes
Beispiel #12
0
def _get_code(self, cr, uid, context=None):
    return [(r, r) for r in getCodes()]
def _get_code():
    """get availble code """
    return [(r, r) for r in getCodes()]
Beispiel #14
0
 def pass_code(self, wizard, code):
     bcc = getCodes()[wizard.get_barcode_format()](value=code)
     bcc.validate()
     bcc.encode()
     wizard.on_barcode_scanned(bcc.encoded[1:-1])
Beispiel #15
0
def _get_code(self, cr, uid, context=None):
    """get availble code """
    return [(r, r) for r in getCodes()]
Beispiel #16
0
 def pass_code(self, wizard, code):
     bcc = getCodes()[
         self.env["stock.request.kanban"].get_barcode_format()](value=code)
     bcc.validate()
     bcc.encode()
     wizard.on_barcode_scanned(bcc.encoded[1:-1])
Beispiel #17
0
def _get_code(self, cr, uid, context=None):
    return [(r, r) for r in getCodes()]