Skip to content

Commit

Permalink
[MIG][17.0] sequence_python
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaspaulb committed Nov 12, 2024
1 parent ef360a8 commit e61370d
Show file tree
Hide file tree
Showing 16 changed files with 1,193 additions and 0 deletions.
117 changes: 117 additions & 0 deletions sequence_python/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
===============================
Sequence from Python expression
===============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:2577b1699eaf32186615d1426d69a461c185cd70423a76700e336c09cf5c7056
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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%2Fserver--tools-lightgray.png?logo=github
:target: https://github.com/OCA/server-tools/tree/16.0/sequence_python
:alt: OCA/server-tools
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-sequence_python
: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/server-tools&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows to generate a sequence by a Python formula expression.

Besides common Python functions and operators, it provides several functions
like 'random' and 'uuid' in the expression, as well as variables such as the
next number in the sequence. These are also listed next to the input field
on the sequence form view.

If you want to add more variables for use in the expression, you can extend
this module.

Use cases for this module could be:

- You want to generate alphanumeric numbering
- You want to apply some math to the number to prevent customers from knowing
their place in the sequence
- You want to use UUID

**Table of contents**

.. contents::
:local:

Usage
=====

To use this module, you need to:

* Go to the form view of an `ir.sequence` record
* Go to the Python tab
* Enable the 'Use Python' checkbox
* Change the default 'number' expression to something more fancy.

Examples:

.. code-block:: python
# To separate the Odoo-generated number with hyphens eg. 0-0-0-0-1
'-'.join(number_padded)
# To have an UUID as the sequence value
uuid.uuid4().hex
# To use an 8-digit binary number
'{0:#010b}'.format(number + 300)[2:]
And so on.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/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/server-tools/issues/new?body=module:%20sequence_python%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
~~~~~~~

* Sunflower IT

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

* Tom Blauwendraat <[email protected]>
* Francesco Apruzzese <[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-tools <https://github.com/OCA/server-tools/tree/16.0/sequence_python>`_ 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 sequence_python/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
13 changes: 13 additions & 0 deletions sequence_python/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2020 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Sequence from Python expression",
"summary": """Calculate a sequence number from a Python expression""",
"author": "Therp BV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/server-tools",
"version": "17.0.1.0.0",
"license": "AGPL-3",
"category": "Generic Modules",
"depends": ["base"],
"data": ["views/ir_sequence.xml"],
}
129 changes: 129 additions & 0 deletions sequence_python/i18n/ca.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sequence_python
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: ca\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"

#. module: sequence_python
#: model_terms:ir.ui.view,arch_db:sequence_python.sequence_view
msgid "<code>number</code>: The next number of the sequence (integer)"
msgstr ""

#. module: sequence_python
#: model_terms:ir.ui.view,arch_db:sequence_python.sequence_view
msgid ""
"<code>number_padded</code>: Padded string of the next number of the sequence"
msgstr ""

#. module: sequence_python
#: model_terms:ir.ui.view,arch_db:sequence_python.sequence_view
msgid ""
"<code>random</code>: The Python random module, eg. to use "
"<code>random.randint(0, 9)</code>"
msgstr ""

#. module: sequence_python
#: model_terms:ir.ui.view,arch_db:sequence_python.sequence_view
msgid "<code>sequence</code>: Odoo record of the sequence being used"
msgstr ""

#. module: sequence_python
#: model_terms:ir.ui.view,arch_db:sequence_python.sequence_view
msgid ""
"<code>string</code>: The Python string module, eg. to use "
"<code>random.choices(string.ascii_letters + string.digits, k=4)</code>"
msgstr ""

#. module: sequence_python
#: model_terms:ir.ui.view,arch_db:sequence_python.sequence_view
msgid ""
"<code>uuid</code>: The Python uuid module, eg. to use "
"<code>uuid.uuid4()</code>"
msgstr ""

#. module: sequence_python
#: model_terms:ir.ui.view,arch_db:sequence_python.sequence_view
msgid "Aside from this, you may use several"
msgstr ""

#. module: sequence_python
#: model:ir.model.fields,field_description:sequence_python.field_ir_sequence__display_name
msgid "Display Name"
msgstr ""

#. module: sequence_python
#: model_terms:ir.ui.view,arch_db:sequence_python.sequence_view
msgid "Help with Python expressions"
msgstr ""

#. module: sequence_python
#: model:ir.model.fields,field_description:sequence_python.field_ir_sequence__id
msgid "ID"
msgstr ""

#. module: sequence_python
#: model:ir.model.fields,field_description:sequence_python.field_ir_sequence____last_update
msgid "Last Modified on"
msgstr ""

#. module: sequence_python
#: model:ir.model.fields,field_description:sequence_python.field_ir_sequence__python_code_preview
msgid "Preview"
msgstr ""

#. module: sequence_python
#: model_terms:ir.ui.view,arch_db:sequence_python.sequence_view
msgid "Python Code"
msgstr ""

#. module: sequence_python
#: model:ir.model.fields,field_description:sequence_python.field_ir_sequence__python_code
msgid "Python expression"
msgstr ""

#. module: sequence_python
#: model:ir.model,name:sequence_python.model_ir_sequence
msgid "Sequence"
msgstr ""

#. module: sequence_python
#: model:ir.model.fields,field_description:sequence_python.field_ir_sequence__smart_search
msgid "Smart Search"
msgstr ""

#. module: sequence_python
#: model_terms:ir.ui.view,arch_db:sequence_python.sequence_view
msgid ""
"The expression you type here will be evaluated as the next number. The "
"following variables can be used:"
msgstr ""

#. module: sequence_python
#: model:ir.model.fields,field_description:sequence_python.field_ir_sequence__use_python_code
msgid "Use Python"
msgstr ""

#. module: sequence_python
#: model:ir.model.fields,help:sequence_python.field_ir_sequence__python_code
msgid "Write Python code that generates the sequence body."
msgstr ""

#. module: sequence_python
#: model_terms:ir.ui.view,arch_db:sequence_python.sequence_view
msgid "builtin Python functions"
msgstr ""

#. module: sequence_python
#: model_terms:ir.ui.view,arch_db:sequence_python.sequence_view
msgid "number"
msgstr ""
Loading

0 comments on commit e61370d

Please sign in to comment.