diff --git a/pos_session_sequence/README.rst b/pos_session_sequence/README.rst new file mode 100644 index 0000000000..81166aba58 --- /dev/null +++ b/pos_session_sequence/README.rst @@ -0,0 +1,98 @@ +==================== +POS Session Sequence +==================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:05fc8398bd86dc5479e2d48e58dd8b2e0caa391b1719f129270532a3ffe613cd + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fpos-lightgray.png?logo=github + :target: https://github.com/OCA/pos/tree/17.0/pos_session_sequence + :alt: OCA/pos +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/pos-17-0/pos-17-0-pos_session_sequence + :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/pos&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows you to configure multiple sequences for every session +in different points of sale. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to: + +- Go to Configuration > Settings +- Setup ``Session Ids Sequence`` for the Point of Sale +- Open the session for the point of sale and you will see the name + computed with the 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 +------- + +* Antoni Marroig +* APSL-Nagarro + +Contributors +------------ + +[APSL-Nagarro](https://apsl.tech): + +- Antoni Marroig + +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. + +.. |maintainer-peluko00| image:: https://github.com/peluko00.png?size=40px + :target: https://github.com/peluko00 + :alt: peluko00 + +Current `maintainer `__: + +|maintainer-peluko00| + +This module is part of the `OCA/pos `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/pos_session_sequence/__init__.py b/pos_session_sequence/__init__.py new file mode 100644 index 0000000000..31660d6a96 --- /dev/null +++ b/pos_session_sequence/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models diff --git a/pos_session_sequence/__manifest__.py b/pos_session_sequence/__manifest__.py new file mode 100644 index 0000000000..6bc3a3329d --- /dev/null +++ b/pos_session_sequence/__manifest__.py @@ -0,0 +1,23 @@ +# Copyright 2024 Antoni Marroig(APSL-Nagarro) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "POS Session Sequence", + "summary": "Generates a sequence of POS sessions", + "version": "17.0.1.0.0", + "category": "Uncategorized", + "website": "https://github.com/OCA/pos", + "author": "Antoni Marroig, APSL-Nagarro, Odoo Community Association (OCA)", + "maintainers": ["peluko00"], + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": [ + "point_of_sale", + ], + "data": [ + "views/res_config_settings_views.xml", + ], + "demo": [ + "demo/pos_session_sequence.xml", + ], +} diff --git a/pos_session_sequence/demo/pos_session_sequence.xml b/pos_session_sequence/demo/pos_session_sequence.xml new file mode 100644 index 0000000000..45293a045c --- /dev/null +++ b/pos_session_sequence/demo/pos_session_sequence.xml @@ -0,0 +1,12 @@ + + + + POS Session Demo + POS/%(y)s + 5 + + + + + + diff --git a/pos_session_sequence/i18n/ca.po b/pos_session_sequence/i18n/ca.po new file mode 100644 index 0000000000..6c5b559112 --- /dev/null +++ b/pos_session_sequence/i18n/ca.po @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_session_sequence +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-12-23 17:14+0000\n" +"PO-Revision-Date: 2024-12-23 17:14+0000\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: pos_session_sequence +#: model:ir.model,name:pos_session_sequence.model_res_config_settings +msgid "Config Settings" +msgstr "Paràmetres de configuració" + +#. module: pos_session_sequence +#: model_terms:ir.ui.view,arch_db:pos_session_sequence.res_config_settings_view_form_inherit +msgid "Generation of your sessions references" +msgstr "Generació de referències de les vostres sessions" + +#. module: pos_session_sequence +#: model:ir.model,name:pos_session_sequence.model_pos_config +msgid "Point of Sale Configuration" +msgstr "Configuració del Punt de Venda" + +#. module: pos_session_sequence +#: model:ir.model,name:pos_session_sequence.model_pos_session +msgid "Point of Sale Session" +msgstr "Sessió del Punt de Venda" + +#. module: pos_session_sequence +#: model:ir.model.fields,field_description:pos_session_sequence.field_pos_config__session_sequence_id +#: model:ir.model.fields,field_description:pos_session_sequence.field_res_config_settings__pos_session_sequence_id +msgid "Session IDs Sequence" +msgstr "Seqüència d'IDs de sessió" + +#. module: pos_session_sequence +#: model:ir.model.fields,help:pos_session_sequence.field_pos_config__session_sequence_id +#: model:ir.model.fields,help:pos_session_sequence.field_res_config_settings__pos_session_sequence_id +msgid "" +"This sequence is automatically created by Odoo but you can change it to " +"customize the reference numbers of your sessions." +msgstr "Aquesta seqüència la crea automàticament Odoo, però podeu canviar-la i " +"personalitzeu els números de referència de les vostres sessions." diff --git a/pos_session_sequence/i18n/es.po b/pos_session_sequence/i18n/es.po new file mode 100644 index 0000000000..10349990c4 --- /dev/null +++ b/pos_session_sequence/i18n/es.po @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_session_sequence +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-12-23 17:14+0000\n" +"PO-Revision-Date: 2024-12-23 17:14+0000\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: pos_session_sequence +#: model:ir.model,name:pos_session_sequence.model_res_config_settings +msgid "Config Settings" +msgstr "Ajustes de configuración" + +#. module: pos_session_sequence +#: model_terms:ir.ui.view,arch_db:pos_session_sequence.res_config_settings_view_form_inherit +msgid "Generation of your sessions references" +msgstr "Generación de referencias de tus sesiones." + +#. module: pos_session_sequence +#: model:ir.model,name:pos_session_sequence.model_pos_config +msgid "Point of Sale Configuration" +msgstr "Configuración del TPV" + +#. module: pos_session_sequence +#: model:ir.model,name:pos_session_sequence.model_pos_session +msgid "Point of Sale Session" +msgstr "Sesión TPV" + +#. module: pos_session_sequence +#: model:ir.model.fields,field_description:pos_session_sequence.field_pos_config__session_sequence_id +#: model:ir.model.fields,field_description:pos_session_sequence.field_res_config_settings__pos_session_sequence_id +msgid "Session IDs Sequence" +msgstr "Secuencia de IDs de sesión" + +#. module: pos_session_sequence +#: model:ir.model.fields,help:pos_session_sequence.field_pos_config__session_sequence_id +#: model:ir.model.fields,help:pos_session_sequence.field_res_config_settings__pos_session_sequence_id +msgid "" +"This sequence is automatically created by Odoo but you can change it to " +"customize the reference numbers of your sessions." +msgstr "Odoo crea automáticamente esta secuencia, pero puedes cambiarla y " +"personaliza los números de referencia de tus sesiones." diff --git a/pos_session_sequence/models/__init__.py b/pos_session_sequence/models/__init__.py new file mode 100644 index 0000000000..ee1433d03a --- /dev/null +++ b/pos_session_sequence/models/__init__.py @@ -0,0 +1,5 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import pos_config +from . import pos_session +from . import res_config_settings diff --git a/pos_session_sequence/models/pos_config.py b/pos_session_sequence/models/pos_config.py new file mode 100644 index 0000000000..9be99ecb79 --- /dev/null +++ b/pos_session_sequence/models/pos_config.py @@ -0,0 +1,17 @@ +# Copyright 2024 Antoni Marroig(APSL-Nagarro) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class PosConfig(models.Model): + _inherit = "pos.config" + + session_sequence_id = fields.Many2one( + "ir.sequence", + string="Session IDs Sequence", + help="This sequence is automatically created by Odoo but you can change it " + "to customize the reference numbers of your sessions.", + copy=False, + ondelete="restrict", + ) diff --git a/pos_session_sequence/models/pos_session.py b/pos_session_sequence/models/pos_session.py new file mode 100644 index 0000000000..343d5ac7d9 --- /dev/null +++ b/pos_session_sequence/models/pos_session.py @@ -0,0 +1,16 @@ +# Copyright 2024 Antoni Marroig(APSL-Nagarro) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, models + + +class PosSession(models.Model): + _inherit = "pos.session" + + @api.model_create_multi + def create(self, vals_list): + res = super().create(vals_list) + if res.config_id.session_sequence_id: + pos_name = res.config_id.session_sequence_id._next() + res.update({"name": pos_name}) + return res diff --git a/pos_session_sequence/models/res_config_settings.py b/pos_session_sequence/models/res_config_settings.py new file mode 100644 index 0000000000..d591bbe905 --- /dev/null +++ b/pos_session_sequence/models/res_config_settings.py @@ -0,0 +1,12 @@ +# Copyright 2024 Antoni Marroig(APSL-Nagarro) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + pos_session_sequence_id = fields.Many2one( + related="pos_config_id.session_sequence_id" + ) diff --git a/pos_session_sequence/pyproject.toml b/pos_session_sequence/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/pos_session_sequence/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/pos_session_sequence/readme/CONTRIBUTORS.md b/pos_session_sequence/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..85671f445c --- /dev/null +++ b/pos_session_sequence/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +\[APSL-Nagarro\](): + - Antoni Marroig \<\> \ No newline at end of file diff --git a/pos_session_sequence/readme/DESCRIPTION.md b/pos_session_sequence/readme/DESCRIPTION.md new file mode 100644 index 0000000000..f793f7ab52 --- /dev/null +++ b/pos_session_sequence/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module allows you to configure multiple sequences for every session in different points of sale. + diff --git a/pos_session_sequence/readme/USAGE.md b/pos_session_sequence/readme/USAGE.md new file mode 100644 index 0000000000..66d3e8a7a8 --- /dev/null +++ b/pos_session_sequence/readme/USAGE.md @@ -0,0 +1,6 @@ + +To use this module, you need to: + +- Go to Configuration > Settings +- Setup `Session Ids Sequence` for the Point of Sale +- Open the session for the point of sale and you will see the name computed with the sequence \ No newline at end of file diff --git a/pos_session_sequence/static/description/icon.png b/pos_session_sequence/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/pos_session_sequence/static/description/icon.png differ diff --git a/pos_session_sequence/static/description/icon.svg b/pos_session_sequence/static/description/icon.svg new file mode 100644 index 0000000000..a7a26d0932 --- /dev/null +++ b/pos_session_sequence/static/description/icon.svg @@ -0,0 +1,79 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/pos_session_sequence/static/description/index.html b/pos_session_sequence/static/description/index.html new file mode 100644 index 0000000000..f92d18ab8d --- /dev/null +++ b/pos_session_sequence/static/description/index.html @@ -0,0 +1,124 @@ +
+
+
+

