diff --git a/pos_session_sequence/README.rst b/pos_session_sequence/README.rst new file mode 100644 index 0000000000..978d086c29 --- /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:edb79a866e36dc11e616f5c341d123d9144294d3e21005652518058008993ec5 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/18.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-18-0/pos-18-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=18.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..780570c016 --- /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": "18.0.1.0.0", + "category": "Point of Sale", + "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..c6d648d6e4 --- /dev/null +++ b/pos_session_sequence/i18n/ca.po @@ -0,0 +1,53 @@ +# 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" +"Language: \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..2ebd3ad462 --- /dev/null +++ b/pos_session_sequence/i18n/es.po @@ -0,0 +1,53 @@ +# 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" +"Language: \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/i18n/it.po b/pos_session_sequence/i18n/it.po new file mode 100644 index 0000000000..b3395e2d56 --- /dev/null +++ b/pos_session_sequence/i18n/it.po @@ -0,0 +1,53 @@ +# 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" +"PO-Revision-Date: 2025-09-29 17:04+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\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 5.10.4\n" + +#. module: pos_session_sequence +#: model:ir.model,name:pos_session_sequence.model_res_config_settings +msgid "Config Settings" +msgstr "Impostazioni di configurazione" + +#. 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 "Generazione nelle tue referenze sessioni" + +#. module: pos_session_sequence +#: model:ir.model,name:pos_session_sequence.model_pos_config +msgid "Point of Sale Configuration" +msgstr "Configurazione punto vendita" + +#. module: pos_session_sequence +#: model:ir.model,name:pos_session_sequence.model_pos_session +msgid "Point of Sale Session" +msgstr "Sessione punto vendita" + +#. 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 "Sequenza ID sessione" + +#. 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 "" +"Questa sequenza è creata automaticamente da Odoo ma si può modificare per " +"personalizzare il numero di riferimento della tua sessione." diff --git a/pos_session_sequence/i18n/pos_session_sequence.pot b/pos_session_sequence/i18n/pos_session_sequence.pot new file mode 100644 index 0000000000..d3b92a9586 --- /dev/null +++ b/pos_session_sequence/i18n/pos_session_sequence.pot @@ -0,0 +1,48 @@ +# 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" +"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 "" + +#. 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 "" + +#. module: pos_session_sequence +#: model:ir.model,name:pos_session_sequence.model_pos_config +msgid "Point of Sale Configuration" +msgstr "" + +#. module: pos_session_sequence +#: model:ir.model,name:pos_session_sequence.model_pos_session +msgid "Point of Sale Session" +msgstr "" + +#. 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 "" + +#. 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 "" 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..eddcb68232 --- /dev/null +++ b/pos_session_sequence/models/pos_config.py @@ -0,0 +1,21 @@ +# 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" + + def _default_session_sequence_id(self): + return self.env.ref("point_of_sale.seq_pos_session").id + + 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", + default=_default_session_sequence_id, + ) diff --git a/pos_session_sequence/models/pos_session.py b/pos_session_sequence/models/pos_session.py new file mode 100644 index 0000000000..a3f90b85c0 --- /dev/null +++ b/pos_session_sequence/models/pos_session.py @@ -0,0 +1,15 @@ +# Copyright 2024 Antoni Marroig(APSL-Nagarro) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class PosSession(models.Model): + _inherit = "pos.session" + + def set_opening_control(self, cashbox_value: int, notes: str): + res = super().set_opening_control(cashbox_value, notes) + config = self.config_id + if not self.rescue and config and config.session_sequence_id: + self.name = config.session_sequence_id._next() + 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..7493fccc64 --- /dev/null +++ b/pos_session_sequence/tests/test_pos_session_sequence.py @@ -0,0 +1,53 @@ +# Copyright 2024 Antoni Marroig(APSL-Nagarro) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.addons.base.tests.common import BaseCommon + + +class TestPosSessionSequence(BaseCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.custom_sequence = cls.env["ir.sequence"].create( + { + "name": "Sequence for POS Sessions", + "prefix": "SHOP-A-", + "padding": 3, + } + ) + cls.pos_config = cls.env["pos.config"].create( + { + "name": "Punto de Venta Test", + "session_sequence_id": cls.custom_sequence.id, + } + ) + + def test_01_session_custom_sequence(self): + session = self.env["pos.session"].create( + { + "config_id": self.pos_config.id, + "user_id": self.env.uid, + } + ) + self.assertEqual(session.state, "opening_control") + session.set_opening_control(100.0, "Initial cash") + self.assertEqual(session.name, "SHOP-A-001") + session.action_pos_session_open() + session.action_pos_session_closing_control() + session_2 = self.env["pos.session"].create( + { + "config_id": self.pos_config.id, + } + ) + session_2.set_opening_control(0.0, "") + self.assertEqual(session_2.name, "SHOP-A-002") + + def test_02_session_rescue_no_sequence(self): + session_rescue = self.env["pos.session"].create( + { + "config_id": self.pos_config.id, + "rescue": True, + } + ) + session_rescue.set_opening_control(0.0, "") + self.assertNotEqual(session_rescue.name, "SHOP-A-003") 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..feda613146 --- /dev/null +++ b/pos_session_sequence/views/res_config_settings_views.xml @@ -0,0 +1,16 @@ + + + + res.config.settings.inherit + res.config.settings + + + + + + + + + +