From f613ce968d4d57eef6c215f38411737bcb458171 Mon Sep 17 00:00:00 2001 From: Arnold Moyaux Date: Fri, 21 Oct 2022 10:05:28 +0000 Subject: [PATCH] [FIX] base, stock, delivery: replace support datamatrix barcode printing This reverts commit 3ebe1185a497718a4d2a303d363a1a923dd9effe. The code ECC200DataMatrix already exist in reportlab (that is already a dependance). Some differences: - ECC200DataMatrix only supports a Type 12 (44x44) C40 encoded data matrix. (214 alphanumeric characters and 14 to 27% of error correcting rate) - pylibdmtx support more type and add a default to 24x24. So it means a (52 characters and 20 to 35% error correcting rate). It's also smaller to display. We consider the gain too small compare to maintain an extra lib. It also fix blured datamatrix in stock report if they contains too much data. *If you want to test 001234560000000018 is a valid sscc for package closes odoo/odoo#106620 X-original-commit: 54ef19f41ffc4a6f715474b65a4183a7fa75feea Related: odoo/enterprise#34422 Signed-off-by: William Henrotin (whe) Signed-off-by: Arnold Moyaux (arm) --- addons/delivery/views/report_package_barcode.xml | 2 +- addons/stock/i18n/stock.pot | 3 +-- addons/stock/report/report_lot_barcode.xml | 4 ++-- addons/stock/report/report_package_barcode.xml | 12 ++++++------ addons/stock/views/res_config_settings_views.xml | 2 +- odoo/addons/base/models/ir_actions_report.py | 14 ++++---------- 6 files changed, 15 insertions(+), 22 deletions(-) diff --git a/addons/delivery/views/report_package_barcode.xml b/addons/delivery/views/report_package_barcode.xml index c1976e3459e..f37e723b63f 100644 --- a/addons/delivery/views/report_package_barcode.xml +++ b/addons/delivery/views/report_package_barcode.xml @@ -35,7 +35,7 @@ - +
Shipping Weight:
Weight:
diff --git a/addons/stock/i18n/stock.pot b/addons/stock/i18n/stock.pot index c5a2a965bb6..8d93df69184 100644 --- a/addons/stock/i18n/stock.pot +++ b/addons/stock/i18n/stock.pot @@ -8486,8 +8486,7 @@ msgstr "" #: model_terms:ir.ui.view,arch_db:stock.res_config_settings_view_form msgid "" "Use GS1 nomenclature datamatrix whenever barcodes are printed for lots and " -"serial numbers. Printing datamatrix requires extra software. If software " -"can't be found then 1D barcodes will be printed." +"serial numbers." msgstr "" #. module: stock diff --git a/addons/stock/report/report_lot_barcode.xml b/addons/stock/report/report_lot_barcode.xml index 76d8b1fc203..76dfe877cdb 100644 --- a/addons/stock/report/report_lot_barcode.xml +++ b/addons/stock/report/report_lot_barcode.xml @@ -23,13 +23,13 @@
LN/SN:
- + -
+
diff --git a/addons/stock/report/report_package_barcode.xml b/addons/stock/report/report_package_barcode.xml index ec5108af68a..f722a92ab76 100644 --- a/addons/stock/report/report_package_barcode.xml +++ b/addons/stock/report/report_package_barcode.xml @@ -16,11 +16,11 @@

- +
-
+
@@ -42,7 +42,7 @@
- + @@ -84,7 +84,7 @@ - + @@ -102,11 +102,11 @@
- +
-
+
SSCC:
Pack Date:
diff --git a/addons/stock/views/res_config_settings_views.xml b/addons/stock/views/res_config_settings_views.xml index 4e43367f592..7c6c2978b47 100644 --- a/addons/stock/views/res_config_settings_views.xml +++ b/addons/stock/views/res_config_settings_views.xml @@ -350,7 +350,7 @@
diff --git a/odoo/addons/base/models/ir_actions_report.py b/odoo/addons/base/models/ir_actions_report.py index a44078447ec..d682b0e10e1 100644 --- a/odoo/addons/base/models/ir_actions_report.py +++ b/odoo/addons/base/models/ir_actions_report.py @@ -42,12 +42,6 @@ try: except Exception: pass -datamatrix_available = True -try: - from pylibdmtx import pylibdmtx -except Exception: - _logger.info('A package may be missing to print Data Matrix barcodes: pylibdmtx or libdmtx.') - datamatrix_available = False def _get_wkhtmltopdf_bin(): return find_in_path('wkhtmltopdf') @@ -221,7 +215,7 @@ class IrActionsReport(models.Model): :return: Boolean ''' - return datamatrix_available + return True def get_paperformat(self): return self.paperformat_id or self.env.company.paperformat_id @@ -542,9 +536,9 @@ class IrActionsReport(models.Model): elif barcode_type == 'auto': symbology_guess = {8: 'EAN8', 13: 'EAN13'} barcode_type = symbology_guess.get(len(value), 'Code128') - elif barcode_type == 'DataMatrix' and not self.datamatrix_available(): - # fallback to avoid stacktrack because reportlab won't recognize the type and error message isn't useful/will be blocking - barcode_type = 'Code128' + elif barcode_type == 'DataMatrix': + # Prevent a crash due to a lib change from pylibdmtx to reportlab + barcode_type = 'ECC200DataMatrix' elif barcode_type == 'QR': # for `QR` type, `quiet` is not supported. And is simply ignored. # But we can use `barBorder` to get a similar behaviour.
Product