product_print_zpl_barcode: print multi labels at once

Print from product tree view and form view (product.product and product.template)
Print from done stock picking using must_print_barcode
This commit is contained in:
Alexis de Lattre
2023-07-15 15:16:58 +02:00
parent 2905b5f426
commit 7477deeae3
11 changed files with 1067 additions and 156 deletions

View File

@@ -46,6 +46,7 @@ This module has been written by Alexis de Lattre from Akretion
'security/ir.model.access.csv',
'wizard/product_print_zpl_barcode_view.xml',
'views/product.xml',
'views/stock_picking.xml',
'data/barcode_sequence.xml',
],
'installable': True,

View File

@@ -0,0 +1,412 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_print_zpl_barcode
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-07-15 13:13+0000\n"
"PO-Revision-Date: 2023-07-15 13:14+0000\n"
"Last-Translator: Alexis de Lattre <alexis.delattre@akretion.com>\n"
"Language-Team: \n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__copies
msgid "# Labels"
msgstr "Nb étiquettes"
#. module: product_print_zpl_barcode
#: model:ir.model.fields.selection,name:product_print_zpl_barcode.selection__product_print_zpl_barcode__label_size__38x25
msgid "38x25 mm"
msgstr "38x25 mm"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__barcode
msgid "Barcode"
msgstr "Code-barres"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__nomenclature_id
msgid "Barcode Nomenclature"
msgstr "Nomenclature des codes-barres"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__rule_id
msgid "Barcode Rule"
msgstr "Règle de codes-barres"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__barcode_type
msgid "Barcode Type"
msgstr "Type de code-barres"
#. module: product_print_zpl_barcode
#: model_terms:ir.ui.view,arch_db:product_print_zpl_barcode.product_print_zpl_barcode_form
msgid "Cancel"
msgstr "Annuler"
#. module: product_print_zpl_barcode
#: model_terms:ir.ui.view,arch_db:product_print_zpl_barcode.product_print_zpl_barcode_form
msgid "Close"
msgstr "Fermer"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__company_id
msgid "Company"
msgstr "Société"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__create_uid
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__create_uid
msgid "Created by"
msgstr "Créé par"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__create_date
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__create_date
msgid "Created on"
msgstr "Créé le"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__currency_id
msgid "Currency"
msgstr "Devise"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,help:product_print_zpl_barcode.field_product_print_zpl_barcode_line__uom_id
msgid "Default unit of measure used for all stock operations."
msgstr ""
"Unité de mesure par défaut utilisée pour toutes les opérations de stock."
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__display_name
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__display_name
msgid "Display Name"
msgstr "Nom affiché"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,help:product_print_zpl_barcode.field_product_product__must_print_barcode
#: model:ir.model.fields,help:product_print_zpl_barcode.field_product_template__must_print_barcode
msgid ""
"Enable that option for products for which you must print a barcode upon "
"reception in stock."
msgstr ""
"Activez cette option sur les articles pour lesquels vous devez imprimer un "
"code-barres dès leur réception en stock."
#. module: product_print_zpl_barcode
#: model:ir.actions.act_window,name:product_print_zpl_barcode.product_print_zpl_barcode_action
#: model_terms:ir.ui.view,arch_db:product_print_zpl_barcode.product_normal_form_view
#: model_terms:ir.ui.view,arch_db:product_print_zpl_barcode.product_template_only_form_view
msgid "Generate Barcode"
msgstr "Générer un code-barres"
#. module: product_print_zpl_barcode
#: model_terms:ir.ui.view,arch_db:product_print_zpl_barcode.product_print_zpl_barcode_form
msgid "Generate Labels"
msgstr "Générer les étiquettes"
#. module: product_print_zpl_barcode
#: model:ir.model,name:product_print_zpl_barcode.model_product_print_zpl_barcode
msgid "Generate and print product barcodes in ZPL"
msgstr "Générer et imprimer des codes-barres d'articles en ZPL"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__id
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__id
msgid "ID"
msgstr "ID"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__label_size
msgid "Label Size"
msgstr "Taille de l'étiquette"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode____last_update
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line____last_update
msgid "Last Modified on"
msgstr "Dernière modification le"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__write_uid
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__write_uid
msgid "Last Updated by"
msgstr "Dernière mise à jour par"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__write_date
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__write_date
msgid "Last Updated on"
msgstr "Dernière mise à jour le"
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/wizard/product_print_zpl_barcode.py:0
#, python-format
msgid ""
"Line '%s': barcode '%s' has %d digits. This wizard only supports EAN8 and "
"EAN13 for the moment."
msgstr ""
"Ligne '%s' : le code-barres '%s' comporte %d chiffres. Cet assistant ne "
"prend en charge que les EAN8 et EAN13 pour le moment."
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/wizard/product_print_zpl_barcode.py:0
#, python-format
msgid "Line '%s': barcode type '%s' is not supported for the moment"
msgstr ""
"Ligne '%s' : le type de code-barres '%s' n'est pas supporté pour le moment"
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/wizard/product_print_zpl_barcode.py:0
#, python-format
msgid ""
"Line '%s': the barcode '%s' is not a valid EAN barcode (wrong checksum)."
msgstr ""
"Ligne '%s' : le code-barres '%s' n'est pas un code-barres EAN valide "
"(mauvaise somme de contrôle)."
#. module: product_print_zpl_barcode
#: model:ir.model,name:product_print_zpl_barcode.model_product_print_zpl_barcode_line
msgid "Line of the print ZPL barcode wizard"
msgstr "Ligne de l'assistant d'impression du code-barres ZPL"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__line_ids
msgid "Lines"
msgstr "Lignes"
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/wizard/product_print_zpl_barcode.py:0
#, python-format
msgid "Missing Products"
msgstr "Produits manquants"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_product__must_print_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_template__must_print_barcode
msgid "Must Print Barcode"
msgstr "Code-barres à imprimer"
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/wizard/product_print_zpl_barcode.py:0
#, python-format
msgid "On line '%s', the number of copies must be strictly positive."
msgstr "Sur la ligne '%s', le nombre d'étiquettes doit être strictement positif."
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_product__barcode_image_png
msgid "PNG Barcode Image"
msgstr "Image PNG du code-barres"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__parent_id
msgid "Parent"
msgstr "Parent"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__price
msgid "Price"
msgstr "Prix"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__price_uom
msgid "Price/UoM"
msgstr "Prix/unité"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__pricelist_id
msgid "Pricelist"
msgstr "Liste de prix"
#. module: product_print_zpl_barcode
#: model_terms:ir.ui.view,arch_db:product_print_zpl_barcode.product_print_zpl_barcode_form
msgid "Print"
msgstr "Imprimer"
#. module: product_print_zpl_barcode
#: model_terms:ir.ui.view,arch_db:product_print_zpl_barcode.product_normal_form_view
#: model_terms:ir.ui.view,arch_db:product_print_zpl_barcode.product_template_only_form_view
#: model_terms:ir.ui.view,arch_db:product_print_zpl_barcode.view_picking_form
msgid "Print Barcode"
msgstr "Imprimer le code-barres"
#. module: product_print_zpl_barcode
#: model_terms:ir.ui.view,arch_db:product_print_zpl_barcode.product_product_tree_view
#: model_terms:ir.ui.view,arch_db:product_print_zpl_barcode.product_template_tree_view
msgid "Print Barcodes"
msgstr "Imprimer les code-barres"
#. module: product_print_zpl_barcode
#: model:ir.model,name:product_print_zpl_barcode.model_product_template
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__product_id
msgid "Product"
msgstr "Article"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__product_name
msgid "Product Label"
msgstr "Étiquette de l'article"
#. module: product_print_zpl_barcode
#: model:ir.model,name:product_print_zpl_barcode.model_product_product
msgid "Product Variant"
msgstr "Variante d'article"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__quantity
msgid "Qty"
msgstr "Qté"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_product__barcode_image_svg
msgid "SVG Barcode Image"
msgstr "Image SVG du code-barres"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_stock_picking__show_print_zpl_barcode
msgid "Show Print Zpl Barcode"
msgstr "Afficher le bouton imprimer le code-barres ZPL"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__state
msgid "State"
msgstr "État"
#. module: product_print_zpl_barcode
#: model:ir.model.fields.selection,name:product_print_zpl_barcode.selection__product_print_zpl_barcode__state__step1
msgid "Step1"
msgstr "Étape 1"
#. module: product_print_zpl_barcode
#: model:ir.model.fields.selection,name:product_print_zpl_barcode.selection__product_print_zpl_barcode__state__step2
msgid "Step2"
msgstr "Étape 2"
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/wizard/product_print_zpl_barcode.py:0
#, python-format
msgid ""
"The barcode of the product (%s) has %d characters, which is smaller than the "
"%d characters of the prefix of the barcode pattern (%s)."
msgstr ""
"Le code-barres de l'article (%s) comporte %d caractères, ce qui est plus "
"petit que les %d caractères du préfixe du modèle de code-barres (%s)."
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/wizard/product_print_zpl_barcode.py:0
#, python-format
msgid ""
"The barcode rule '%s' has a pattern '%s' which doesn't contain a integer and "
"decimal part between '{}'."
msgstr ""
"La règle de code-barres '%s' a un motif '%s' qui ne contient pas de partie "
"entière et décimale entre '{}'."
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/models/product.py:0
#, python-format
msgid "The product '%s' already has a barcode."
msgstr "L'article '%s' a déjà un code-barres."
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/wizard/product_print_zpl_barcode.py:0
#, python-format
msgid "The quantity (%s) must be positive !"
msgstr "La quantité (%s) doit être positive !"
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/models/product.py:0
#, python-format
msgid ""
"The sequence 'private.product.barcode' is not properly configured. The "
"generated sequence should have 7 digits (for EAN-8) or 12 digits (for "
"EAN-13). It currently has %d digits."
msgstr ""
"La séquence 'private.product.barcode' n'est pas correctement configurée. La "
"séquence générée devrait avoir 7 chiffres (pour EAN-8) ou 12 chiffres (pour "
"EAN-13). Elle comporte actuellement %d chiffres."
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/wizard/product_print_zpl_barcode.py:0
#, python-format
msgid ""
"The value to encode in the barcode (%s) is superior to the maximum value "
"allowed by the barcode pattern (%s)."
msgstr ""
"La valeur à encoder dans le code-barres (%s) est supérieure à la valeur "
"maximale autorisée par le motif du code-barres (%s)."
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/wizard/product_print_zpl_barcode.py:0
#, python-format
msgid "There are no pricelist in company '%s'."
msgstr "Il n'y a pas de liste de prix dans la société '%s'."
#. module: product_print_zpl_barcode
#: model:ir.model,name:product_print_zpl_barcode.model_stock_picking
msgid "Transfer"
msgstr "Transfert"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__uom_id
msgid "UoM"
msgstr "Unité"
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/wizard/product_print_zpl_barcode.py:0
#, python-format
msgid "Wrong active_model in context (%s)."
msgstr "Mauvais active_model dans le contexte (%s)."
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/models/product.py:0
#, python-format
msgid ""
"You cannot call the method generate_barcode_from_product_template on product "
"'%s' because it has %d variants and not just one."
msgstr ""
"Vous ne pouvez pas appeler la méthode generate_barcode_from_product_template "
"sur l'article '%s' parce qu'il a %d variantes et non une seule."
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/wizard/product_print_zpl_barcode.py:0
#, python-format
msgid "You must select a ZPL Printer."
msgstr "Vous devez sélectionner une imprimante ZPL."
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__zpl_file
msgid "ZPL File"
msgstr "Fichier ZPL"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__zpl_filename
msgid "ZPL Filename"
msgstr "Nom du fichier ZPL"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__zpl_printer_id
msgid "ZPL Printer"
msgstr "Imprimante ZPL"

