# Barcode Reports

**URL:** https://discuss.tryton.org/t/barcode-reports/5421
**Category:** Ideas
**Tags:** stock
**Created:** [July 14, 2022, 1:01pm UTC](https://discuss.tryton.org/t/barcode-reports/5421 "2022-07-14T13:01:15Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![acaubet](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/acaubet/32/1493_2.png) [@acaubet](https://discuss.tryton.org/u/acaubet)
#### Post date: [July 14, 2022, 1:01pm UTC](https://discuss.tryton.org/t/barcode-reports/5421/1 "2022-07-14T13:01:15Z")

</div>

We have been asked so many times to print the barcodes of a product or a lot.  
I would be nice to have core Barcode reports for product and lots. So you can print those reports to get the label.

We have some custom reports u-sing [python-barcode](https://python-barcode.readthedocs.io/en/stable/contents.html) which works really well.  
The field to get the code for the image should be a property, to allow customization.

Don’t you think it make sense to have this? Any use case I’m not catching or that can be an addition to my suggestion?

---

<div class="post-metadata">

### Author: ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)
#### Post date: [July 14, 2022, 1:25pm UTC](https://discuss.tryton.org/t/barcode-reports/5421/2 "2022-07-14T13:25:51Z")

</div>

I would suggest to add the barcode generation function into the report class itself. So you can call for the barcode with the data you want, the size and the type of barcode. The function returns an image which you can position in your report. So no new things are needed in the different models.

There are many reports for which you want a barcode. For example a form which is filled by hand and then digitized. By using OCR you can use the barcode to match with a Tryton record for example.

I use [Treepoem](https://github.com/adamchainz/treepoem) for barcode generation. It’s a Python wrapper around [BWIPP](https://github.com/bwipp/postscriptbarcode) a pure Postscript barcode generator. It has basically all the barcodes available ([Symbologies Reference · bwipp/postscriptbarcode Wiki · GitHub](https://github.com/bwipp/postscriptbarcode/wiki/Symbologies-Reference)) from 1D to 2D.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [July 14, 2022, 2:06pm UTC](https://discuss.tryton.org/t/barcode-reports/5421/3 "2022-07-14T14:06:52Z")

</div>

I will not be against adding tools to generate barcode and qrcode in trytond. The API must be designed to be abstract from the underlying library used (because we may need to change it in the future). Of course it is a good idea to expose this API to the report context. The API must also allow to create Function field to display them in the client.  
Once this API is designed we can choose the libraries. For me they must be pure Python to avoid to have to deal with non-Python dependencies. I think it is good like python-barcode to use SVG as base format and rely on Pillow (which is already an optional dependency) to generate non-vectorial image. [qrcode](https://pypi.org/project/qrcode/) seem to be a good option also.  
Also we should be allowed to introspect the available formats and support to have fallback.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [October 11, 2022, 3:25pm UTC](https://discuss.tryton.org/t/barcode-reports/5421/4 "2022-10-11T15:25:59Z")

</div>

Here is my proposal [Add support for barcode an qrcode (#11791) · Issues · Tryton / Tryton · GitLab](https://bugs.tryton.org/issue11791)

---

<div class="post-metadata">

### Author: ![hodeinavarro](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/hodeinavarro/32/1185_2.png) [@hodeinavarro](https://discuss.tryton.org/u/hodeinavarro)
#### Post date: [October 23, 2022, 12:25am UTC](https://discuss.tryton.org/t/barcode-reports/5421/5 "2022-10-23T00:25:55Z")

</div>

Following the proposed implementation, I think a `barcode` function could be added to `stock.move` in order to generate a [Code 128](https://python-barcode.readthedocs.io/en/stable/supported-formats.html#code-128) and [GS1\_128](https://python-barcode.readthedocs.io/en/stable/supported-formats.html#gs1-128).

Instead of calling `self.code` I’d call a `get_128_code()` that would return the result of [stdnum’s gs1\_128](https://arthurdejong.org/python-stdnum/doc/1.17/stdnum.gs1_128) `encode` implementation. This way we can achieve modules like `stock_lot` to fill the `10` from the `gs1_128`, `17` with `stock_lot_sled`, etc. etc. This could be configurable on the `product.product` very much like the `lot_required` multiselection and/or maybe a global `product.configuration` default.

Thoughts?

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [October 23, 2022, 7:46am UTC](https://discuss.tryton.org/t/barcode-reports/5421/6 "2022-10-23T07:46:19Z")

</div>

For me there is nothing standard in this proposal.  
More over I do not see the point to generate a barcode for a stock move.

---

<div class="post-metadata">

### Author: ![hodeinavarro](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/hodeinavarro/32/1185_2.png) [@hodeinavarro](https://discuss.tryton.org/u/hodeinavarro)
#### Post date: [October 23, 2022, 3:02pm UTC](https://discuss.tryton.org/t/barcode-reports/5421/7 "2022-10-23T15:02:44Z")

</div>

I can’t argue about the standard on the proposal, technically speaking, but I do not agree about the idea not being standard - not sure which you’re referring to.  
stdnum provides the wikipedia links and the gs1 website links about the implementation.

- [Code 128 - Wikipedia](https://en.wikipedia.org/wiki/GS1-128)
- [GS1 Application Identifiers](https://www.gs1.org/standards/barcodes/application-identifiers)
- [https://www.gs1.org/docs/barcodes/GS1\_General\_Specifications.pdf](https://www.gs1.org/docs/barcodes/GS1_General_Specifications.pdf)

I do not remember the necessity about generating a barcode for a stock move, but we’ve been asked on multiple times about this feature instead of the product one. In fact, the very initial post of this thread proposes the lot barcode.

> [@acaubet](#):
>
> We have been asked so many times to print the barcodes of a product or a lot.

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [October 24, 2022, 6:40am UTC](https://discuss.tryton.org/t/barcode-reports/5421/8 "2022-10-24T06:40:39Z")

</div>

> [@ced](#):
>
> More over I do not see the point to generate a barcode for a stock move.

When using Code128 which is already [supported by python-stdnum](https://github.com/arthurdejong/python-stdnum/blob/master/stdnum/gs1_128.py#L21) you can have all the information related to a move in the code. This is usefull for example to include in a package/pallet/box a barcode with the following information:

- Product EAN
- Product Quantity
- Weight (in case different from quantity)
- Lot
- Expiry date

With such code, when the package is received on another place scanning the barcode will import all the information in the ERP without the need of manually entering the information.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [October 24, 2022, 9:08am UTC](https://discuss.tryton.org/t/barcode-reports/5421/9 "2022-10-24T09:08:36Z")

</div>

Indeed GS1 is a global encoding system for various logistics. It could be computed for various Tryton models. But for me it is out of the supporting barcode (and qrcode) in Tryton.  
GS1 system could be implemented by a module which will define a standard API to get the encoded data and apply to various model but that’s for another topic.