Module name

+

This module was written to extend the functionality of ... to support ... and allow you to ...

+
+
+
+ +
+
+
+

Installation

+
+
+

To install this module, you need to: +

    +
  • ...
  • +
+

+
+
+
+ + + +
+
+
+
+ +
+
+
+

Configuration

+
+
+

To configure this module, you need to: +

    +
  • ...
  • +
+

+
+
+
+ + + +
+
+
+
+ +
+
+
+

Usage

+
+
+

To use this module, you need to: +

    +
  • ...
  • +
+

+

For further information, please visit: +

+

+
+
+
+ + + +
+
+
+
+ +
+
+
+

Known issues / Roadmap

+
+
+

+

    +
  • ...
  • +
+

+
+
+
+ + + +
+
+
+
+ +
+
+
+

Credits

+
+
+

Contributors

+ +
+
+

Maintainer

+

+ This module is maintained by the OCA.
+ 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.
+ To contribute to this module, please visit http://odoo-community.org.
+ +

+
+
+
diff --git a/pos_session_sequence/tests/__init__.py b/pos_session_sequence/tests/__init__.py new file mode 100644 index 0000000000..0c56dc1b34 --- /dev/null +++ b/pos_session_sequence/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_pos_session_sequence diff --git a/pos_session_sequence/tests/test_pos_session_sequence.py b/pos_session_sequence/tests/test_pos_session_sequence.py new file mode 100644 index 0000000000..3fd6b7a032 --- /dev/null +++ b/pos_session_sequence/tests/test_pos_session_sequence.py @@ -0,0 +1,24 @@ +# Copyright 2024 Antoni Marroig(APSL-Nagarro) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + + +class TestPosSessionSequence(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.pos_config_id = cls.env.ref("point_of_sale.pos_config_main") + cls.sequence_id = cls.env.ref("pos_session_sequence.pos_session_seq") + + def test_session_sequence(self): + self.session_id = self.env["pos.session"].create( + [ + { + "config_id": self.pos_config_id.id, + "user_id": self.env.ref("base.user_admin").id, + } + ] + ) + self.sequence_id.number_next_actual -= 1 + self.assertEqual(self.session_id.name, self.sequence_id._next()) diff --git a/pos_session_sequence/views/res_config_settings_views.xml b/pos_session_sequence/views/res_config_settings_views.xml new file mode 100644 index 0000000000..987b9b376e --- /dev/null +++ b/pos_session_sequence/views/res_config_settings_views.xml @@ -0,0 +1,16 @@ + + + + res.config.settings.inherit + res.config.settings + + + + + + + + + +