View File

@@ -0,0 +1,392 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_print_zpl_barcode
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-07-15 13:13+0000\n"
"PO-Revision-Date: 2023-07-15 13:13+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__copies
msgid "# Labels"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields.selection,name:product_print_zpl_barcode.selection__product_print_zpl_barcode__label_size__38x25
msgid "38x25 mm"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__barcode
msgid "Barcode"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__nomenclature_id
msgid "Barcode Nomenclature"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__rule_id
msgid "Barcode Rule"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__barcode_type
msgid "Barcode Type"
msgstr ""
#. module: product_print_zpl_barcode
#: model_terms:ir.ui.view,arch_db:product_print_zpl_barcode.product_print_zpl_barcode_form
msgid "Cancel"
msgstr ""
#. module: product_print_zpl_barcode
#: model_terms:ir.ui.view,arch_db:product_print_zpl_barcode.product_print_zpl_barcode_form
msgid "Close"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__company_id
msgid "Company"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__create_uid
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__create_uid
msgid "Created by"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__create_date
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__create_date
msgid "Created on"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__currency_id
msgid "Currency"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,help:product_print_zpl_barcode.field_product_print_zpl_barcode_line__uom_id
msgid "Default unit of measure used for all stock operations."
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__display_name
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__display_name
msgid "Display Name"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,help:product_print_zpl_barcode.field_product_product__must_print_barcode
#: model:ir.model.fields,help:product_print_zpl_barcode.field_product_template__must_print_barcode
msgid ""
"Enable that option for products for which you must print a barcode upon "
"reception in stock."
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.actions.act_window,name:product_print_zpl_barcode.product_print_zpl_barcode_action
#: model_terms:ir.ui.view,arch_db:product_print_zpl_barcode.product_normal_form_view
#: model_terms:ir.ui.view,arch_db:product_print_zpl_barcode.product_template_only_form_view
msgid "Generate Barcode"
msgstr ""
#. module: product_print_zpl_barcode
#: model_terms:ir.ui.view,arch_db:product_print_zpl_barcode.product_print_zpl_barcode_form
msgid "Generate Labels"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model,name:product_print_zpl_barcode.model_product_print_zpl_barcode
msgid "Generate and print product barcodes in ZPL"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__id
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__id
msgid "ID"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__label_size
msgid "Label Size"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode____last_update
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line____last_update
msgid "Last Modified on"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__write_uid
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__write_uid
msgid "Last Updated by"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__write_date
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__write_date
msgid "Last Updated on"
msgstr ""
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/wizard/product_print_zpl_barcode.py:0
#, python-format
msgid ""
"Line '%s': barcode '%s' has %d digits. This wizard only supports EAN8 and "
"EAN13 for the moment."
msgstr ""
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/wizard/product_print_zpl_barcode.py:0
#, python-format
msgid "Line '%s': barcode type '%s' is not supported for the moment"
msgstr ""
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/wizard/product_print_zpl_barcode.py:0
#, python-format
msgid ""
"Line '%s': the barcode '%s' is not a valid EAN barcode (wrong checksum)."
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model,name:product_print_zpl_barcode.model_product_print_zpl_barcode_line
msgid "Line of the print ZPL barcode wizard"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__line_ids
msgid "Lines"
msgstr ""
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/wizard/product_print_zpl_barcode.py:0
#, python-format
msgid "Missing Products"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_product__must_print_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_template__must_print_barcode
msgid "Must Print Barcode"
msgstr ""
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/wizard/product_print_zpl_barcode.py:0
#, python-format
msgid "On line '%s', the number of copies must be strictly positive."
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_product__barcode_image_png
msgid "PNG Barcode Image"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__parent_id
msgid "Parent"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__price
msgid "Price"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__price_uom
msgid "Price/UoM"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__pricelist_id
msgid "Pricelist"
msgstr ""
#. module: product_print_zpl_barcode
#: model_terms:ir.ui.view,arch_db:product_print_zpl_barcode.product_print_zpl_barcode_form
msgid "Print"
msgstr ""
#. module: product_print_zpl_barcode
#: model_terms:ir.ui.view,arch_db:product_print_zpl_barcode.product_normal_form_view
#: model_terms:ir.ui.view,arch_db:product_print_zpl_barcode.product_template_only_form_view
#: model_terms:ir.ui.view,arch_db:product_print_zpl_barcode.view_picking_form
msgid "Print Barcode"
msgstr ""
#. module: product_print_zpl_barcode
#: model_terms:ir.ui.view,arch_db:product_print_zpl_barcode.product_product_tree_view
#: model_terms:ir.ui.view,arch_db:product_print_zpl_barcode.product_template_tree_view
msgid "Print Barcodes"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model,name:product_print_zpl_barcode.model_product_template
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__product_id
msgid "Product"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__product_name
msgid "Product Label"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model,name:product_print_zpl_barcode.model_product_product
msgid "Product Variant"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__quantity
msgid "Qty"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_product__barcode_image_svg
msgid "SVG Barcode Image"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_stock_picking__show_print_zpl_barcode
msgid "Show Print Zpl Barcode"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__state
msgid "State"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields.selection,name:product_print_zpl_barcode.selection__product_print_zpl_barcode__state__step1
msgid "Step1"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields.selection,name:product_print_zpl_barcode.selection__product_print_zpl_barcode__state__step2
msgid "Step2"
msgstr ""
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/wizard/product_print_zpl_barcode.py:0
#, python-format
msgid ""
"The barcode of the product (%s) has %d characters, which is smaller than the"
" %d characters of the prefix of the barcode pattern (%s)."
msgstr ""
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/wizard/product_print_zpl_barcode.py:0
#, python-format
msgid ""
"The barcode rule '%s' has a pattern '%s' which doesn't contain a integer and"
" decimal part between '{}'."
msgstr ""
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/models/product.py:0
#, python-format
msgid "The product '%s' already has a barcode."
msgstr ""
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/wizard/product_print_zpl_barcode.py:0
#, python-format
msgid "The quantity (%s) must be positive !"
msgstr ""
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/models/product.py:0
#, python-format
msgid ""
"The sequence 'private.product.barcode' is not properly configured. The "
"generated sequence should have 7 digits (for EAN-8) or 12 digits (for "
"EAN-13). It currently has %d digits."
msgstr ""
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/wizard/product_print_zpl_barcode.py:0
#, python-format
msgid ""
"The value to encode in the barcode (%s) is superior to the maximum value "
"allowed by the barcode pattern (%s)."
msgstr ""
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/wizard/product_print_zpl_barcode.py:0
#, python-format
msgid "There are no pricelist in company '%s'."
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model,name:product_print_zpl_barcode.model_stock_picking
msgid "Transfer"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode_line__uom_id
msgid "UoM"
msgstr ""
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/wizard/product_print_zpl_barcode.py:0
#, python-format
msgid "Wrong active_model in context (%s)."
msgstr ""
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/models/product.py:0
#, python-format
msgid ""
"You cannot call the method generate_barcode_from_product_template on product"
" '%s' because it has %d variants and not just one."
msgstr ""
#. module: product_print_zpl_barcode
#. odoo-python
#: code:addons/product_print_zpl_barcode/wizard/product_print_zpl_barcode.py:0
#, python-format
msgid "You must select a ZPL Printer."
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__zpl_file
msgid "ZPL File"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__zpl_filename
msgid "ZPL Filename"
msgstr ""
#. module: product_print_zpl_barcode
#: model:ir.model.fields,field_description:product_print_zpl_barcode.field_product_print_zpl_barcode__zpl_printer_id
msgid "ZPL Printer"
msgstr ""

