diff --git a/pos_edit_order_line/README.rst b/pos_edit_order_line/README.rst new file mode 100644 index 0000000000..5ea93033ee --- /dev/null +++ b/pos_edit_order_line/README.rst @@ -0,0 +1,111 @@ +=================== +POS Edit Order Line +=================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:44dde903de0f82d6771fb69606890611023369cf3690d38548eb877a494144cc + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fpos-lightgray.png?logo=github + :target: https://github.com/OCA/pos/tree/17.0/pos_edit_order_line + :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_edit_order_line + :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 adds a button "Edit order lines" in main POS interface to +allow an easier UX for cashier when editing product price, qty and +discount. + +On button click, a popup with order lines allows user to input a clear +value for each field, instead of having to use the default process of +selecting which field to edit, which is not very intuitive and +error-prone. + +|Display Edit Order Line Popup| + +.. |Display Edit Order Line Popup| image:: https://raw.githubusercontent.com/OCA/pos/17.0/pos_edit_order_line/static/description/pos_edit_order_line.png + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +Select PoS > configuration > enable flag "Allow Edit Order Line" To +improve usability when there are more than 3 order lines, we suggest +activating the "Large scrollbars" POS setting. + +Changelog +========= + +14.0.1.0.0 +---------- + +- Initial release + +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 +------- + +* Ooops +* Cetmix + +Contributors +------------ + +- Ooops404 +- Cetmix +- `Acsone `__: + + - Maxime Franco + +- `Heliconia Solutions Pvt. Ltd. `__ + + - Bhavesh Heliconia + +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/pos `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/pos_edit_order_line/__init__.py b/pos_edit_order_line/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/pos_edit_order_line/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/pos_edit_order_line/__manifest__.py b/pos_edit_order_line/__manifest__.py new file mode 100644 index 0000000000..05a163d34d --- /dev/null +++ b/pos_edit_order_line/__manifest__.py @@ -0,0 +1,28 @@ +# copyright 2022 Dinar Gabbasov +# Copyright 2022 Ooops404 +# Copyright 2022 Cetmix +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). + +{ + "name": "POS Edit Order Line", + "version": "17.0.1.0.0", + "summary": "POS Edit Order Line", + "author": "Ooops, Cetmix, Odoo Community Association (OCA)", + "contributors": "Cetmix", + "license": "LGPL-3", + "category": "Point of Sale", + "website": "https://github.com/OCA/pos", + "depends": ["point_of_sale"], + "external_dependencies": {}, + "demo": [], + "data": ["views/res_config_settings_view.xml"], + "assets": { + "point_of_sale._assets_pos": [ + "pos_edit_order_line/static/src/css/pos.css", + "pos_edit_order_line/static/src/js/*.js", + "pos_edit_order_line/static/src/xml/*.xml", + ], + }, + "installable": True, + "application": False, +} diff --git a/pos_edit_order_line/i18n/es.po b/pos_edit_order_line/i18n/es.po new file mode 100644 index 0000000000..75426247e9 --- /dev/null +++ b/pos_edit_order_line/i18n/es.po @@ -0,0 +1,115 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_edit_order_line +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-08-22 18:15+0000\n" +"Last-Translator: Ivorra78 \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 4.17\n" + +#. module: pos_edit_order_line +#: model:ir.model.fields,field_description:pos_edit_order_line.field_pos_config__allow_edit_order_line +#: model:ir.model.fields,field_description:pos_edit_order_line.field_res_config_settings__pos_allow_edit_order_line +msgid "Allow Edit Order Line" +msgstr "Permitir editar ticket" + +#. module: pos_edit_order_line +#: model_terms:ir.ui.view,arch_db:pos_edit_order_line.res_config_settings_view_form +msgid "Allow edit Order Line in popup" +msgstr "Permitir editar ticket en un popup" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/js/EditOrderPopup.js:0 +#, python-format +msgid "Cancel" +msgstr "Cancelar" + +#. module: pos_edit_order_line +#: model:ir.model,name:pos_edit_order_line.model_res_config_settings +msgid "Config Settings" +msgstr "Configuración" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0 +#, python-format +msgid "Discount" +msgstr "Descuento" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/js/EditOrderButton.js:0 +#, python-format +msgid "Edit Order Line" +msgstr "Editar ticket" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/xml/EditOrderButton.xml:0 +#, python-format +msgid "Edit Order Lines" +msgstr "Editar ticket" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/js/EditOrderButton.js:0 +#, python-format +msgid "Empty Order" +msgstr "Ticket vacío" + +#. module: pos_edit_order_line +#: model:ir.model,name:pos_edit_order_line.model_pos_config +msgid "Point of Sale Configuration" +msgstr "Configuración TPV" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0 +#, python-format +msgid "Price" +msgstr "Precio" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0 +#, python-format +msgid "Product" +msgstr "Producto" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0 +#, python-format +msgid "Quantity" +msgstr "Cantidad" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/js/EditOrderPopup.js:0 +#, python-format +msgid "Save" +msgstr "Guardar" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0 +#, python-format +msgid "UoM" +msgstr "UdM" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/js/EditOrderButton.js:0 +#, python-format +msgid "You need add some products first" +msgstr "Primero añada productos" diff --git a/pos_edit_order_line/i18n/it.po b/pos_edit_order_line/i18n/it.po new file mode 100644 index 0000000000..68c235a3bb --- /dev/null +++ b/pos_edit_order_line/i18n/it.po @@ -0,0 +1,124 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_edit_order_line +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-03-30 10:23+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_edit_order_line +#: model:ir.model.fields,field_description:pos_edit_order_line.field_pos_config__allow_edit_order_line +#: model:ir.model.fields,field_description:pos_edit_order_line.field_res_config_settings__pos_allow_edit_order_line +msgid "Allow Edit Order Line" +msgstr "Abilita la modifica righe ordine con popup" + +#. module: pos_edit_order_line +#: model_terms:ir.ui.view,arch_db:pos_edit_order_line.res_config_settings_view_form +msgid "Allow edit Order Line in popup" +msgstr "Abilita la modifica righe ordine con popup" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/js/EditOrderPopup.js:0 +#, python-format +msgid "Cancel" +msgstr "Annulla" + +#. module: pos_edit_order_line +#: model:ir.model,name:pos_edit_order_line.model_res_config_settings +msgid "Config Settings" +msgstr "Impostazioni configurazione" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0 +#, python-format +msgid "Discount" +msgstr "Sconto" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/js/EditOrderButton.js:0 +#, python-format +msgid "Edit Order Line" +msgstr "Modifica righe ordine" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/xml/EditOrderButton.xml:0 +#, python-format +msgid "Edit Order Lines" +msgstr "Modifica righe ordine" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/js/EditOrderButton.js:0 +#, python-format +msgid "Empty Order" +msgstr "Svuota ordine" + +#. module: pos_edit_order_line +#: model:ir.model,name:pos_edit_order_line.model_pos_config +msgid "Point of Sale Configuration" +msgstr "Configurazione punto vendita" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0 +#, python-format +msgid "Price" +msgstr "Prezzo" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0 +#, python-format +msgid "Product" +msgstr "Prodotto" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0 +#, python-format +msgid "Quantity" +msgstr "Quantità" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/js/EditOrderPopup.js:0 +#, python-format +msgid "Save" +msgstr "Salva" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0 +#, python-format +msgid "UoM" +msgstr "UdM" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/js/EditOrderButton.js:0 +#, python-format +msgid "You need add some products first" +msgstr "È necessario aggiungere prima alcuni prodotti" + +#~ msgid "Display Name" +#~ msgstr "Nome visualizzato" + +#~ msgid "ID" +#~ msgstr "ID" + +#~ msgid "Last Modified on" +#~ msgstr "Ultima modifica il" diff --git a/pos_edit_order_line/i18n/pos_edit_order_line.pot b/pos_edit_order_line/i18n/pos_edit_order_line.pot new file mode 100644 index 0000000000..e33dd9fb22 --- /dev/null +++ b/pos_edit_order_line/i18n/pos_edit_order_line.pot @@ -0,0 +1,112 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_edit_order_line +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.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_edit_order_line +#: model:ir.model.fields,field_description:pos_edit_order_line.field_pos_config__allow_edit_order_line +#: model:ir.model.fields,field_description:pos_edit_order_line.field_res_config_settings__pos_allow_edit_order_line +msgid "Allow Edit Order Line" +msgstr "" + +#. module: pos_edit_order_line +#: model_terms:ir.ui.view,arch_db:pos_edit_order_line.res_config_settings_view_form +msgid "Allow edit Order Line in popup" +msgstr "" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/js/EditOrderPopup.js:0 +#, python-format +msgid "Cancel" +msgstr "" + +#. module: pos_edit_order_line +#: model:ir.model,name:pos_edit_order_line.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0 +#, python-format +msgid "Discount" +msgstr "" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/js/EditOrderButton.js:0 +#, python-format +msgid "Edit Order Line" +msgstr "" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/xml/EditOrderButton.xml:0 +#, python-format +msgid "Edit Order Lines" +msgstr "" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/js/EditOrderButton.js:0 +#, python-format +msgid "Empty Order" +msgstr "" + +#. module: pos_edit_order_line +#: model:ir.model,name:pos_edit_order_line.model_pos_config +msgid "Point of Sale Configuration" +msgstr "" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0 +#, python-format +msgid "Price" +msgstr "" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0 +#, python-format +msgid "Product" +msgstr "" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0 +#, python-format +msgid "Quantity" +msgstr "" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/js/EditOrderPopup.js:0 +#, python-format +msgid "Save" +msgstr "" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0 +#, python-format +msgid "UoM" +msgstr "" + +#. module: pos_edit_order_line +#. odoo-javascript +#: code:addons/pos_edit_order_line/static/src/js/EditOrderButton.js:0 +#, python-format +msgid "You need add some products first" +msgstr "" diff --git a/pos_edit_order_line/models/__init__.py b/pos_edit_order_line/models/__init__.py new file mode 100644 index 0000000000..2b92809a3b --- /dev/null +++ b/pos_edit_order_line/models/__init__.py @@ -0,0 +1,2 @@ +from . import pos_config +from . import res_config_settings diff --git a/pos_edit_order_line/models/pos_config.py b/pos_edit_order_line/models/pos_config.py new file mode 100644 index 0000000000..f3be8adb73 --- /dev/null +++ b/pos_edit_order_line/models/pos_config.py @@ -0,0 +1,14 @@ +# copyright 2022 Dinar Gabbasov +# Copyright 2022 Ooops404 +# Copyright 2022 Cetmix +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). + +from odoo import fields, models + + +class PosConfig(models.Model): + _inherit = "pos.config" + + allow_edit_order_line = fields.Boolean( + default=True, + ) diff --git a/pos_edit_order_line/models/res_config_settings.py b/pos_edit_order_line/models/res_config_settings.py new file mode 100644 index 0000000000..b9944f70fe --- /dev/null +++ b/pos_edit_order_line/models/res_config_settings.py @@ -0,0 +1,14 @@ +# copyright 2023 Dinar Gabbasov +# Copyright 2023 Ooops404 +# Copyright 2023 Cetmix +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + pos_allow_edit_order_line = fields.Boolean( + related="pos_config_id.allow_edit_order_line", + readonly=False, + ) diff --git a/pos_edit_order_line/pyproject.toml b/pos_edit_order_line/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/pos_edit_order_line/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/pos_edit_order_line/readme/CONFIGURE.md b/pos_edit_order_line/readme/CONFIGURE.md new file mode 100644 index 0000000000..88295a93d0 --- /dev/null +++ b/pos_edit_order_line/readme/CONFIGURE.md @@ -0,0 +1,3 @@ +Select PoS \> configuration \> enable flag "Allow Edit Order Line" To +improve usability when there are more than 3 order lines, we suggest +activating the "Large scrollbars" POS setting. diff --git a/pos_edit_order_line/readme/CONTRIBUTORS.md b/pos_edit_order_line/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..8c08378790 --- /dev/null +++ b/pos_edit_order_line/readme/CONTRIBUTORS.md @@ -0,0 +1,6 @@ +- Ooops404 \<\> +- Cetmix \<\> +- [Acsone](https://www.acsone.eu/): + - Maxime Franco +- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io) + - Bhavesh Heliconia diff --git a/pos_edit_order_line/readme/DESCRIPTION.md b/pos_edit_order_line/readme/DESCRIPTION.md new file mode 100644 index 0000000000..6d4cd8c2f3 --- /dev/null +++ b/pos_edit_order_line/readme/DESCRIPTION.md @@ -0,0 +1,10 @@ +This module adds a button "Edit order lines" in main POS interface to +allow an easier UX for cashier when editing product price, qty and +discount. + +On button click, a popup with order lines allows user to input a clear +value for each field, instead of having to use the default process of +selecting which field to edit, which is not very intuitive and +error-prone. + +![Display Edit Order Line Popup](../static/description/pos_edit_order_line.png) diff --git a/pos_edit_order_line/readme/HISTORY.md b/pos_edit_order_line/readme/HISTORY.md new file mode 100644 index 0000000000..a6871c38d0 --- /dev/null +++ b/pos_edit_order_line/readme/HISTORY.md @@ -0,0 +1,3 @@ +## 14.0.1.0.0 + +- Initial release diff --git a/pos_edit_order_line/static/description/icon.png b/pos_edit_order_line/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/pos_edit_order_line/static/description/icon.png differ diff --git a/pos_edit_order_line/static/description/index.html b/pos_edit_order_line/static/description/index.html new file mode 100644 index 0000000000..5b968cfd51 --- /dev/null +++ b/pos_edit_order_line/static/description/index.html @@ -0,0 +1,460 @@ + + + + + +POS Edit Order Line + + + +
+

