diff --git a/pos_picking_delayed/README.rst b/pos_picking_delayed/README.rst new file mode 100644 index 0000000000..df3d799afa --- /dev/null +++ b/pos_picking_delayed/README.rst @@ -0,0 +1,144 @@ +======================================== +Point of Sale - Picking Creation Delayed +======================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:622db1c8626b1b09ead079043386a1f40457fbc59e7dea9a5f62ae9782b9e4c1 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/14.0/pos_picking_delayed + :alt: OCA/pos +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/pos-14-0/pos-14-0-pos_picking_delayed + :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=14.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionality of odoo Point Of Sale to reduce creation +time of the PoS orders, via the front UI. + +For that purpose, it delays the creation of the picking associated, that will +be created later by queue job. + +This module is interesting specially in a context of Synchroneous Point Of +Sale that is introduced by certification modules like 'l10n_fr_pos_cert' because +in such cases, the bill will be printed only when the pos order is created ( +after the call of the function create_from_ui) and the creation of the picking +is the process that takes the most time. + +See https://github.com/odoo/odoo/pull/26314#issuecomment-422949266 +for more information. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +* Go to 'Point of Sale' / 'Configuration' / 'Point of Sale' +* Select your Point of Sale +* Set the value in the field 'Picking Creation Delayed'. (Checked by default) + +.. image:: https://raw.githubusercontent.com/pos_picking_delayed/static/description/pos_config_form.png + +* This module depends on ``queue_job`` module that requires specific + configuration to works properly. Make sure your config file is correctly set. + See https://github.com/OCA/queue/tree/12.0/queue_job + +You should update your ``odoo.cfg`` file to add a new channel named +``root.pos_picking_delayed``: + + +.. code-block:: + + [queue_job] + channels = root:2,root.pos_picking_delayed:1 + +Otherwise, you'll have a non blocking warning in your log, like this one. + +.. code-block:: + + WARNING ? odoo.addons.queue_job.jobrunner.channels: unknown channel root.pos_picking_delayed, using root channel for job 23f6b872-1d2c-4003-bd38-a8486bbec664 + +Usage +===== + +* Use your Point of Sale as usual. When validating an order, the order will + be in a different color until the job is executed + +.. image:: https://raw.githubusercontent.com/pos_picking_delayed/static/description/pos_order_tree.png + +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 +~~~~~~~ + +* GRAP + +Contributors +~~~~~~~~~~~~ + +* Sylvain LE GAL +* `Tecnativa `_: + + * Carlos Roca + +Other credits +~~~~~~~~~~~~~ + +The development of this module has been financially supported by: + +* GRAP, Groupement Régional Alimentaire de Proximité (www.grap.coop) +* Mind & Go, (https://mind-and-go.com/) + +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-legalsylvain| image:: https://github.com/legalsylvain.png?size=40px + :target: https://github.com/legalsylvain + :alt: legalsylvain + +Current `maintainer `__: + +|maintainer-legalsylvain| + +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_picking_delayed/__init__.py b/pos_picking_delayed/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/pos_picking_delayed/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/pos_picking_delayed/__manifest__.py b/pos_picking_delayed/__manifest__.py new file mode 100644 index 0000000000..a91fc0fe07 --- /dev/null +++ b/pos_picking_delayed/__manifest__.py @@ -0,0 +1,23 @@ +# Copyright 2018 - Today Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Point of Sale - Picking Creation Delayed", + "summary": "Delay the creation of the picking when PoS order is created", + "version": "14.0.1.0.0", + "category": "Point Of Sale", + "author": "GRAP, " "Odoo Community Association (OCA)", + "maintainers": ["legalsylvain"], + "license": "AGPL-3", + "website": "https://github.com/OCA/pos", + "depends": ["point_of_sale", "queue_job"], + "data": [ + "data/queue_job_channel.xml", + "data/queue_job_function.xml", + "views/view_pos_config.xml", + "views/view_pos_order.xml", + ], + "demo": ["demo/pos_config.xml"], + "images": ["static/description/pos_order_tree.png"], + "installable": True, +} diff --git a/pos_picking_delayed/data/queue_job_channel.xml b/pos_picking_delayed/data/queue_job_channel.xml new file mode 100644 index 0000000000..995cd06f5d --- /dev/null +++ b/pos_picking_delayed/data/queue_job_channel.xml @@ -0,0 +1,11 @@ + + + + + + pos_picking_delayed + + + + diff --git a/pos_picking_delayed/data/queue_job_function.xml b/pos_picking_delayed/data/queue_job_function.xml new file mode 100644 index 0000000000..1a414a2ebf --- /dev/null +++ b/pos_picking_delayed/data/queue_job_function.xml @@ -0,0 +1,12 @@ + + + + + + + _create_delayed_picking + + + + diff --git a/pos_picking_delayed/demo/pos_config.xml b/pos_picking_delayed/demo/pos_config.xml new file mode 100644 index 0000000000..8ea3cdbaba --- /dev/null +++ b/pos_picking_delayed/demo/pos_config.xml @@ -0,0 +1,16 @@ + + + + + + + + + + diff --git a/pos_picking_delayed/i18n/es.po b/pos_picking_delayed/i18n/es.po new file mode 100644 index 0000000000..ecf3788100 --- /dev/null +++ b/pos_picking_delayed/i18n/es.po @@ -0,0 +1,62 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_picking_delayed +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-07-27 11:19+0000\n" +"Last-Translator: Daniel Martinez Vila \n" +"Language-Team: none\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.10\n" + +#. module: pos_picking_delayed +#: model:ir.model.fields,help:pos_picking_delayed.field_pos_config__picking_creation_delayed +msgid "" +"Check this box if you want to delay the creation of the picking created by " +"the PoS orders. If checked, the pickings will be created later, by a cron " +"task." +msgstr "" +"Marque esta casilla si desea retrasar la creación de la selección creada por " +"los pedidos PdV. Si está marcada, las selecciones se crearán más tarde, por " +"una tarea cron." + +#. module: pos_picking_delayed +#: model_terms:ir.ui.view,arch_db:pos_picking_delayed.view_pos_config_form +msgid "Delay the creation of the picking created by the PoS orders" +msgstr "Retrasar la creación del picking creado por los pedidos PdV" + +#. module: pos_picking_delayed +#: model:ir.model.fields,field_description:pos_picking_delayed.field_pos_order__has_picking_delayed +msgid "Has Picking Delayed" +msgstr "Ha retrasado el picking" + +#. module: pos_picking_delayed +#: model:ir.model.fields,field_description:pos_picking_delayed.field_pos_config__picking_creation_delayed +msgid "Picking Creation Delayed" +msgstr "Creación de picking retrasada" + +#. module: pos_picking_delayed +#: model:ir.model,name:pos_picking_delayed.model_pos_config +msgid "Point of Sale Configuration" +msgstr "Configuración del punto de venta" + +#. module: pos_picking_delayed +#: model:ir.model,name:pos_picking_delayed.model_pos_order +msgid "Point of Sale Orders" +msgstr "Pedidos de Punto de Venta" + +#. module: pos_picking_delayed +#: model:ir.model.fields,help:pos_picking_delayed.field_pos_order__has_picking_delayed +msgid "" +"This checkbox is checked if the generation of the picking has been delayed. " +"The picking will be created by cron." +msgstr "" +"Esta casilla de verificación se marca si la generación del picking se ha " +"retrasado. La selección será creada por cron." diff --git a/pos_picking_delayed/i18n/fr.po b/pos_picking_delayed/i18n/fr.po new file mode 100644 index 0000000000..c8a4422a85 --- /dev/null +++ b/pos_picking_delayed/i18n/fr.po @@ -0,0 +1,64 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_picking_delayed +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-05-05 09:52+0000\n" +"PO-Revision-Date: 2020-05-05 09:52+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_picking_delayed +#: model:ir.model.fields,help:pos_picking_delayed.field_pos_config__picking_creation_delayed +msgid "" +"Check this box if you want to delay the creation of the picking created by " +"the PoS orders. If checked, the pickings will be created later, by a cron " +"task." +msgstr "" +"Cochez cette case si vous souhaitez retarder la création des transferts de " +"stock liés au commandes de point de vente. Si la case est cochée, ceux-ci " +"seront créés ultérieurement, par une tâche de fond." + +#. module: pos_picking_delayed +#: model_terms:ir.ui.view,arch_db:pos_picking_delayed.view_pos_config_form +msgid "Delay the creation of the picking created by the PoS orders" +msgstr "" +"Retarder la création des transferts de stock créé par les Commandes du Point " +"de Vente" + +#. module: pos_picking_delayed +#: model:ir.model.fields,field_description:pos_picking_delayed.field_pos_order__has_picking_delayed +msgid "Has Picking Delayed" +msgstr "A un transfert retardée" + +#. module: pos_picking_delayed +#: model:ir.model.fields,field_description:pos_picking_delayed.field_pos_config__picking_creation_delayed +msgid "Picking Creation Delayed" +msgstr "Création de transfert retardé" + +#. module: pos_picking_delayed +#: model:ir.model,name:pos_picking_delayed.model_pos_config +msgid "Point of Sale Configuration" +msgstr "Paramétrage du point de vente" + +#. module: pos_picking_delayed +#: model:ir.model,name:pos_picking_delayed.model_pos_order +msgid "Point of Sale Orders" +msgstr "Commandes du point de vente" + +#. module: pos_picking_delayed +#: model:ir.model.fields,help:pos_picking_delayed.field_pos_order__has_picking_delayed +msgid "" +"This checkbox is checked if the generation of the picking has been delayed. " +"The picking will be created by cron." +msgstr "" +"Cette case est cochée si la génération du transfert de stock a été retardée. " +"Celui ci sera créé par une tâche de fond." diff --git a/pos_picking_delayed/i18n/it.po b/pos_picking_delayed/i18n/it.po new file mode 100644 index 0000000000..f1905d3aaf --- /dev/null +++ b/pos_picking_delayed/i18n/it.po @@ -0,0 +1,62 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_picking_delayed +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-03-17 15:22+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 4.14.1\n" + +#. module: pos_picking_delayed +#: model:ir.model.fields,help:pos_picking_delayed.field_pos_config__picking_creation_delayed +msgid "" +"Check this box if you want to delay the creation of the picking created by " +"the PoS orders. If checked, the pickings will be created later, by a cron " +"task." +msgstr "" +"Selezionare questa opzione se si vuole ritardare la creazione del prelievo " +"creato dagli ordini POS. Se selezionato, i prelievi verranno creati in un " +"secondo momento da un lavoro cron." + +#. module: pos_picking_delayed +#: model_terms:ir.ui.view,arch_db:pos_picking_delayed.view_pos_config_form +msgid "Delay the creation of the picking created by the PoS orders" +msgstr "Ritarda la creazione del prelievo creato dagli ordini POS" + +#. module: pos_picking_delayed +#: model:ir.model.fields,field_description:pos_picking_delayed.field_pos_order__has_picking_delayed +msgid "Has Picking Delayed" +msgstr "Ha prelievo ritardato" + +#. module: pos_picking_delayed +#: model:ir.model.fields,field_description:pos_picking_delayed.field_pos_config__picking_creation_delayed +msgid "Picking Creation Delayed" +msgstr "Creazione prelievo ritardato" + +#. module: pos_picking_delayed +#: model:ir.model,name:pos_picking_delayed.model_pos_config +msgid "Point of Sale Configuration" +msgstr "Configurazione punto vendita" + +#. module: pos_picking_delayed +#: model:ir.model,name:pos_picking_delayed.model_pos_order +msgid "Point of Sale Orders" +msgstr "Ordini punto vendita" + +#. module: pos_picking_delayed +#: model:ir.model.fields,help:pos_picking_delayed.field_pos_order__has_picking_delayed +msgid "" +"This checkbox is checked if the generation of the picking has been delayed. " +"The picking will be created by cron." +msgstr "" +"Questa opzione è selezionata se la generazione dei prelievi è stata " +"ritardata. Il prelievo verrà creato da cron." diff --git a/pos_picking_delayed/i18n/pos_picking_delayed.pot b/pos_picking_delayed/i18n/pos_picking_delayed.pot new file mode 100644 index 0000000000..98f9a07d0a --- /dev/null +++ b/pos_picking_delayed/i18n/pos_picking_delayed.pot @@ -0,0 +1,54 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_picking_delayed +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.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_picking_delayed +#: model:ir.model.fields,help:pos_picking_delayed.field_pos_config__picking_creation_delayed +msgid "" +"Check this box if you want to delay the creation of the picking created by " +"the PoS orders. If checked, the pickings will be created later, by a cron " +"task." +msgstr "" + +#. module: pos_picking_delayed +#: model_terms:ir.ui.view,arch_db:pos_picking_delayed.view_pos_config_form +msgid "Delay the creation of the picking created by the PoS orders" +msgstr "" + +#. module: pos_picking_delayed +#: model:ir.model.fields,field_description:pos_picking_delayed.field_pos_order__has_picking_delayed +msgid "Has Picking Delayed" +msgstr "" + +#. module: pos_picking_delayed +#: model:ir.model.fields,field_description:pos_picking_delayed.field_pos_config__picking_creation_delayed +msgid "Picking Creation Delayed" +msgstr "" + +#. module: pos_picking_delayed +#: model:ir.model,name:pos_picking_delayed.model_pos_config +msgid "Point of Sale Configuration" +msgstr "" + +#. module: pos_picking_delayed +#: model:ir.model,name:pos_picking_delayed.model_pos_order +msgid "Point of Sale Orders" +msgstr "" + +#. module: pos_picking_delayed +#: model:ir.model.fields,help:pos_picking_delayed.field_pos_order__has_picking_delayed +msgid "" +"This checkbox is checked if the generation of the picking has been delayed. " +"The picking will be created by cron." +msgstr "" diff --git a/pos_picking_delayed/models/__init__.py b/pos_picking_delayed/models/__init__.py new file mode 100644 index 0000000000..234b311eae --- /dev/null +++ b/pos_picking_delayed/models/__init__.py @@ -0,0 +1,2 @@ +from . import pos_config +from . import pos_order diff --git a/pos_picking_delayed/models/pos_config.py b/pos_picking_delayed/models/pos_config.py new file mode 100644 index 0000000000..91931feed3 --- /dev/null +++ b/pos_picking_delayed/models/pos_config.py @@ -0,0 +1,17 @@ +# Copyright 2018 - Today Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + + +from odoo import fields, models + + +class PosConfig(models.Model): + _inherit = "pos.config" + + picking_creation_delayed = fields.Boolean( + string="Picking Creation Delayed", + default=True, + help="Check this box if you want to delay the creation of the picking" + " created by the PoS orders. If checked, the pickings will" + " be created later, by a cron task.", + ) diff --git a/pos_picking_delayed/models/pos_order.py b/pos_picking_delayed/models/pos_order.py new file mode 100644 index 0000000000..8d00430f77 --- /dev/null +++ b/pos_picking_delayed/models/pos_order.py @@ -0,0 +1,62 @@ +# Copyright 2018 - Today Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class PosOrder(models.Model): + _inherit = "pos.order" + + has_picking_delayed = fields.Boolean( + default=False, + help="This checkbox is checked if the generation of" + " the picking has been delayed. The picking will be created by cron.", + ) + + # Overload Section + @api.model + def create_from_ui(self, orders, draft=False): + PosSession = self.env["pos.session"] + for order_data in orders: + session_id = order_data.get("data").get("pos_session_id") + session = PosSession.browse(session_id) + order_data["data"]["has_picking_delayed"] = ( + session.config_id.picking_creation_delayed + and not session.update_stock_at_closing + ) + return super(PosOrder, self.with_context(create_from_ui=True)).create_from_ui( + orders, draft=draft + ) + + @api.model + def _delayed_picking_job_kwargs(self): + return {} + + def _create_order_picking(self): + if self.env.context.get("create_from_ui", False): + orders = self.filtered(lambda x: not x.has_picking_delayed) + delayed_orders = self.filtered(lambda x: x.has_picking_delayed) + if delayed_orders: + kw = self._delayed_picking_job_kwargs() + delayed_orders.with_delay(**kw)._create_delayed_picking() + else: + orders = self + + if not orders: + return + + super(PosOrder, orders)._create_order_picking() + orders.write({"has_picking_delayed": False}) + + @api.model + def _order_fields(self, ui_order): + res = super(PosOrder, self)._order_fields(ui_order) + res["has_picking_delayed"] = ui_order["has_picking_delayed"] + return res + + # Custom Section + def _create_delayed_picking(self): + # make the function idempotent + orders = self.filtered(lambda x: x.has_picking_delayed) + super(PosOrder, orders)._create_order_picking() + orders.write({"has_picking_delayed": False}) diff --git a/pos_picking_delayed/readme/CONFIGURE.rst b/pos_picking_delayed/readme/CONFIGURE.rst new file mode 100644 index 0000000000..678f68f95f --- /dev/null +++ b/pos_picking_delayed/readme/CONFIGURE.rst @@ -0,0 +1,24 @@ +* Go to 'Point of Sale' / 'Configuration' / 'Point of Sale' +* Select your Point of Sale +* Set the value in the field 'Picking Creation Delayed'. (Checked by default) + +.. image:: /pos_picking_delayed/static/description/pos_config_form.png + +* This module depends on ``queue_job`` module that requires specific + configuration to works properly. Make sure your config file is correctly set. + See https://github.com/OCA/queue/tree/12.0/queue_job + +You should update your ``odoo.cfg`` file to add a new channel named +``root.pos_picking_delayed``: + + +.. code-block:: + + [queue_job] + channels = root:2,root.pos_picking_delayed:1 + +Otherwise, you'll have a non blocking warning in your log, like this one. + +.. code-block:: + + WARNING ? odoo.addons.queue_job.jobrunner.channels: unknown channel root.pos_picking_delayed, using root channel for job 23f6b872-1d2c-4003-bd38-a8486bbec664 diff --git a/pos_picking_delayed/readme/CONTRIBUTORS.rst b/pos_picking_delayed/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..aa65903c89 --- /dev/null +++ b/pos_picking_delayed/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* Sylvain LE GAL +* `Tecnativa `_: + + * Carlos Roca diff --git a/pos_picking_delayed/readme/CREDITS.rst b/pos_picking_delayed/readme/CREDITS.rst new file mode 100644 index 0000000000..0a9ea63841 --- /dev/null +++ b/pos_picking_delayed/readme/CREDITS.rst @@ -0,0 +1,4 @@ +The development of this module has been financially supported by: + +* GRAP, Groupement Régional Alimentaire de Proximité (www.grap.coop) +* Mind & Go, (https://mind-and-go.com/) diff --git a/pos_picking_delayed/readme/DESCRIPTION.rst b/pos_picking_delayed/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..b793c4ff60 --- /dev/null +++ b/pos_picking_delayed/readme/DESCRIPTION.rst @@ -0,0 +1,14 @@ +This module extends the functionality of odoo Point Of Sale to reduce creation +time of the PoS orders, via the front UI. + +For that purpose, it delays the creation of the picking associated, that will +be created later by queue job. + +This module is interesting specially in a context of Synchroneous Point Of +Sale that is introduced by certification modules like 'l10n_fr_pos_cert' because +in such cases, the bill will be printed only when the pos order is created ( +after the call of the function create_from_ui) and the creation of the picking +is the process that takes the most time. + +See https://github.com/odoo/odoo/pull/26314#issuecomment-422949266 +for more information. diff --git a/pos_picking_delayed/readme/USAGE.rst b/pos_picking_delayed/readme/USAGE.rst new file mode 100644 index 0000000000..00c9f863fc --- /dev/null +++ b/pos_picking_delayed/readme/USAGE.rst @@ -0,0 +1,4 @@ +* Use your Point of Sale as usual. When validating an order, the order will + be in a different color until the job is executed + +.. image:: /pos_picking_delayed/static/description/pos_order_tree.png diff --git a/pos_picking_delayed/static/description/icon.png b/pos_picking_delayed/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/pos_picking_delayed/static/description/icon.png differ diff --git a/pos_picking_delayed/static/description/index.html b/pos_picking_delayed/static/description/index.html new file mode 100644 index 0000000000..4580acdcd1 --- /dev/null +++ b/pos_picking_delayed/static/description/index.html @@ -0,0 +1,482 @@ + + + + + +Point of Sale - Picking Creation Delayed + + + +
+