View File

@@ -1 +1,2 @@
from . import product
from . import stock_picking

View File

@@ -29,22 +29,6 @@ class ProductTemplate(models.Model):
% (self.display_name, self.product_variant_count))
return self.product_variant_ids[0].generate_barcode_from_product_product()
def print_zpl_barcode_from_product_template(self):
self.ensure_one()
if self.product_variant_count != 1:
raise UserError(_(
"You cannot call the method "
"print_zpl_barcode_from_product_template on product '%s' "
"because it has %d variants and not just one.")
% (self.display_name, self.product_variant_count))
action = self.env["ir.actions.actions"]._for_xml_id(
'product_print_zpl_barcode.product_print_zpl_barcode_action')
action['context'] = {
'active_id': self.product_variant_ids[0].id,
'active_model': 'product.product',
}
return action
class ProductProduct(models.Model):
_inherit = 'product.product'

View File

@@ -0,0 +1,25 @@
# Copyright 2023 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
from odoo.tools import float_compare
class StockPicking(models.Model):
_inherit = "stock.picking"
show_print_zpl_barcode = fields.Boolean(compute='_compute_show_print_zpl_barcode')
@api.depends('state')
def _compute_show_print_zpl_barcode(self):
prec = self.env['decimal.precision'].precision_get('Product Unit of Measure')
for picking in self:
show = False
if picking.state == 'done' and picking.picking_type_code != 'outgoing':
for line in picking.move_line_ids:
if (
line.product_id.must_print_barcode and
float_compare(line.qty_done, 0, precision_digits=prec) > 0):
show = True
picking.show_print_zpl_barcode = show

