diff --git a/delivery_package_sscc/README.rst b/delivery_package_sscc/README.rst new file mode 100644 index 0000000000..01c30c0cdb --- /dev/null +++ b/delivery_package_sscc/README.rst @@ -0,0 +1,106 @@ +========================== +Delivery package SSCC code +========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:9c6c3abee558c7614053ee5e117d94a1a118de602ee148ef9df43ea4ccf536c1 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fdelivery--carrier-lightgray.png?logo=github + :target: https://github.com/OCA/delivery-carrier/tree/16.0/delivery_package_sscc + :alt: OCA/delivery-carrier +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/delivery-carrier-16-0/delivery-carrier-16-0-delivery_package_sscc + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/delivery-carrier&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to generate SSCC codes for packages automatically. + +SSCC codes are explained here: https://www.gs1.org/standards/id-keys/sscc + +Typically, a company registers a range of 1000, 10000 or more SSCC codes which +they can then use as barcodes on their packages. These are unique, and once +they run out, new ones are bought. + +With this module, you can modify Odoo's package number sequence to pick SSCC +codes from your range, instead of using the standard PACK00001, PACK00002 etc. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to: + +* Identify your SSCC range. For example: `123456789012xxxxx`. +* Go to the form view of the `ir.sequence` record for your packages. +* Change the Padding field to the number of variable digits. + In the above example, it would be 5. +* Go to the Python tab +* Enable the 'Use Python' checkbox +* Change the default 'number' expression to: + +.. code-block:: python + + # Note that you have to adapt this to your own range. + "123456789012" + number_padded + str(get_barcode_check_digit("123456789012" + number_padded + "x")) + +Now, your packages will generate with SSCC codes instead of regular sequence numbers such as PACK00001. +Once the numbers run out, you'll have to configure this again with a new sequence. + +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 +~~~~~~~ + +* Therp BV + +Contributors +~~~~~~~~~~~~ + +* Tom Blauwendraat + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +This module is part of the `OCA/delivery-carrier `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/delivery_package_sscc/__init__.py b/delivery_package_sscc/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/delivery_package_sscc/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/delivery_package_sscc/__manifest__.py b/delivery_package_sscc/__manifest__.py new file mode 100644 index 0000000000..3a747f2955 --- /dev/null +++ b/delivery_package_sscc/__manifest__.py @@ -0,0 +1,13 @@ +# Copyright 2024 Therp BV() +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Delivery package SSCC code", + "summary": """Automatically select the package number from a given range of SSCC codes""", + "author": "Therp BV,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/delivery-carrier", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "category": "Delivery", + "depends": ["stock", "sequence_python"], + "data": [], +} diff --git a/delivery_package_sscc/models/__init__.py b/delivery_package_sscc/models/__init__.py new file mode 100644 index 0000000000..5b015772ab --- /dev/null +++ b/delivery_package_sscc/models/__init__.py @@ -0,0 +1 @@ +from . import ir_sequence diff --git a/delivery_package_sscc/models/ir_sequence.py b/delivery_package_sscc/models/ir_sequence.py new file mode 100644 index 0000000000..d391400f41 --- /dev/null +++ b/delivery_package_sscc/models/ir_sequence.py @@ -0,0 +1,19 @@ +# Copyright 2024 Therp BV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models +from odoo.tools.barcode import get_barcode_check_digit + + +class IrSequence(models.Model): + _inherit = "ir.sequence" + + def _get_python_eval_context(self, number_next): + res = super()._get_python_eval_context(number_next) + # This function can be used to calculate the value of the + # check digit at the end of a barcode. + return res.update( + { + "get_barcode_check_digit": get_barcode_check_digit, + } + ) diff --git a/delivery_package_sscc/readme/CONTRIBUTORS.rst b/delivery_package_sscc/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..36efafcf46 --- /dev/null +++ b/delivery_package_sscc/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Tom Blauwendraat diff --git a/delivery_package_sscc/readme/DESCRIPTION.rst b/delivery_package_sscc/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..ceaa8db92c --- /dev/null +++ b/delivery_package_sscc/readme/DESCRIPTION.rst @@ -0,0 +1,10 @@ +This module allows to generate SSCC codes for packages automatically. + +SSCC codes are explained here: https://www.gs1.org/standards/id-keys/sscc + +Typically, a company registers a range of 1000, 10000 or more SSCC codes which +they can then use as barcodes on their packages. These are unique, and once +they run out, new ones are bought. + +With this module, you can modify Odoo's package number sequence to pick SSCC +codes from your range, instead of using the standard PACK00001, PACK00002 etc. diff --git a/delivery_package_sscc/readme/USAGE.rst b/delivery_package_sscc/readme/USAGE.rst new file mode 100644 index 0000000000..6fd6329da5 --- /dev/null +++ b/delivery_package_sscc/readme/USAGE.rst @@ -0,0 +1,17 @@ +To use this module, you need to: + +* Identify your SSCC range. For example: `123456789012xxxxx`. +* Go to the form view of the `ir.sequence` record for your packages. +* Change the Padding field to the number of variable digits. + In the above example, it would be 5. +* Go to the Python tab +* Enable the 'Use Python' checkbox +* Change the default 'number' expression to: + +.. code-block:: python + + # Note that you have to adapt this to your own range. + "123456789012" + number_padded + str(get_barcode_check_digit("123456789012" + number_padded + "x")) + +Now, your packages will generate with SSCC codes instead of regular sequence numbers such as PACK00001. +Once the numbers run out, you'll have to configure this again with a new sequence. diff --git a/delivery_package_sscc/static/description/icon.png b/delivery_package_sscc/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/delivery_package_sscc/static/description/icon.png differ diff --git a/delivery_package_sscc/static/description/index.html b/delivery_package_sscc/static/description/index.html new file mode 100644 index 0000000000..3ad594f7cc --- /dev/null +++ b/delivery_package_sscc/static/description/index.html @@ -0,0 +1,449 @@ + + + + + +Delivery package SSCC code + + + +
+

