-
-
Notifications
You must be signed in to change notification settings - Fork 525
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
[15.0][MIG] sequence_check_digit: Migration to 15.0 #697
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
9a2cda4
[ADD] Sequence check Digit (#1000)
etobella 5ba57c2
[MIG] sequence_check_digit: Migration to 11.0
etobella 59b0e54
[UPD] Update sequence_check_digit.pot
oca-travis 7a072a1
Translated using Weblate (Español (España))
etobella 904e1df
[12.0][MIG] sequence_check_digit
49d606d
[UPD] Update sequence_check_digit.pot
oca-travis 1b1b56f
[UPD] README.rst
OCA-git-bot bbcd0e5
Update translation files
oca-transbot 8af74a5
[IMP] sequence_check_digit: black, isort, prettier
00bd097
[13.0][MIG] sequence_check_digit
5ed039a
[UPD] Update sequence_check_digit.pot
oca-travis 2fc8d03
[IMP] sequence_check_digit: black, isort, prettier
schhatbar-initos d4e1e13
[14.0][MIG]sequence_check_digit
schhatbar-initos 048cc0c
[UPD] Update sequence_check_digit.pot
oca-travis bbd013a
[UPD] README.rst
OCA-git-bot 2d970d1
[14.0] [FIX] external_dependency python-stdnum
Shide 09ef9eb
sequence_check_digit 14.0.1.0.1
OCA-git-bot 0849bab
sequence_check_digit 14.0.1.0.2
OCA-git-bot 53fd392
[IMP] sequence_check_digit: black, isort, prettier
kaynnan 073c4f1
[MIG] sequence_check_digit: Migration to 15.0
kaynnan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
======================== | ||
Check Digit on Sequences | ||
======================== | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
.. |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-LGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html | ||
:alt: License: LGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--ux-lightgray.png?logo=github | ||
:target: https://github.com/OCA/server-ux/tree/14.0/sequence_check_digit | ||
:alt: OCA/server-ux | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/server-ux-14-0/server-ux-14-0-sequence_check_digit | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/250/14.0 | ||
:alt: Try me on Runbot | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module was written to configure check digits on sequences added on the end. | ||
It is useful as a control of the number on visual validation. | ||
|
||
It is useful when some manual checks are required or on integrations. | ||
The implemented codes can avoid modification of one character and flip of | ||
two consecutive characters. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
* Access sequences and configurate the model to use. | ||
* The model will check if the format of prefix, suffix and number is valid | ||
* Implemented algorithms | ||
* Luhn: [0-9]* | ||
* Damm: [0-9]* | ||
* Verhoeff: [0-9]* | ||
* ISO 7064 Mod 11, 2: [0-9]* | ||
* ISO 7064 Mod 11, 10: [0-9]* | ||
* ISO 7064 Mod 37, 2: [0-9A-Z]* | ||
* ISO 7064 Mod 37, 36: [0-9A-Z]* | ||
* ISO 7064 Mod 97, 10: [0-9A-Z]* | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-ux/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us smashing it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/server-ux/issues/new?body=module:%20sequence_check_digit%0Aversion:%2014.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 | ||
~~~~~~~ | ||
|
||
* Creu Blanca | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Enric Tobella <[email protected]> | ||
* Sunanda Chhatbar <[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/server-ux <https://github.com/OCA/server-ux/tree/14.0/sequence_check_digit>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). | ||
|
||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright (C) 2017 Creu Blanca | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). | ||
|
||
{ | ||
"name": "Check Digit on Sequences", | ||
"version": "15.0.1.0.0", | ||
"category": "Reporting", | ||
"website": "https://github.com/OCA/server-ux", | ||
"author": "Creu Blanca, Odoo Community Association (OCA)", | ||
"license": "LGPL-3", | ||
"installable": True, | ||
"application": False, | ||
"summary": "Adds a check digit on sequences", | ||
"depends": ["base"], | ||
"data": ["views/sequence_views.xml"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * sequence_check_digit | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 10.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2017-09-28 10:14+0000\n" | ||
"PO-Revision-Date: 2018-07-13 08:48+0000\n" | ||
"Last-Translator: Enric Tobella <[email protected]>\n" | ||
"Language-Team: \n" | ||
"Language: es\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: nplurals=2; plural=n != 1;\n" | ||
"X-Generator: Weblate 3.0.1\n" | ||
|
||
#. module: sequence_check_digit | ||
#: code:addons/sequence_check_digit/models/ir_sequence.py:45 | ||
#, python-format | ||
msgid "%s is not an implemented function" | ||
msgstr "%s no es una función implementada" | ||
|
||
#. module: sequence_check_digit | ||
#: model:ir.model.fields,field_description:sequence_check_digit.field_ir_sequence__check_digit_formula | ||
msgid "Check Digit Formula" | ||
msgstr "Fórmula del Dígito de control" | ||
|
||
#. module: sequence_check_digit | ||
#: selection:ir.sequence,check_digit_formula:0 | ||
msgid "Damm" | ||
msgstr "Damm" | ||
|
||
#. module: sequence_check_digit | ||
#: code:addons/sequence_check_digit/models/ir_sequence.py:39 | ||
#: code:addons/sequence_check_digit/models/ir_sequence.py:48 | ||
#, python-format | ||
msgid "Format is not accepted" | ||
msgstr "El formato no está aceptado" | ||
|
||
#. module: sequence_check_digit | ||
#: selection:ir.sequence,check_digit_formula:0 | ||
msgid "ISO 7064 Mod 11, 10" | ||
msgstr "ISO 7064 Mod 11, 10" | ||
|
||
#. module: sequence_check_digit | ||
#: selection:ir.sequence,check_digit_formula:0 | ||
msgid "ISO 7064 Mod 11, 2" | ||
msgstr "ISO 7064 Mod 11, 2" | ||
|
||
#. module: sequence_check_digit | ||
#: selection:ir.sequence,check_digit_formula:0 | ||
msgid "ISO 7064 Mod 37, 2" | ||
msgstr "ISO 7064 Mod 37, 2" | ||
|
||
#. module: sequence_check_digit | ||
#: selection:ir.sequence,check_digit_formula:0 | ||
msgid "ISO 7064 Mod 37, 36" | ||
msgstr "ISO 7064 Mod 37, 36" | ||
|
||
#. module: sequence_check_digit | ||
#: selection:ir.sequence,check_digit_formula:0 | ||
msgid "ISO 7064 Mod 97, 10" | ||
msgstr "ISO 7064 Mod 97, 10" | ||
|
||
#. module: sequence_check_digit | ||
#: selection:ir.sequence,check_digit_formula:0 | ||
msgid "Luhn" | ||
msgstr "Luhn" | ||
|
||
#. module: sequence_check_digit | ||
#: selection:ir.sequence,check_digit_formula:0 | ||
msgid "None" | ||
msgstr "Ninguno" | ||
|
||
#. module: sequence_check_digit | ||
#: model:ir.model,name:sequence_check_digit.model_ir_sequence | ||
#, fuzzy | ||
#| msgid "ir.sequence" | ||
msgid "Sequence" | ||
msgstr "ir.sequence" | ||
|
||
#. module: sequence_check_digit | ||
#: selection:ir.sequence,check_digit_formula:0 | ||
msgid "Verhoeff" | ||
msgstr "Verhoeff" | ||
|
||
#~ msgid "Function not found" | ||
#~ msgstr "Función no encontrada" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * sequence_check_digit | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0\n" | ||
"Report-Msgid-Bugs-To: \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: sequence_check_digit | ||
#: code:addons/sequence_check_digit/models/ir_sequence.py:0 | ||
#, python-format | ||
msgid "%s is not an implemented function" | ||
msgstr "" | ||
|
||
#. module: sequence_check_digit | ||
#: model:ir.model.fields,field_description:sequence_check_digit.field_ir_sequence__check_digit_formula | ||
msgid "Check Digit Formula" | ||
msgstr "" | ||
|
||
#. module: sequence_check_digit | ||
#: model:ir.model.fields.selection,name:sequence_check_digit.selection__ir_sequence__check_digit_formula__damm | ||
msgid "Damm" | ||
msgstr "" | ||
|
||
#. module: sequence_check_digit | ||
#: model:ir.model.fields,field_description:sequence_check_digit.field_ir_sequence__display_name | ||
msgid "Display Name" | ||
msgstr "" | ||
|
||
#. module: sequence_check_digit | ||
#: code:addons/sequence_check_digit/models/ir_sequence.py:0 | ||
#: code:addons/sequence_check_digit/models/ir_sequence.py:0 | ||
#, python-format | ||
msgid "Format is not accepted" | ||
msgstr "" | ||
|
||
#. module: sequence_check_digit | ||
#: model:ir.model.fields,field_description:sequence_check_digit.field_ir_sequence__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: sequence_check_digit | ||
#: model:ir.model.fields.selection,name:sequence_check_digit.selection__ir_sequence__check_digit_formula__iso7064_11_10 | ||
msgid "ISO 7064 Mod 11, 10" | ||
msgstr "" | ||
|
||
#. module: sequence_check_digit | ||
#: model:ir.model.fields.selection,name:sequence_check_digit.selection__ir_sequence__check_digit_formula__iso7064_11_2 | ||
msgid "ISO 7064 Mod 11, 2" | ||
msgstr "" | ||
|
||
#. module: sequence_check_digit | ||
#: model:ir.model.fields.selection,name:sequence_check_digit.selection__ir_sequence__check_digit_formula__iso7064_37_2 | ||
msgid "ISO 7064 Mod 37, 2" | ||
msgstr "" | ||
|
||
#. module: sequence_check_digit | ||
#: model:ir.model.fields.selection,name:sequence_check_digit.selection__ir_sequence__check_digit_formula__iso7064_37_36 | ||
msgid "ISO 7064 Mod 37, 36" | ||
msgstr "" | ||
|
||
#. module: sequence_check_digit | ||
#: model:ir.model.fields.selection,name:sequence_check_digit.selection__ir_sequence__check_digit_formula__iso7064_97_10 | ||
msgid "ISO 7064 Mod 97, 10" | ||
msgstr "" | ||
|
||
#. module: sequence_check_digit | ||
#: model:ir.model.fields,field_description:sequence_check_digit.field_ir_sequence____last_update | ||
msgid "Last Modified on" | ||
msgstr "" | ||
|
||
#. module: sequence_check_digit | ||
#: model:ir.model.fields.selection,name:sequence_check_digit.selection__ir_sequence__check_digit_formula__luhn | ||
msgid "Luhn" | ||
msgstr "" | ||
|
||
#. module: sequence_check_digit | ||
#: model:ir.model.fields.selection,name:sequence_check_digit.selection__ir_sequence__check_digit_formula__none | ||
msgid "None" | ||
msgstr "" | ||
|
||
#. module: sequence_check_digit | ||
#: model:ir.model,name:sequence_check_digit.model_ir_sequence | ||
msgid "Sequence" | ||
msgstr "" | ||
|
||
#. module: sequence_check_digit | ||
#: model:ir.model.fields.selection,name:sequence_check_digit.selection__ir_sequence__check_digit_formula__verhoeff | ||
msgid "Verhoeff" | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). | ||
|
||
from . import ir_sequence |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Copyright (C) 2017 Creu Blanca | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). | ||
|
||
import logging | ||
|
||
from odoo import _, api, fields, models | ||
from odoo.exceptions import ValidationError | ||
|
||
_logger = logging.getLogger(__name__) | ||
try: | ||
from stdnum import damm, luhn, verhoeff | ||
from stdnum.iso7064 import mod_11_2, mod_11_10, mod_37_2, mod_37_36, mod_97_10 | ||
except (ImportError, IOError) as err: | ||
_logger.debug(err) | ||
|
||
|
||
class IrSequence(models.Model): | ||
_inherit = "ir.sequence" | ||
|
||
check_digit_formula = fields.Selection( | ||
selection=[ | ||
("none", "None"), | ||
("luhn", "Luhn"), | ||
("damm", "Damm"), | ||
("verhoeff", "Verhoeff"), | ||
("ISO7064_11_2", "ISO 7064 Mod 11, 2"), | ||
("ISO7064_11_10", "ISO 7064 Mod 11, 10"), | ||
("ISO7064_37_2", "ISO 7064 Mod 37, 2"), | ||
("ISO7064_37_36", "ISO 7064 Mod 37, 36"), | ||
("ISO7064_97_10", "ISO 7064 Mod 97, 10"), | ||
], | ||
default="none", | ||
) | ||
|
||
@api.constrains("check_digit_formula", "prefix", "suffix") | ||
def check_check_digit_formula(self): | ||
try: | ||
self.get_next_char(0) | ||
except Exception: | ||
raise ValidationError(_("Format is not accepted")) from None | ||
|
||
def get_check_digit(self, code): | ||
try: | ||
return self.get_formula_map()[self.check_digit_formula](code) | ||
except KeyError: | ||
raise ValidationError( | ||
_("%s is not an implemented function") % self.check_digit_formula | ||
) from None | ||
except Exception: | ||
raise ValidationError(_("Format is not accepted")) from None | ||
|
||
def get_formula_map(self): | ||
return { | ||
"none": lambda _: "", | ||
"luhn": luhn.calc_check_digit, | ||
"damm": damm.calc_check_digit, | ||
"verhoeff": verhoeff.calc_check_digit, | ||
"ISO7064_11_2": mod_11_2.calc_check_digit, | ||
"ISO7064_11_10": mod_11_10.calc_check_digit, | ||
"ISO7064_37_2": mod_37_2.calc_check_digit, | ||
"ISO7064_37_36": mod_37_36.calc_check_digit, | ||
"ISO7064_97_10": mod_97_10.calc_check_digits, | ||
} | ||
|
||
def get_next_char(self, number_next): | ||
code = super(IrSequence, self).get_next_char(number_next) | ||
if not self.check_digit_formula: | ||
return code | ||
return "{}{}".format(code, self.get_check_digit(code)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* Enric Tobella <[email protected]> | ||
* Sunanda Chhatbar <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
This module was written to configure check digits on sequences added on the end. | ||
It is useful as a control of the number on visual validation. | ||
|
||
It is useful when some manual checks are required or on integrations. | ||
The implemented codes can avoid modification of one character and flip of | ||
two consecutive characters. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you add the from None?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to the suggestion made by the pre-commit