View File

@@ -1,2 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_product_print_zpl_barcode,Full access to product.print.zpl.barcode wizard,model_product_print_zpl_barcode,base_report_to_printer.printing_group_user,1,1,1,1
access_product_print_zpl_barcode_line,Full access to product.print.zpl.barcode.line wizard,model_product_print_zpl_barcode_line,base_report_to_printer.printing_group_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_product_print_zpl_barcode Full access to product.print.zpl.barcode wizard model_product_print_zpl_barcode base_report_to_printer.printing_group_user 1 1 1 1
3 access_product_print_zpl_barcode_line Full access to product.print.zpl.barcode.line wizard model_product_print_zpl_barcode_line base_report_to_printer.printing_group_user 1 1 1 1

View File

@@ -27,7 +27,17 @@
<field name="arch" type="xml">
<button name="action_open_label_layout" position="after">
<button name="generate_barcode_from_product_template" type="object" string="Generate Barcode" attrs="{'invisible': ['|', ('product_variant_count', '>', 1), ('barcode', '!=', False)]}"/>
<button name="print_zpl_barcode_from_product_template" type="object" string="Print Barcode" groups="base_report_to_printer.printing_group_user" attrs="{'invisible': ['|', ('product_variant_count', '>', 1), ('barcode', '=', False)]}"/>
<button name="%(product_print_zpl_barcode.product_print_zpl_barcode_action)d" type="action" string="Print Barcode" groups="base_report_to_printer.printing_group_user" attrs="{'invisible': ['|', ('product_variant_count', '>', 1), ('barcode', '=', False)]}"/>
</button>
</field>
</record>
<record id="product_template_tree_view" model="ir.ui.view">
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_tree_view"/>
<field name="arch" type="xml">
<button name="action_open_label_layout" position="after">
<button name="%(product_print_zpl_barcode.product_print_zpl_barcode_action)d" type="action" string="Print Barcodes" groups="base_report_to_printer.printing_group_user"/>
</button>
</field>
</record>
@@ -44,5 +54,14 @@
</field>
</record>
<record id="product_product_tree_view" model="ir.ui.view">
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_product_tree_view"/>
<field name="arch" type="xml">
<button name="action_open_label_layout" position="after">
<button name="%(product_print_zpl_barcode.product_print_zpl_barcode_action)d" type="action" string="Print Barcodes" groups="base_report_to_printer.printing_group_user"/>
</button>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2023 Akretion France (http://www.akretion.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="view_picking_form" model="ir.ui.view">
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_form"/>
<field name="arch" type="xml">
<button name="action_toggle_is_locked" position="after">
<button name="%(product_print_zpl_barcode.product_print_zpl_barcode_action)d" type="action" string="Print Barcode" attrs="{'invisible': [('show_print_zpl_barcode', '=', False)]}"/>
<field name="show_print_zpl_barcode" invisible="1"/>
</button>
</field>
</record>
</odoo>

View File

@@ -1,4 +1,4 @@
# Copyright 2016-2020 Akretion France (http://www.akretion.com/)
# Copyright 2016-2023 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
@@ -9,23 +9,18 @@ from stdnum.ean import is_valid, calc_check_digit
import base64
import re
import logging
logger = logging.getLogger(__name__)
class ProductPrintZplBarcode(models.TransientModel):
_name = 'product.print.zpl.barcode'
_description = 'Generate and print product barcodes in ZPL'
_check_company_auto = True
@api.model
def default_get(self, fields_list):
res = super().default_get(fields_list)
assert self._context.get('active_model') == 'product.product',\
'wrong active_model, should be product.product'
product_id = self._context.get('active_id')
product = self.env['product.product'].browse(product_id)
if not product:
raise UserError(_('Missing Product'))
if not product.barcode:
raise UserError(_(
"Product '%s' doesn't have a barcode") % product.display_name)
nomenclature = self.env.ref('barcodes.default_barcode_nomenclature')
company = self.env.company
posconfig = self.env['pos.config'].sudo().search(
@@ -39,82 +34,200 @@ class ProductPrintZplBarcode(models.TransientModel):
], limit=1)
if not pricelist:
raise UserError(_(
"There are no pricelist in company %s ?") % company.name)
"There are no pricelist in company '%s'.") % company.name)
printer = self.env['printing.printer'].get_default()
line_ids = []
if self._context.get('active_model') == 'product.product':
product_ids = self._context.get('active_ids')
products = self.env['product.product'].browse(product_ids)
if not products:
raise UserError(_('Missing Products'))
for product in products:
self._update_line_ids(line_ids, product)
elif self._context.get('active_model') == 'product.template':
product_tmpl_ids = self._context.get('active_ids')
product_tmpls = self.env['product.template'].browse(product_tmpl_ids)
for product_tmpl in product_tmpls:
for product in product_tmpl.product_variant_ids:
self._update_line_ids(line_ids, product)
elif self._context.get('active_model') == 'stock.picking':
prec = self.env['decimal.precision'].precision_get(
'Product Unit of Measure')
picking = self.env['stock.picking'].browse(self._context['active_id'])
for ml in picking.move_line_ids:
if (
ml.product_id and
ml.product_id.must_print_barcode and
float_compare(ml.qty_done, 0, precision_digits=prec) > 0):
self._update_line_ids(
line_ids, ml.product_id, int(round(ml.qty_done)))
else:
raise UserError(_(
"Wrong active_model in context (%s).")
% self._context.get('active_model'))
res.update({
'company_id': company.id,
'nomenclature_id': nomenclature.id,
'pricelist_id': pricelist.id,
'currency_id': pricelist.currency_id.id,
'barcode': product.barcode,
'product_name': product.name,
'product_id': product_id,
'zpl_printer_id': printer and printer.id or False,
'line_ids': line_ids,
})
return res
product_id = fields.Many2one(
'product.product', string='Product', required=True, readonly=True)
uom_id = fields.Many2one(related='product_id.uom_id')
# 1 line = un peu moins de 30
product_name = fields.Char('Product Label', required=True, size=56)
@api.model
def _update_line_ids(self, line_ids, product, copies=1):
if product.barcode:
line_ids.append((0, 0, {
'barcode': product.barcode,
'product_name': product.name,
'product_id': product.id,
'copies': copies,
}))
else:
logger.warning("Product '%s' doesn't have a barcode", product.display_name)
company_id = fields.Many2one( # default value set by default_get
'res.company', required=True, ondelete='cascade')
nomenclature_id = fields.Many2one(
'barcode.nomenclature', 'Barcode Nomenclature', required=True)
rule_id = fields.Many2one(
'barcode.rule', string='Barcode Rule', readonly=True,
compute='_compute_rule_id')
barcode_type = fields.Selection(related='rule_id.type', string="Barcode Type")
'barcode.nomenclature', 'Barcode Nomenclature', required=True,
states={'step2': [('readonly', True)]})
# label_size: remove readonly=True when we will support more labels
label_size = fields.Selection([
('38x25', '38x25 mm'),
], required=True, default='38x25')
], required=True, default='38x25', readonly=True)
pricelist_id = fields.Many2one(
'product.pricelist', string='Pricelist', required=True)
currency_id = fields.Many2one(related='pricelist_id.currency_id')
# TODO: for the moment, we only support weight, but...
quantity = fields.Float(digits='Stock Weight')
price_uom = fields.Monetary(
readonly=True, string="Price per Unit of Measure",
compute='_compute_price') # given by pricelist
price = fields.Monetary(compute='_compute_price', readonly=True)
currency_id = fields.Many2one('res.currency', string='Currency')
'product.pricelist', string='Pricelist', required=True,
states={'step2': [('readonly', True)]}, check_company=True,
domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]"
)
state = fields.Selection([
('step1', 'Step1'),
('step2', 'Step2'),
], default='step1', readonly=True)
zpl_file = fields.Binary(string='ZPL File', readonly=True)
zpl_filename = fields.Char('ZPL Filename')
barcode = fields.Char(readonly=True)
copies = fields.Integer(
string='Number of Labels', default=1, required=True)
zpl_printer_id = fields.Many2one(
'printing.printer', string='ZPL Printer')
line_ids = fields.One2many(
'product.print.zpl.barcode.line', 'parent_id',
string='Lines', states={'step2': [('readonly', True)]})
@api.depends('pricelist_id', 'quantity', 'product_id')
def generate(self):
"""Called by button for the wizard, 1st step"""
self.ensure_one()
zpl_strings = []
for line in self.line_ids:
barcode = line.barcode
product_name = line.product_name
assert barcode
barcode_len = len(barcode)
if barcode_len not in (8, 13):
raise UserError(_(
"Line '%s': barcode '%s' has %d digits. "
"This wizard only supports EAN8 and EAN13 for the moment.")
% (product_name, barcode, barcode_len))
if not is_valid(barcode):
raise UserError(_(
"Line '%s': the barcode '%s' is not a valid EAN barcode "
"(wrong checksum).") % (product_name, barcode))
if line.copies <= 0:
raise UserError(_(
"On line '%s', the number of copies must be strictly positive."
) % product_name)
if line.barcode_type in ('price', 'weight'):
barcode, zpl_str = line._prepare_price_weight_barcode_type()
elif line.barcode_type == 'product':
barcode, zpl_str = line._prepare_product_barcode_type()
else:
raise UserError(_(
"Line '%s': barcode type '%s' is not supported for the moment")
% (product_name, line.barcode_type))
line.write({'barcode': barcode})
zpl_strings.append(zpl_str)
zpl_filename = "barcodes.zpl"
if len(self.line_ids) == 1:
zpl_filename = "barcode_%s.zpl" % self.line_ids[0].barcode
zpl_str = '\n'.join(zpl_strings)
zpl_bytes = zpl_str.encode('utf-8')
vals = {
'zpl_file': base64.encodebytes(zpl_bytes),
'state': 'step2',
'zpl_filename': zpl_filename,
}
self.write(vals)
action = self.env["ir.actions.actions"]._for_xml_id(
'product_print_zpl_barcode.product_print_zpl_barcode_action')
action.update({
'res_id': self.id,
'context': self._context,
'views': False})
return action
def print_zpl(self):
if not self.zpl_printer_id:
raise UserError(_(
"You must select a ZPL Printer."))
self.zpl_printer_id.print_document(
self.zpl_filename, base64.decodebytes(self.zpl_file), format='raw')
class ProductPrintZplBarcodeLine(models.TransientModel):
_name = 'product.print.zpl.barcode.line'
_description = 'Line of the print ZPL barcode wizard'
parent_id = fields.Many2one(
'product.print.zpl.barcode', ondelete='cascade')
product_id = fields.Many2one(
'product.product', string='Product', readonly=True)
uom_id = fields.Many2one(related='product_id.uom_id', string='UoM')
# 1 line = a bit less than 30
# I don't make product_name a stored computed field because I'm afraid
# that we may not take the lang of the user
product_name = fields.Char('Product Label', required=True, size=56)
rule_id = fields.Many2one(
'barcode.rule', string='Barcode Rule', compute='_compute_rule_id')
barcode_type = fields.Selection(related='rule_id.type', string="Barcode Type")
currency_id = fields.Many2one(related='parent_id.pricelist_id.currency_id')
# TODO: for the moment, we only support weight, but...
quantity = fields.Float(digits='Stock Weight', string='Qty')
price_uom = fields.Monetary(
string="Price/UoM", compute='_compute_price') # given by pricelist
price = fields.Monetary(compute='_compute_price')
barcode = fields.Char(readonly=True)
copies = fields.Integer(string='# Labels', default=1, required=True)
@api.depends('parent_id.pricelist_id', 'quantity', 'product_id')
def _compute_price(self):
# for regular barcodes
for wiz in self:
if wiz.pricelist_id and wiz.product_id:
price_uom = wiz.pricelist_id._get_product_price(
wiz.product_id, 1, False)
wiz.price_uom = price_uom
wiz.price = price_uom * wiz.quantity
for line in self:
pricelist = line.parent_id.pricelist_id
price_uom = price = 0.0
if pricelist and line.product_id:
price_uom = pricelist._get_product_price(line.product_id, 1, False)
price = price_uom * line.quantity
line.price_uom = price_uom
line.price = price
@api.depends('nomenclature_id')
@api.depends('parent_id.nomenclature_id')
def _compute_rule_id(self):
for wiz in self:
for line in self:
nomenclature = line.parent_id.nomenclature_id
match_rule = False
if wiz.nomenclature_id and wiz.barcode:
for rule in wiz.nomenclature_id.rule_ids:
match = wiz.nomenclature_id.match_pattern(
wiz.barcode, rule.pattern)
if nomenclature and line.barcode:
for rule in nomenclature.rule_ids:
match = nomenclature.match_pattern(
line.barcode, rule.pattern)
if match.get('match'):
match_rule = rule.id
break
wiz.rule_id = match_rule
line.rule_id = match_rule
def _prepare_price_weight_barcode_type(self):
dpo = self.env['decimal.precision']
bno = self.env['barcode.nomenclature']
prec = dpo.precision_get('Stock Weight')
value = self.quantity
pbarcode = self.barcode
@@ -139,7 +252,7 @@ class ProductPrintZplBarcode(models.TransientModel):
barcode = pbarcode[0:len(prefix)]
# print("barcode=", barcode)
# print("pattern=", pattern)
m = re.search('\{N+D+\}', pattern)
m = re.search(r'\{N+D+\}', pattern)
# print("m=", m)
assert m
pattern_val = m.group(0)
@@ -172,7 +285,7 @@ class ProductPrintZplBarcode(models.TransientModel):
assert len(barcode) == 13
assert is_valid(barcode)
# print("barcode FINAL=", barcode)
zpl_unicode = self._price_weight_barcode_type_zpl() % {
zpl_str = self._price_weight_barcode_type_zpl() % {
'product_name': self.product_name,
'ean_zpl_command': len(self.barcode) == 8 and 'B8' or 'BE',
'ean_no_checksum': barcode[:-1],
@@ -183,12 +296,7 @@ class ProductPrintZplBarcode(models.TransientModel):
'quantity': value,
'uom_name': self.uom_id.name,
}
zpl_bytes = zpl_unicode.encode('utf-8')
vals = {
'zpl_file': base64.encodebytes(zpl_bytes),
'barcode': barcode,
}
return vals
return (barcode, zpl_str)
@api.model
def _price_weight_barcode_type_zpl(self):
@@ -229,7 +337,7 @@ class ProductPrintZplBarcode(models.TransientModel):
return label
def _prepare_product_barcode_type(self):
zpl_unicode = self._product_barcode_type_zpl() % {
zpl_str = self._product_barcode_type_zpl() % {
'product_name': self.product_name,
'ean_zpl_command': len(self.barcode) == 8 and 'B8' or 'BE',
'ean_no_checksum': self.barcode[:-1],
@@ -237,60 +345,4 @@ class ProductPrintZplBarcode(models.TransientModel):
'currency_symbol': self.currency_id.symbol, # symbol is a required field
'copies': self.copies,
}
zpl_bytes = zpl_unicode.encode('utf-8')
vals = {
'zpl_file': base64.encodebytes(zpl_bytes),
'barcode': self.barcode, # unchanged
}
return vals
def generate(self):
assert self.barcode
if len(self.barcode) not in (8, 13):
raise UserError(_(
"This wizard only supports EAN8 and EAN13 for the moment. "
"Barcode '%s' has %d digits.") % (
self.barcode,
len(self.barcode)))
if not is_valid(self.barcode):
raise UserError(_(
"The barcode '%s' is not a valid EAN barcode "
"(wrong checksum).") % self.barcode)
if not self.copies:
raise UserError(_("The number of copies cannot be 0"))
if self.barcode_type in ('price', 'weight'):
vals = self._prepare_price_weight_barcode_type()
elif self.barcode_type == 'product':
vals = self._prepare_product_barcode_type()
else:
raise UserError(_(
"Barcode Type %s is not supported for the moment")
% self.barcode_type)
vals.update({
'state': 'step2',
'zpl_filename': 'barcode_%s.zpl' % vals['barcode'],
})
self.write(vals)
action = self.env["ir.actions.actions"]._for_xml_id(
'product_print_zpl_barcode.product_print_zpl_barcode_action')
action.update({
'res_id': self.id,
'context': self._context,
'views': False})
return action
def print_zpl(self):
if not self.zpl_printer_id:
raise UserError(_(
"You must select a ZPL Printer."))
self.zpl_printer_id.print_document(
self.zpl_filename, base64.decodebytes(self.zpl_file), format='raw')
action = True
if self._context.get('print_and_new'):
action = self.env["ir.actions.actions"]._for_xml_id(
'product_print_zpl_barcode.product_print_zpl_barcode_action')
action.update({
'views': False,
'context': self._context,
})
return action
return (self.barcode, zpl_str)

View File

@@ -11,38 +11,41 @@
<field name="name">product_print_zpl_barcode.form</field>
<field name="model">product.print.zpl.barcode</field>
<field name="arch" type="xml">
<form string="Generate and Print Product Barcode">
<group name="step1" string="Configuration">
<form>
<group name="step1">
<field name="state" invisible="1"/>
<field name="currency_id" invisible="1"/>
<field name="product_id"/>
<field name="product_name" attrs="{'readonly': [('state', '=', 'step2')]}"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="company_id" invisible="1"/>
<field name="pricelist_id" attrs="{'readonly': [('state', '=', 'step2')]}"/>
<field name="price_uom"/>
<field name="label_size" attrs="{'readonly': [('state', '=', 'step2')]}"/>
<field name="nomenclature_id" attrs="{'readonly': [('state', '=', 'step2')]}"/>
<field name="rule_id"/>
<field name="barcode_type"/>
<field name="barcode"/>
<field name="copies" attrs="{'readonly': [('state', '=', 'step2')]}"/>
</group>
<group string="Enter Quantity" attrs="{'invisible': [('barcode_type', '=', 'product')]}">
<label for="quantity"/>
<div name="qty_uom" class="o_row">
<field name="quantity" attrs="{'readonly': [('state', '=', 'step2')]}" class="oe_inline"/>
<field name="uom_id" class="oe_inline" style="margin-left: 5px"/> </div>
</group>
<group name="step2" states="step2" string="Label">
<field name="price" attrs="{'invisible': [('barcode_type', 'not in', ('price', 'weight'))]}"/>
<group name="step2" states="step2">
<field name="zpl_file" filename="zpl_filename" />
<field name="zpl_filename" invisible="1"/>
<field name="zpl_printer_id" attrs="{'required': [('state', '=', 'step2')]}"/>
</group>
<group name="lines">
<field name="line_ids" colspan="2" nolabel="1">
<tree editable="bottom">
<field name="currency_id" invisible="1"/>
<field name="product_id" optional="hide" force_save="1"/>
<field name="product_name"/>
<field name="price_uom"/>
<field name="rule_id" optional="show"/>
<field name="barcode_type" optional="hide"/>
<field name="barcode" force_save="1"/>
<field name="price" attrs="{'invisible': [('barcode_type', 'not in', ('price', 'weight'))]}"/>
<field name="quantity" attrs="{'invisible': [('barcode_type', '=', 'product')]}" optional="show"/>
<field name="uom_id" attrs="{'invisible': [('barcode_type', '=', 'product')]}" optional="show"/>
<field name="copies" />
</tree>
</field>
</group>
<footer>
<button name="generate" type="object" string="Generate Label" class="btn-primary" states="step1"/>
<button name="generate" type="object" string="Generate Labels" class="btn-primary" states="step1"/>
<button special="cancel" string="Cancel" class="btn-default" states="step1"/>
<button name="print_zpl" type="object" string="Print" class="btn-primary" states="step2"/>
<button name="print_zpl" type="object" string="Print and New" class="btn-primary" context="{'print_and_new': True}" attrs="{'invisible': ['|', ('state', '!=', 'step2'), ('barcode_type', '=', 'product')]}"/>
<button special="cancel" string="Close" class="btn-default" states="step2"/>
</footer>
</form>