POS Edit Order Line

+ + +

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

+

This module adds a button “Edit order lines” in main POS interface to +allow an easier UX for cashier when editing product price, qty and +discount.

+

On button click, a popup with order lines allows user to input a clear +value for each field, instead of having to use the default process of +selecting which field to edit, which is not very intuitive and +error-prone.

+

Display Edit Order Line Popup

+

Table of contents

+ +
+

Configuration

+

Select PoS > configuration > enable flag “Allow Edit Order Line” To +improve usability when there are more than 3 order lines, we suggest +activating the “Large scrollbars” POS setting.

+
+
+

Changelog

+
+

14.0.1.0.0

+
    +
  • Initial release
  • +
+
+
+
+

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

+
    +
  • Ooops
  • +
  • Cetmix
  • +
+
+
+

Contributors

+ +
+
+

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.

+

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_edit_order_line/static/description/pos_edit_order_line.png b/pos_edit_order_line/static/description/pos_edit_order_line.png new file mode 100644 index 0000000000..a4fd719e15 Binary files /dev/null and b/pos_edit_order_line/static/description/pos_edit_order_line.png differ diff --git a/pos_edit_order_line/static/src/css/pos.css b/pos_edit_order_line/static/src/css/pos.css new file mode 100644 index 0000000000..024911f610 --- /dev/null +++ b/pos_edit_order_line/static/src/css/pos.css @@ -0,0 +1,60 @@ +/* The Edit Order Line Popup */ +.pos .edit-order-popup .popup { + max-width: 600px; +} + +.pos .edit-order-popup .full-content { + overflow: auto; +} + +.pos .edit-order-popup .order-line-list { + font-size: 16px; + width: 100%; +} + +.pos .edit-order-popup .order-line-list th, +.pos .edit-order-popup .order-line-list td { + padding: 12px 8px; +} + +.pos .edit-order-popup .order-line-list tr { + transition: all 150ms linear; + background: rgb(230, 230, 230); +} + +.pos .edit-order-popup .order-line-list thead > tr, +.pos .edit-order-popup .order-line-list tr:nth-child(even) { + background: rgb(247, 247, 247); +} + +.pos .edit-order-popup .order-line-list tr.highlight { + transition: all 150ms linear; + background: rgb(110, 200, 155) !important; + color: white; +} + +.pos .edit-order-popup .order-line-list tr.lowlight { + transition: all 150ms linear; + background: rgb(216, 238, 227); +} + +.pos .edit-order-popup .order-line-list tr.lowlight:nth-child(even) { + transition: all 150ms linear; + background: rgb(227, 246, 237); +} + +.pos .edit-order-popup .subwindow .subwindow-container { + height: 250px; +} + +.pos .edit-order-popup input.required { + outline: none; + box-shadow: 0px 0px 0px 2px red; +} + +@media screen and (max-width: 768px) { + .pos .edit-order-popup .order-line-list td { + overflow: hidden; + white-space: nowrap; + } +} diff --git a/pos_edit_order_line/static/src/js/EditOrderButton.esm.js b/pos_edit_order_line/static/src/js/EditOrderButton.esm.js new file mode 100644 index 0000000000..3492d8367a --- /dev/null +++ b/pos_edit_order_line/static/src/js/EditOrderButton.esm.js @@ -0,0 +1,68 @@ +/** @odoo-module */ + +import {ProductScreen} from "@point_of_sale/app/screens/product_screen/product_screen"; +import {usePos} from "@point_of_sale/app/store/pos_hook"; +import {Component} from "@odoo/owl"; +import {_t} from "@web/core/l10n/translation"; +import {useService} from "@web/core/utils/hooks"; +import {ErrorPopup} from "@point_of_sale/app/errors/popups/error_popup"; +import {EditOrderPopup} from "./EditOrderPopup.esm"; + +export class EditOrderButton extends Component { + static template = "pos_edit_order_line.EditOrderButton"; + setup() { + this.pos = usePos(); + this.popup = useService("popup"); + } + async onClick() { + var self = this; + var order = this.pos.get_order(); + var order_lines = order.get_orderlines(); + if (!order_lines.length) { + return this.popup.add(ErrorPopup, { + title: _t("Empty Order"), + body: _t("You need add some products first"), + }); + } + var array = []; + order_lines.forEach((line) => { + array.push({ + id: line.id, + discount: line.discount, + price: line.get_unit_price(), + quantity: line.quantity, + uom: self.pos.units_by_id[line.product.uom_id[0]].name, + name: line.get_full_product_name(), + }); + }); + const {confirmed, payload} = await this.popup.add(EditOrderPopup, { + title: _t("Edit Order Line"), + array: array, + }); + if (confirmed) { + await self.apply_changes(payload); + } + } + async apply_changes(payload) { + var order = this.pos.get_order(); + Object.entries(payload).forEach(([id, changes]) => { + var line = order.get_orderline(parseInt(id, 10)); + Object.entries(changes).forEach(([key, value]) => { + if (key === "quantity") { + line.set_quantity(value); + } else if (key === "price") { + line.set_unit_price(value); + } else if (key === "discount") { + line.set_discount(value); + } + }); + }); + } +} + +ProductScreen.addControlButton({ + component: EditOrderButton, + condition: function () { + return this.pos.config.allow_edit_order_line; + }, +}); diff --git a/pos_edit_order_line/static/src/js/EditOrderLineInput.esm.js b/pos_edit_order_line/static/src/js/EditOrderLineInput.esm.js new file mode 100644 index 0000000000..c1d19ed239 --- /dev/null +++ b/pos_edit_order_line/static/src/js/EditOrderLineInput.esm.js @@ -0,0 +1,42 @@ +/** @odoo-module */ + +import {Component, useState} from "@odoo/owl"; +import {usePos} from "@point_of_sale/app/store/pos_hook"; + +export class EditOrderLineInput extends Component { + static template = "EditOrderLineInput"; + setup() { + super.setup(); + this.pos = usePos(); + this.state = useState({ + quantityInput: this.props.item.quantity, + priceInput: this.props.item.price, + discountInput: this.props.item.discount, + }); + this.changes = { + quantityInput: this.props.item.quantity, + priceInput: this.props.item.price, + discountInput: this.props.item.discount, + }; + } + onChange(event) { + const id = this.props.item.id; + const value = parseFloat(event.target.value.trim()); + const targetElement = event.target; + if (isNaN(value)) { + targetElement.classList.add("required"); + } else { + targetElement.classList.remove("required"); + } + if (this.props.item[targetElement.name] !== value) { + this.changes[targetElement.name] = value; + if (this.props.onchange) { + this.props.onchange({id, changes: this.changes}); + } + } + } + onFocus(event) { + // Select the text inside the input element + event.target.select(); + } +} diff --git a/pos_edit_order_line/static/src/js/EditOrderPopup.esm.js b/pos_edit_order_line/static/src/js/EditOrderPopup.esm.js new file mode 100644 index 0000000000..e92a5e104c --- /dev/null +++ b/pos_edit_order_line/static/src/js/EditOrderPopup.esm.js @@ -0,0 +1,65 @@ +/** @odoo-module */ + +import {useState} from "@odoo/owl"; +import {usePos} from "@point_of_sale/app/store/pos_hook"; +import {EditOrderLineInput} from "./EditOrderLineInput.esm"; +import {AbstractAwaitablePopup} from "@point_of_sale/app/popup/abstract_awaitable_popup"; +import {_t} from "@web/core/l10n/translation"; + +export class EditOrderPopup extends AbstractAwaitablePopup { + static template = "EditOrderPopup"; + static defaultProps = { + confirmText: _t("Save"), + cancelText: _t("Cancel"), + array: [], + }; + static components = {EditOrderLineInput}; + setup() { + super.setup(); + this.pos = usePos(); + this._id = 0; + this.state = useState({array: this._initialize(this.props.array)}); + this.changes = {}; + this.handleChange = this.handleChange.bind(this); + } + _nextId() { + return this._id++; + } + _emptyItem() { + return { + text: "", + _id: this._nextId(), + }; + } + _initialize(array) { + // If no array is provided, we initialize with one empty item. + if (array.length === 0) return [this._emptyItem()]; + // Put _id for each item. It will serve as unique identifier of each item. + return array.map((item) => + Object.assign( + {}, + {_id: this._nextId()}, + typeof item === "object" ? item : {text: item} + ) + ); + } + handleChange({id, changes}) { + this.changes[id] = changes; + } + getPayload() { + return this.changes; + } + async confirm() { + var allowConfirmChanges = true; + Object.values(this.changes).forEach((updates) => { + Object.values(updates).forEach((value) => { + if (isNaN(value)) { + allowConfirmChanges = false; + } + }); + }); + if (allowConfirmChanges) { + this.props.close({confirmed: true, payload: await this.getPayload()}); + } + } +} diff --git a/pos_edit_order_line/static/src/xml/EditOrderButton.xml b/pos_edit_order_line/static/src/xml/EditOrderButton.xml new file mode 100644 index 0000000000..8ffd9e7d4e --- /dev/null +++ b/pos_edit_order_line/static/src/xml/EditOrderButton.xml @@ -0,0 +1,14 @@ + + + + +
+ + Edit Order Lines +
+
+ +
diff --git a/pos_edit_order_line/static/src/xml/EditOrderLineInput.xml b/pos_edit_order_line/static/src/xml/EditOrderLineInput.xml new file mode 100644 index 0000000000..db69c5e849 --- /dev/null +++ b/pos_edit_order_line/static/src/xml/EditOrderLineInput.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pos_edit_order_line/static/src/xml/EditOrderPopup.xml b/pos_edit_order_line/static/src/xml/EditOrderPopup.xml new file mode 100644 index 0000000000..15e654c570 --- /dev/null +++ b/pos_edit_order_line/static/src/xml/EditOrderPopup.xml @@ -0,0 +1,71 @@ + + + + +
+