Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][ADD] delivery_package_sscc #902

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <tblauwendraat@therp.nl>

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
20 changes: 20 additions & 0 deletions delivery_package_sscc/models/ir_sequence.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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.
res.update(
{
"get_barcode_check_digit": get_barcode_check_digit,
}
)
return res
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 <tblauwendraat@therp.nl>
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.
18 changes: 18 additions & 0 deletions delivery_package_sscc/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
To use this module, you need to:

* Identify your SSCC range. For example: `123456789012xxxxx`.
* Go to the form view of the sequence record for your packages.
* Clear the Prefix field (eg from `PACK` to empty)
* Set the Sequence Size (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
Loading