Skip to content

Commit

Permalink
[ADD] delivery_package_sscc
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaspaulb committed Nov 11, 2024
1 parent 2b06300 commit 1002c97
Show file tree
Hide file tree
Showing 14 changed files with 658 additions and 0 deletions.
106 changes: 106 additions & 0 deletions delivery_package_sscc/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/OCA/delivery-carrier/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 <https://github.com/OCA/delivery-carrier/issues/new?body=module:%20delivery_package_sscc%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Therp BV

Contributors
~~~~~~~~~~~~

* Tom Blauwendraat <[email protected]>

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 <https://github.com/OCA/delivery-carrier/tree/16.0/delivery_package_sscc>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions delivery_package_sscc/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
13 changes: 13 additions & 0 deletions delivery_package_sscc/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2024 Therp BV(<https://therp.nl>)
# 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": [],
}
1 change: 1 addition & 0 deletions delivery_package_sscc/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import ir_sequence
19 changes: 19 additions & 0 deletions delivery_package_sscc/models/ir_sequence.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2024 Therp BV (<https://therp.nl>)
# 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,
}
)
1 change: 1 addition & 0 deletions delivery_package_sscc/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Tom Blauwendraat <[email protected]>
10 changes: 10 additions & 0 deletions delivery_package_sscc/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -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.
17 changes: 17 additions & 0 deletions delivery_package_sscc/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -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.
Binary file added delivery_package_sscc/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 1002c97

Please sign in to comment.