Point of Sale - Picking Creation Delayed

+ + +

Beta License: AGPL-3 OCA/pos Translate me on Weblate Try me on Runboat

+

This module extends the functionality of odoo Point Of Sale to reduce creation +time of the PoS orders, via the front UI.

+

For that purpose, it delays the creation of the picking associated, that will +be created later by queue job.

+

This module is interesting specially in a context of Synchroneous Point Of +Sale that is introduced by certification modules like ‘l10n_fr_pos_cert’ because +in such cases, the bill will be printed only when the pos order is created ( +after the call of the function create_from_ui) and the creation of the picking +is the process that takes the most time.

+

See https://github.com/odoo/odoo/pull/26314#issuecomment-422949266 +for more information.

+

Table of contents

+ +
+

Configuration

+
    +
  • Go to ‘Point of Sale’ / ‘Configuration’ / ‘Point of Sale’
  • +
  • Select your Point of Sale
  • +
  • Set the value in the field ‘Picking Creation Delayed’. (Checked by default)
  • +
+https://raw.githubusercontent.com/pos_picking_delayed/static/description/pos_config_form.png + +

You should update your odoo.cfg file to add a new channel named +root.pos_picking_delayed:

+
+[queue_job]
+channels = root:2,root.pos_picking_delayed:1
+
+