Delivery package SSCC code

+ + +

Beta License: AGPL-3 OCA/delivery-carrier Translate me on Weblate Try me on Runboat

+

This module allows to generate SSCC codes for packages automatically.

+

SSCC codes are explained here: https://www.gs1.org/standards/id-keys/sscc

+

Typically, a company registers a range of 1000, 10000 or more SSCC codes which +they can then use as barcodes on their packages. These are unique, and once +they run out, new ones are bought.

+

With this module, you can modify Odoo’s package number sequence to pick SSCC +codes from your range, instead of using the standard PACK00001, PACK00002 etc.

+

Table of contents

+ +
+

Usage

+

To use this module, you need to:

+
    +
  • Identify your SSCC range. For example: 123456789012xxxxx.
  • +
  • Go to the form view of the ir.sequence record for your packages.
  • +
  • Change the Padding field to the number of variable digits. +In the above example, it would be 5.
  • +
  • Go to the Python tab
  • +
  • Enable the ‘Use Python’ checkbox
  • +
  • Change the default ‘number’ expression to:
  • +
+
+# Note that you have to adapt this to your own range.
+"123456789012" + number_padded + str(get_barcode_check_digit("123456789012" + number_padded + "x"))
+
+

Now, your packages will generate with SSCC codes instead of regular sequence numbers such as PACK00001. +Once the numbers run out, you’ll have to configure this again with a new sequence.

+
+
+

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

+
    +
  • Therp BV
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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.

+

This module is part of the OCA/delivery-carrier project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/delivery_package_sscc/tests/__init__.py b/delivery_package_sscc/tests/__init__.py new file mode 100644 index 0000000000..b251d4327b --- /dev/null +++ b/delivery_package_sscc/tests/__init__.py @@ -0,0 +1,3 @@ +# Copyright 2024 Therp BV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import test_ir_sequence diff --git a/delivery_package_sscc/tests/test_ir_sequence.py b/delivery_package_sscc/tests/test_ir_sequence.py new file mode 100644 index 0000000000..c88f23c535 --- /dev/null +++ b/delivery_package_sscc/tests/test_ir_sequence.py @@ -0,0 +1,31 @@ +# Copyright 2024 Therp BV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.tests.common import TransactionCase + + +class TestSsccSequence(TransactionCase): + def test_sscc_sequence(self): + package_sequence = self.env.ref("stock.seq_quant_package") + package_sequence.padding = 5 + package_sequence.use_python_code = True + package_sequence.python_code = ( + "'123456789012' + number_padded " + "+ str(get_barcode_check_digit('123456789012' + number_padded + 'x'))" + ) + + package = self.env["stock.quant.package"].create( + { + "name": "Package 1", + } + ) + sscc1 = package.name + self.assertTrue(package.valid_sscc) + package = self.env["stock.quant.package"].create( + { + "name": "Package 2", + } + ) + sscc2 = package.name + self.assertTrue(package.valid_sscc) + self.assertNotEqual(sscc1, sscc2) diff --git a/setup/delivery_package_sscc/odoo/addons/delivery_package_sscc b/setup/delivery_package_sscc/odoo/addons/delivery_package_sscc new file mode 120000 index 0000000000..3250af2db3 --- /dev/null +++ b/setup/delivery_package_sscc/odoo/addons/delivery_package_sscc @@ -0,0 +1 @@ +../../../../delivery_package_sscc \ No newline at end of file diff --git a/setup/delivery_package_sscc/setup.py b/setup/delivery_package_sscc/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/delivery_package_sscc/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)