Generate Barcodes (Abstract)
by GRAP https://github.com/OCA/stock-logistics-barcode , La Louve https://github.com/OCA/stock-logistics-barcode , LasLabs https://github.com/OCA/stock-logistics-barcode , Odoo Community Association (OCA) https://github.com/OCA/stock-logistics-barcodeAvailability |
Odoo Online
Odoo.sh
On Premise
|
Lines of code | 207 |
Technical Name |
barcodes_generator_abstract |
License | AGPL-3 |
Website | https://github.com/OCA/stock-logistics-barcode |
Versions | 12.0 13.0 15.0 9.0 10.0 14.0 16.0 |
Generate Barcodes (Abstract)
This module extends Odoo functionality, allowing user to generate barcode depending on a given barcode rule for any Model.
For example, if the barcode pattern is “20…..{NNNDD}”:
- the EAN13 code will begin with ‘20’,
- followed by 5 digits (named Barcode Base in this module),
- followed by 5 others digits to define the variable price with 2 decimals,
- the last digit (the 13rd digit) is the control digit (i.e. the checksum).
With this module, it is possible to:
- Affect a pattern (barcode.rule) to a model
- Define a Barcode base:
- manually, if the base of the barcode must be set by a user (typically an internal code defined in your company).
- automatically by a sequence, if you want to let Odoo increment a sequence (typical case of a customer number incrementation).
- Generate a barcode, based on the defined pattern and the barcode base
Table of contents
Installation
This module use an extra python library named ‘python-barcode’ you should install to make barcode generation works properly.
sudo pip install python-barcode
Configuration
To configure this module, you need to:
- Go to Settings / Technical / Sequences & Identifiers / Barcode Nomenclatures
- Select a Nomenclature
- Create or select a rule
- For manual generation, set:
- ‘Base set Manually’ in ‘Generate Type’
- Set the model
- For automatic generation, set:
- ‘Base managed by Sequence’ in ‘Generate Type’
- Set the model
- Generate a new sequence by button, or affect a existing one
In all cases, padding will be computed automaticaly, based on the number of ‘.’ in the Barcode Pattern field.
Usage
This module is an abstract module. You can configure Barcode Rule, but to enable this feature, you need to install an extra module for a given model. This repository provide ‘barcodes_generator_product’ and ‘barcodes_generator_partner’ module to generate barcode for product or partner model.
Alternatively, you can develop a custom module for a custom model. See ‘Inheritance’ parts.
If you want to generate barcode for another model, you can create a custom module that depend on ‘barcodes_generator_abstract’ and inherit your model like that:
class MyModel(models.Model): _name = 'my.model' _inherit = ['my.model', 'barcode.generate.mixin'] class barcode_rule(models.Model): _inherit = 'barcode.rule' generate_model = fields.Selection(selection_add=[('my.model', 'My Model')])
Eventually, you should inherit your model view adding buttons and fields.
Note
Your model should have a field ‘barcode’ defined.
Known issues / Roadmap
- On barcode.rule model, constraint and domain system could be set between ‘type’ and ‘generate_model’ fields.
- Cache is being cleared in a constraint in barcode.rule. Mutating in a constraint is bad practice & should be moved somewhere.
Bug Tracker
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed feedback.
Do not contact contributors directly about support or help with technical issues.
Credits
Authors
- GRAP
- La Louve
- LasLabs
Contributors
- Sylvain LE GAL (https://twitter.com/legalsylvain)
- Dave Lasley <dave@laslabs.com>
- Tecnativa:
- Carlos Roca
- Ooops404:
- Ilyas <irazor147@gmail.com>
Images
- Icon of the module is based on the Oxygen Team work and is under LGPL licence: http://www.iconarchive.com/show/oxygen-icons-by-oxygen-icons.org.html
Maintainers
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
Current maintainer:
This module is part of the OCA/stock-logistics-barcode project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Please log in to comment on this module
Report comment
Any abuse of this reporting system will be penalizedCó lỗi
Tôi gặp lỗi "AttributeError: module 'barcode' has no attribute 'get_barcode_class'" khi cố gắng chạy mô-đun trên. Bạn có thể giúp tôi khắc phục lỗi trên không?
Cám ơn bạn./
suddenlyI start to have this error on Odoo 16 community, Module is update.
File "/odoo16/custom/oca/stock-logistics-barcode/barcodes_generator_abstract/models/barcode_generate_mixin.py", line 80, in generate_barcode barcode_class = barcode.get_barcode_class(item.barcode_rule_id.encoding) AttributeError: module 'barcode' has no attribute 'get_barcode_class' The above server error caused the following client error: RPC_ERROR: Odoo Server Error RPCError@https://www.miditec.com.mx/web/assets/debug/web.assets_backend.js:10360:14 (/web/static/src/core/network/rpc_service.js:11) makeErrorFromResponse@https://www.miditec.com.mx/web/assets/debug/web.assets_backend.js:10383:31 (/web/static/src/core/network/rpc_service.js:34) @https://www.miditec.com.mx/web/assets/debug/web.assets_backend.js:10436:48 (/web/static/src/core/network/rpc_service.js:87)
The complete log error is this one:
RPC_ERROR
Odoo Server Error
Traceback (most recent call last):
File "/odoo16/odoo16-server/odoo/http.py", line 1589, in _serve_db
return service_model.retrying(self._serve_ir_http, self.env)
File "/odoo16/odoo16-server/odoo/service/model.py", line 133, in retrying
result = func()
File "/odoo16/odoo16-server/odoo/http.py", line 1616, in _serve_ir_http
response = self.dispatcher.dispatch(rule.endpoint, args)
File "/odoo16/odoo16-server/odoo/http.py", line 1820, in dispatch
result = self.request.registry['ir.http']._dispatch(endpoint)
File "/odoo16/odoo16-server/addons/website/models/ir_http.py", line 237, in _dispatch
response = super()._dispatch(endpoint)
File "/odoo16/odoo16-server/odoo/addons/base/models/ir_http.py", line 154, in _dispatch
result = endpoint(**request.params)
File "/odoo16/odoo16-server/odoo/http.py", line 697, in route_wrapper
result = endpoint(self, *args, **params_ok)
File "/odoo16/odoo16-server/addons/web/controllers/dataset.py", line 46, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/odoo16/odoo16-server/addons/web/controllers/dataset.py", line 33, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/odoo16/odoo16-server/odoo/api.py", line 466, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/odoo16/odoo16-server/odoo/api.py", line 453, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "/odoo16/custom/oca/stock-logistics-barcode/barcodes_generator_product/models/product_template.py", line 68, in generate_barcode
self.product_variant_ids.generate_barcode()
File "/odoo16/custom/oca/stock-logistics-barcode/barcodes_generator_abstract/models/barcode_generate_mixin.py", line 80, in generate_barcode
barcode_class = barcode.get_barcode_class(item.barcode_rule_id.encoding)
AttributeError: module 'barcode' has no attribute 'get_barcode_class'
The above server error caused the following client error:
RPC_ERROR: Odoo Server Error
RPCError@https://192.168.1.222/web/assets/37579-2f78a00/web.assets_backend.min.js:983:279
makeErrorFromResponse@https://192.168.1.222/web/assets/37579-2f78a00/web.assets_backend.min.js:987:175
@https://192.168.1.222/web/assets/37579-2f78a00/web.assets_backend.min.js:995:34
Luis G