> import barcode > > from barcode.writer import ImageWriter > > > class Product: > > barcode = fields.Function(fields.Binary("Barcode", > > states={ > > 'invisible': ~Eval('barcode'), > > }), > > 'get_barcode') > > > > def get_barcode(self, name): > > fd = BytesIO() > > barcode.generate( > > 'ean13', self.code[:12].zfill(12), > > writer=ImageWriter(), output=fd) > > fd.seek(0) > > return fields.Binary.cast(fd.read()) > > > This should show without problems on the report. > > [1] https://pypi.python.org/pypi/pyBarcode/0.8b1
Hi, I try your code to generate a barcode on a report. I had to install "Pillow" (pip install Pillow) to avoid an NoneType error. How display this new field 'barcode' inside LibreOffice writer ? I try to add a frame but don't know how to link my binary field and relatorio documentation seems outdated... -- You received this message because you are subscribed to the Google Groups "tryton-dev" group. To view this discussion on the web visit https://groups.google.com/d/msgid/tryton-dev/9f4a7160-7bc8-4372-b304-9d657c7ff7cc%40googlegroups.com.