Otherwise, you’ll have a non blocking warning in your log, like this one.

+
+WARNING ? odoo.addons.queue_job.jobrunner.channels: unknown channel root.pos_picking_delayed, using root channel for job 23f6b872-1d2c-4003-bd38-a8486bbec664
+
+
+
+

Usage

+
    +
  • Use your Point of Sale as usual. When validating an order, the order will +be in a different color until the job is executed
  • +
+https://raw.githubusercontent.com/pos_picking_delayed/static/description/pos_order_tree.png +
+
+

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

+
    +
  • GRAP
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

The development of this module has been financially supported by:

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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.

+

Current maintainer:

+

legalsylvain

+

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_picking_delayed/static/description/pos_config_form.png b/pos_picking_delayed/static/description/pos_config_form.png new file mode 100644 index 0000000000..d4756d3a52 Binary files /dev/null and b/pos_picking_delayed/static/description/pos_config_form.png differ diff --git a/pos_picking_delayed/static/description/pos_order_tree.png b/pos_picking_delayed/static/description/pos_order_tree.png new file mode 100644 index 0000000000..1420d6b967 Binary files /dev/null and b/pos_picking_delayed/static/description/pos_order_tree.png differ diff --git a/pos_picking_delayed/tests/__init__.py b/pos_picking_delayed/tests/__init__.py new file mode 100644 index 0000000000..d9b96c4fa5 --- /dev/null +++ b/pos_picking_delayed/tests/__init__.py @@ -0,0 +1 @@ +from . import test_module diff --git a/pos_picking_delayed/tests/test_module.py b/pos_picking_delayed/tests/test_module.py new file mode 100644 index 0000000000..60c0139a19 --- /dev/null +++ b/pos_picking_delayed/tests/test_module.py @@ -0,0 +1,137 @@ +# Copyright 2018 - Today Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields +from odoo.tests.common import TransactionCase + + +class TestModule(TransactionCase): + def setUp(self): + super(TestModule, self).setUp() + self.PosOrder = self.env["pos.order"] + self.QueueJob = self.env["queue.job"] + self.currency = self.env.user.company_id.currency_id + self.pos_product = self.env.ref("point_of_sale.whiteboard_pen") + self.pricelist = self.env["product.pricelist"].create( + { + "name": "Test pricelist", + "item_ids": [ + ( + 0, + 0, + { + "applied_on": "3_global", + "compute_price": "formula", + "base": "list_price", + }, + ) + ], + "currency_id": self.currency.id, + } + ) + # Create a new pos config and open it + self.pos_config = self.env.ref("point_of_sale.pos_config_main").copy( + { + "available_pricelist_ids": [(6, 0, self.pricelist.ids)], + "pricelist_id": self.pricelist.id, + "currency_id": self.currency.id, + } + ) + self.pos_config.company_id.point_of_sale_update_stock_quantities = "real" + + def test_01_picking_delayed_enabled(self): + # Enable feature + self.pos_config.picking_creation_delayed = True + self.pos_config.open_session_cb() + + order = self._create_order() + + self.assertEqual( + order.picking_ids.id, + False, + "Creating order via UI should not generate a picking if" + " feature is enabled", + ) + + # Test if a Queue Job has been generated + func_string = "pos.order(%d,)._create_delayed_picking()" % (order.id) + queues = self.QueueJob.search([("func_string", "=", func_string)]) + self.assertEqual(len(queues), 1, "Queue Job has not been created") + + def test_02_picking_delayed_disabled(self): + # Disable feature + self.pos_config.picking_creation_delayed = False + self.pos_config.open_session_cb() + + order = self._create_order() + + picking_id = order.picking_ids.id + self.assertNotEqual( + picking_id, + False, + "Creating order via UI should generate a picking if" " feature is disabled", + ) + + # Test if a Queue Job has not been generated + func_string = "pos.order(%d,)._create_delayed_picking()" % (order.id) + queues = self.QueueJob.search([("func_string", "=", func_string)]) + self.assertEqual(len(queues), 0, "Queue Job has been created") + + def _create_order(self): + # Create order + account_id = self.env.user.partner_id.property_account_receivable_id + statement_id = self.pos_config.current_session_id.statement_ids[0] + payment_methods = self.pos_config.current_session_id.payment_method_ids + order_data = { + "id": "0006-001-0010", + "to_invoice": False, + "data": { + "pricelist_id": self.pricelist.id, + "user_id": 1, + "name": "Order 0006-001-0010", + "partner_id": False, + "amount_paid": 0.9, + "pos_session_id": self.pos_config.current_session_id.id, + "lines": [ + [ + 0, + 0, + { + "product_id": self.pos_product.id, + "price_unit": 0.9, + "qty": 1, + "price_subtotal": 0.9, + "price_subtotal_incl": 0.9, + }, + ] + ], + "statement_ids": [ + [ + 0, + 0, + { + "journal_id": self.pos_config.journal_id.id, + "amount": 0.9, + "name": fields.Datetime.now(), + "account_id": account_id.id, + "statement_id": statement_id.id, + "payment_method_id": payment_methods.filtered( + lambda pm: pm.is_cash_count + and not pm.split_transactions + )[0].id, + }, + ] + ], + "creation_date": "2018-09-27 15:51:03", + "amount_tax": 0, + "fiscal_position_id": False, + "uid": "00001-001-0001", + "amount_return": 0, + "sequence_number": 1, + "amount_total": 0.9, + }, + } + + result = self.PosOrder.create_from_ui([order_data]) + order = self.PosOrder.browse(result[0]["id"]) + return order diff --git a/pos_picking_delayed/views/view_pos_config.xml b/pos_picking_delayed/views/view_pos_config.xml new file mode 100644 index 0000000000..38114a3ae1 --- /dev/null +++ b/pos_picking_delayed/views/view_pos_config.xml @@ -0,0 +1,28 @@ + + + + + + pos.config + + + + +
+
+ +
+
+
+
+
+ +
+
+ +
diff --git a/pos_picking_delayed/views/view_pos_order.xml b/pos_picking_delayed/views/view_pos_order.xml new file mode 100644 index 0000000000..63b7858e8d --- /dev/null +++ b/pos_picking_delayed/views/view_pos_order.xml @@ -0,0 +1,31 @@ + + + + + + pos.order + + + + has_picking_delayed == True + + + + + + + + + pos.order + + + + + + + + + diff --git a/setup/pos_picking_delayed/odoo/addons/pos_picking_delayed b/setup/pos_picking_delayed/odoo/addons/pos_picking_delayed new file mode 120000 index 0000000000..6ddaccdf8f --- /dev/null +++ b/setup/pos_picking_delayed/odoo/addons/pos_picking_delayed @@ -0,0 +1 @@ +../../../../pos_picking_delayed \ No newline at end of file diff --git a/setup/pos_picking_delayed/setup.py b/setup/pos_picking_delayed/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/pos_picking_delayed/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)