From 50096735a3ac1fd926dc392e7a5de748663ead99 Mon Sep 17 00:00:00 2001 From: Chafique Date: Fri, 11 Dec 2020 15:28:25 +0100 Subject: [PATCH] [MIG] barcodes_generator_abstract: Migration to 14.0 --- barcodes_generator_abstract/__manifest__.py | 4 +-- .../models/barcode_generate_mixin.py | 2 -- .../models/barcode_rule.py | 7 +---- .../readme/CONFIGURE.rst | 23 ++++++++++++++++ .../readme/CONTRIBUTORS.rst | 2 ++ .../readme/DESCRIPTION.rst | 21 +++++++++++++++ .../readme/INSTALL.rst | 4 +++ barcodes_generator_abstract/readme/USAGE.rst | 27 +++++++++++++++++++ 8 files changed, 80 insertions(+), 10 deletions(-) create mode 100644 barcodes_generator_abstract/readme/CONFIGURE.rst create mode 100644 barcodes_generator_abstract/readme/CONTRIBUTORS.rst create mode 100644 barcodes_generator_abstract/readme/DESCRIPTION.rst create mode 100644 barcodes_generator_abstract/readme/INSTALL.rst create mode 100644 barcodes_generator_abstract/readme/USAGE.rst diff --git a/barcodes_generator_abstract/__manifest__.py b/barcodes_generator_abstract/__manifest__.py index 8f1f1386ab8e..a2f6cb2a30b1 100644 --- a/barcodes_generator_abstract/__manifest__.py +++ b/barcodes_generator_abstract/__manifest__.py @@ -7,9 +7,9 @@ { "name": "Generate Barcodes (Abstract)", "summary": "Generate Barcodes for Any Models", - "version": "12.0.1.0.2", + "version": "14.0.1.0.0", "category": "Tools", - "author": "GRAP, " "La Louve, " "LasLabs, " "Odoo Community Association (OCA)", + "author": "GRAP, La Louve, LasLabs, Odoo Community Association (OCA)", "website": "https://github.com/OCA/stock-logistics-barcode", "license": "AGPL-3", "depends": [ diff --git a/barcodes_generator_abstract/models/barcode_generate_mixin.py b/barcodes_generator_abstract/models/barcode_generate_mixin.py index fdc282e204c5..621d097b3334 100644 --- a/barcodes_generator_abstract/models/barcode_generate_mixin.py +++ b/barcodes_generator_abstract/models/barcode_generate_mixin.py @@ -54,7 +54,6 @@ def create(self, vals): return record # View Section - @api.multi def generate_base(self): for item in self: if item.generate_type != "sequence": @@ -67,7 +66,6 @@ def generate_base(self): else: item.barcode_base = item.barcode_rule_id.sequence_id.next_by_id() - @api.multi def generate_barcode(self): for item in self: padding = item.barcode_rule_id.padding diff --git a/barcodes_generator_abstract/models/barcode_rule.py b/barcodes_generator_abstract/models/barcode_rule.py index dd92a299c093..53f532de1ca5 100644 --- a/barcodes_generator_abstract/models/barcode_rule.py +++ b/barcodes_generator_abstract/models/barcode_rule.py @@ -51,21 +51,18 @@ class BarcodeRule(models.Model): # Compute Section @api.depends("pattern") - @api.multi def _compute_padding(self): for rule in self: rule.padding = rule.pattern.count(".") # On Change Section @api.onchange("generate_type") - @api.multi def onchange_generate_type(self): for rule in self: if rule.generate_type == "no": rule.generate_model = False # Constrains Section - @api.multi @api.constrains("generate_model", "generate_automate") def _check_generate_model_automate(self): """It should not allow two automated barcode generators per model. @@ -94,13 +91,11 @@ def create(self, vals): self._clear_cache(vals) return super(BarcodeRule, self).create(vals) - @api.multi def write(self, vals): self._clear_cache(vals) return super(BarcodeRule, self).write(vals) # View Section - @api.multi def generate_sequence(self): sequence_obj = self.env["ir.sequence"] for rule in self: @@ -156,7 +151,7 @@ def get_automatic_rule_ids(self, model): ) return record.ids - @api.model_cr_context + @api.model def _clear_cache(self, vals): """It clears the caches if certain vals are updated.""" fields = ("generate_model", "generate_automate") diff --git a/barcodes_generator_abstract/readme/CONFIGURE.rst b/barcodes_generator_abstract/readme/CONFIGURE.rst new file mode 100644 index 000000000000..26a6c83f85ad --- /dev/null +++ b/barcodes_generator_abstract/readme/CONFIGURE.rst @@ -0,0 +1,23 @@ +To configure this module, you need to: + +* Go to Settings / Technical / Sequences & Identifiers / Barcode Nomenclatures +* Select a Nomenclature +* Create or select a rule + +.. image:: /barcodes_generator_abstract/static/description/barcode_rule_tree.png + +* For manual generation, set: + * 'Base set Manually' in 'Generate Type' + * Set the model + +.. image:: /barcodes_generator_abstract/static/description/barcode_rule_form_manual.png + +* 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 + +.. image:: /barcodes_generator_abstract/static/description/barcode_rule_form_sequence.png + +In all cases, padding will be computed automaticaly, based on the number +of '.' in the Barcode Pattern field. diff --git a/barcodes_generator_abstract/readme/CONTRIBUTORS.rst b/barcodes_generator_abstract/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..3fe1a59a724f --- /dev/null +++ b/barcodes_generator_abstract/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Sylvain LE GAL (https://twitter.com/legalsylvain) +* Dave Lasley diff --git a/barcodes_generator_abstract/readme/DESCRIPTION.rst b/barcodes_generator_abstract/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..1cb16b7896a8 --- /dev/null +++ b/barcodes_generator_abstract/readme/DESCRIPTION.rst @@ -0,0 +1,21 @@ +This module expends Odoo functionality, allowing user to generate barcode +depending on a given barcode rule for any Model. + +For example, a typical pattern for products is "20.....{NNNDD}" that means +that: +* the EAN13 code will begin by '20' +* followed by 5 digits (named Barcode Base in this module) +* and after 5 others digits to define the variable price +* a 13 digit control + +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) + * automaticaly by a sequence, if you want to let Odoo to increment a + sequence. (typical case of a customer number incrementation) + +* Generate a barcode, based on the defined pattern and the barcode base diff --git a/barcodes_generator_abstract/readme/INSTALL.rst b/barcodes_generator_abstract/readme/INSTALL.rst new file mode 100644 index 000000000000..2ce690c2f68e --- /dev/null +++ b/barcodes_generator_abstract/readme/INSTALL.rst @@ -0,0 +1,4 @@ +This module use an extra python library named 'python-barcode' you should install +to make barcode generation works properly. + +``sudo pip install python-barcode`` diff --git a/barcodes_generator_abstract/readme/USAGE.rst b/barcodes_generator_abstract/readme/USAGE.rst new file mode 100644 index 000000000000..21aab7f2df10 --- /dev/null +++ b/barcodes_generator_abstract/readme/USAGE.rst @@ -0,0 +1,27 @@ +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. + +If you want to generate barcode for another model, you can create a custom +module that inherits 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')]) + +Finally, you should inherit your model view adding buttons and fields. + +Note +---- + +Your model should have a field 'barcode' defined.