diff --git a/pos_partner_sale_warning/README.rst b/pos_partner_sale_warning/README.rst new file mode 100644 index 0000000000..3b5c0da232 --- /dev/null +++ b/pos_partner_sale_warning/README.rst @@ -0,0 +1,112 @@ +========================= +POS Partner Sale Warnings +========================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:785171ea5bffb78bc4fdbf43155a0614913d7eca35d68963a7416c7264b5613d + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_partner_sale_warning + :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_partner_sale_warning + :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 shows partner warnings when a partner is selected in POS. + +**Table of contents** + +.. contents:: + :local: + +Use Cases / Context +=================== + +Odoo allows to configure warnings for partners and products to be shown +when a new sales order is created. + +However those warnings will not be shown for a POS order. + +Configuration +============= + +This module requires "sale_management" module to be installed. + +When installed go to the "Settings/Sales" menu and scroll to the +"Quotations & Orders" section. + +Activate the "Sale Warnings" checkbox. + +Usage +===== + +On a partner form open the "Internal Notes" tab, and select a message +type in the "WARNING ON THE SALES ORDER" field. Add the warning text to +be shown in the field below. + +When this partner is selected in POS a warning will be shown. Depending +on the warning type it can be a blocking or a non-blocking one. + +Known issues / Roadmap +====================== + +TODO: add support for product messages + +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 +------- + +* Cetmix + +Contributors +------------ + +- Cetmix + + - Ivan Sokolov + - Maksim Shurupov + +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_partner_sale_warning/__init__.py b/pos_partner_sale_warning/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/pos_partner_sale_warning/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/pos_partner_sale_warning/__manifest__.py b/pos_partner_sale_warning/__manifest__.py new file mode 100644 index 0000000000..eb7b14a402 --- /dev/null +++ b/pos_partner_sale_warning/__manifest__.py @@ -0,0 +1,23 @@ +# Copyright (C) 2023 Cetmix OÜ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "POS Partner Sale Warnings", + "version": "17.0.1.0.0", + "category": "Sales/Point of Sale", + "summary": "Show partner sales warning in POS", + "depends": ["sale_management", "point_of_sale"], + "website": "https://github.com/OCA/pos", + "author": "Cetmix, Odoo Community Association (OCA)", + "license": "AGPL-3", + "data": [], + "assets": { + "point_of_sale._assets_pos": [ + "pos_partner_sale_warning/static/src/js/*.esm.js", + ], + "web.assets_tests": [ + "pos_partner_sale_warning/static/src/tests/tours/PosPartnerSaleWarning.esm.js", + ], + }, + "installable": True, +} diff --git a/pos_partner_sale_warning/i18n/es.po b/pos_partner_sale_warning/i18n/es.po new file mode 100644 index 0000000000..1bd6721acc --- /dev/null +++ b/pos_partner_sale_warning/i18n/es.po @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_partner_sale_warning +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-02-06 09:09+0000\n" +"Last-Translator: Daniel Duque \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_partner_sale_warning +#: model:ir.model,name:pos_partner_sale_warning.model_pos_session +msgid "Point of Sale Session" +msgstr "Sesión TPV" + +#. module: pos_partner_sale_warning +#. odoo-javascript +#: code:addons/pos_partner_sale_warning/static/src/js/PartnerListScreen.esm.js:0 +#, python-format +msgid "Warning for %s" +msgstr "Aviso para %s" diff --git a/pos_partner_sale_warning/i18n/it.po b/pos_partner_sale_warning/i18n/it.po new file mode 100644 index 0000000000..75e70d21a2 --- /dev/null +++ b/pos_partner_sale_warning/i18n/it.po @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_partner_sale_warning +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-01-19 09:34+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.17\n" + +#. module: pos_partner_sale_warning +#: model:ir.model,name:pos_partner_sale_warning.model_pos_session +msgid "Point of Sale Session" +msgstr "Sessione punto vendita" + +#. module: pos_partner_sale_warning +#. odoo-javascript +#: code:addons/pos_partner_sale_warning/static/src/js/PartnerListScreen.esm.js:0 +#, python-format +msgid "Warning for %s" +msgstr "Avviso per %s" diff --git a/pos_partner_sale_warning/i18n/pos_partner_sale_warning.pot b/pos_partner_sale_warning/i18n/pos_partner_sale_warning.pot new file mode 100644 index 0000000000..7920815592 --- /dev/null +++ b/pos_partner_sale_warning/i18n/pos_partner_sale_warning.pot @@ -0,0 +1,26 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_partner_sale_warning +# +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_partner_sale_warning +#: model:ir.model,name:pos_partner_sale_warning.model_pos_session +msgid "Point of Sale Session" +msgstr "" + +#. module: pos_partner_sale_warning +#. odoo-javascript +#: code:addons/pos_partner_sale_warning/static/src/js/PartnerListScreen.esm.js:0 +#, python-format +msgid "Warning for %s" +msgstr "" diff --git a/pos_partner_sale_warning/models/__init__.py b/pos_partner_sale_warning/models/__init__.py new file mode 100644 index 0000000000..f7116e3d45 --- /dev/null +++ b/pos_partner_sale_warning/models/__init__.py @@ -0,0 +1 @@ +from . import pos_session diff --git a/pos_partner_sale_warning/models/pos_session.py b/pos_partner_sale_warning/models/pos_session.py new file mode 100644 index 0000000000..f68845a542 --- /dev/null +++ b/pos_partner_sale_warning/models/pos_session.py @@ -0,0 +1,14 @@ +# Copyright (C) 2023 Cetmix OÜ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models + + +class PosSession(models.Model): + _inherit = "pos.session" + + def _loader_params_res_partner(self): + result = super()._loader_params_res_partner() + if self.user_has_groups("sale.group_warning_sale"): + result["search_params"]["fields"] += ["sale_warn", "sale_warn_msg"] + return result diff --git a/pos_partner_sale_warning/pyproject.toml b/pos_partner_sale_warning/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/pos_partner_sale_warning/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/pos_partner_sale_warning/readme/CONFIGURE.md b/pos_partner_sale_warning/readme/CONFIGURE.md new file mode 100644 index 0000000000..5dbdb4e942 --- /dev/null +++ b/pos_partner_sale_warning/readme/CONFIGURE.md @@ -0,0 +1,5 @@ +This module requires "sale_management" module to be installed. + +When installed go to the "Settings/Sales" menu and scroll to the "Quotations & Orders" section. + +Activate the "Sale Warnings" checkbox. diff --git a/pos_partner_sale_warning/readme/CONTEXT.md b/pos_partner_sale_warning/readme/CONTEXT.md new file mode 100644 index 0000000000..da6a3813ec --- /dev/null +++ b/pos_partner_sale_warning/readme/CONTEXT.md @@ -0,0 +1,3 @@ +Odoo allows to configure warnings for partners and products to be shown when a new sales order is created. + +However those warnings will not be shown for a POS order. diff --git a/pos_partner_sale_warning/readme/CONTRIBUTORS.md b/pos_partner_sale_warning/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..4a26c35d5b --- /dev/null +++ b/pos_partner_sale_warning/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +* Cetmix + * Ivan Sokolov + * Maksim Shurupov diff --git a/pos_partner_sale_warning/readme/DESCRIPTION.md b/pos_partner_sale_warning/readme/DESCRIPTION.md new file mode 100644 index 0000000000..3d1aafe989 --- /dev/null +++ b/pos_partner_sale_warning/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This module shows partner warnings when a partner is selected in POS. diff --git a/pos_partner_sale_warning/readme/ROADMAP.md b/pos_partner_sale_warning/readme/ROADMAP.md new file mode 100644 index 0000000000..19f1bfa814 --- /dev/null +++ b/pos_partner_sale_warning/readme/ROADMAP.md @@ -0,0 +1 @@ +TODO: add support for product messages diff --git a/pos_partner_sale_warning/readme/USAGE.md b/pos_partner_sale_warning/readme/USAGE.md new file mode 100644 index 0000000000..93c2f36f71 --- /dev/null +++ b/pos_partner_sale_warning/readme/USAGE.md @@ -0,0 +1,3 @@ +On a partner form open the "Internal Notes" tab, and select a message type in the "WARNING ON THE SALES ORDER" field. Add the warning text to be shown in the field below. + +When this partner is selected in POS a warning will be shown. Depending on the warning type it can be a blocking or a non-blocking one. diff --git a/pos_partner_sale_warning/static/description/icon.png b/pos_partner_sale_warning/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/pos_partner_sale_warning/static/description/icon.png differ diff --git a/pos_partner_sale_warning/static/description/index.html b/pos_partner_sale_warning/static/description/index.html new file mode 100644 index 0000000000..acf112aaac --- /dev/null +++ b/pos_partner_sale_warning/static/description/index.html @@ -0,0 +1,456 @@ + + + + + +POS Partner Sale Warnings + + + +
+

POS Partner Sale Warnings

+ + +

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

+

This module shows partner warnings when a partner is selected in POS.

+

Table of contents

+ +
+

Use Cases / Context

+

Odoo allows to configure warnings for partners and products to be shown +when a new sales order is created.

+

However those warnings will not be shown for a POS order.

+
+
+

Configuration

+

This module requires “sale_management” module to be installed.

+

When installed go to the “Settings/Sales” menu and scroll to the +“Quotations & Orders” section.

+

Activate the “Sale Warnings” checkbox.

+
+
+

Usage

+

On a partner form open the “Internal Notes” tab, and select a message +type in the “WARNING ON THE SALES ORDER” field. Add the warning text to +be shown in the field below.

+

When this partner is selected in POS a warning will be shown. Depending +on the warning type it can be a blocking or a non-blocking one.

+
+
+

Known issues / Roadmap

+

TODO: add support for product messages

+
+
+

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

+
    +
  • Cetmix
  • +
+
+
+

Contributors

+
    +
  • Cetmix <cetmix.com>
      +
    • Ivan Sokolov
    • +
    • Maksim Shurupov
    • +
    +
  • +
+
+
+

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_partner_sale_warning/static/src/js/PartnerListScreen.esm.js b/pos_partner_sale_warning/static/src/js/PartnerListScreen.esm.js new file mode 100644 index 0000000000..85b2452765 --- /dev/null +++ b/pos_partner_sale_warning/static/src/js/PartnerListScreen.esm.js @@ -0,0 +1,33 @@ +/** @odoo-module **/ + +import {ErrorPopup} from "@point_of_sale/app/errors/popups/error_popup"; +import {PartnerListScreen} from "@point_of_sale/app/screens/partner_list/partner_list"; +import {_t} from "@web/core/l10n/translation"; +import {patch} from "@web/core/utils/patch"; +import {sprintf} from "@web/core/utils/strings"; +import {useService} from "@web/core/utils/hooks"; + +patch(PartnerListScreen.prototype, { + setup() { + super.setup(); + this.popup = useService("popup"); + }, + clickPartner(partner) { + if ( + this.state.selectedPartner && + this.state.selectedPartner.id === partner.id + ) { + return super.clickPartner(partner); + } + if (partner && partner.sale_warn && partner.sale_warn !== "no-message") { + this.popup.add(ErrorPopup, { + title: sprintf(_t("Warning for %s"), partner.name), + body: partner.sale_warn_msg, + }); + if (partner.sale_warn === "block") { + return; + } + } + return super.clickPartner(partner); + }, +}); diff --git a/pos_partner_sale_warning/static/src/tests/tours/PosPartnerSaleWarning.esm.js b/pos_partner_sale_warning/static/src/tests/tours/PosPartnerSaleWarning.esm.js new file mode 100644 index 0000000000..ae75f77dbb --- /dev/null +++ b/pos_partner_sale_warning/static/src/tests/tours/PosPartnerSaleWarning.esm.js @@ -0,0 +1,102 @@ +/** @odoo-module */ +import {registry} from "@web/core/registry"; + +const startSteps = [ + { + content: "Test pos_partner_sale_warning: Waiting for loading to finish", + trigger: "body:not(:has(.loader))", + // eslint-disable-next-line no-empty-function + run: () => {}, + }, + { + content: "Test pos_partner_sale_warning: Close Opening cashbox popup", + trigger: "div.opening-cash-control .button:contains('Open session')", + }, + { + content: "Test pos_partner_sale_warning: Click on 'Customer' Button", + trigger: "button.set-partner", + }, + { + content: "Test pos_partner_sale_warning: Search partner 'Test Partner #1'", + trigger: ".pos-search-bar input", + run: "text 'Test Partner'", + }, +]; + +const endSteps = [ + { + content: "Test pos_partner_sale_warning: Open menu Point of Sale", + trigger: "div.navbar-button.menu-button", + run: "click", + }, + { + content: + "Test pos_partner_sale_warning: Open modal confirm closing Point of Sale", + trigger: "li.close-button", + run: "click", + }, + { + content: "Test pos_partner_sale_warning: Confirm closing the frontend", + extra_trigger: "div.popup.close-pos-popup", + trigger: "button.button.highlight", + run: "click", + }, +]; + +registry.category("web_tour.tours").add("PosPartnerSaleWarning", { + test: true, + url: "/pos/ui", + steps: () => + [ + ...startSteps, + { + content: "Test pos_partner_sale_warning: Click in partner", + trigger: "tr.partner-line:has(td b:contains('Test Partner #1'))", + run: "click", + }, + { + content: "Test pos_partner_sale_warning: Check warning text", + extra_trigger: ".modal-dialog", + trigger: ".modal-dialog .title:contains('Warning for Test Partner #1')", + }, + { + content: "Test pos_partner_sale_warning: Check warning text", + extra_trigger: ".modal-dialog", + trigger: "main.modal-body:contains('Error Message Test Message')", + // eslint-disable-next-line no-empty-function + run: () => {}, + }, + { + content: + "Test pos_partner_sale_warning: Confirm popup click on 'Ok' Button", + trigger: ".modal-dialog .modal-footer .button:contains('Ok')", + run: "click", + }, + { + content: "Test pos_partner_sale_warning: Click on 'Test Partner #2'", + trigger: "tr.partner-line:has(td b:contains('Test Partner #2'))", + run: "click", + }, + { + content: "Test pos_partner_sale_warning: Check warning text", + extra_trigger: ".modal-dialog", + trigger: ".modal-dialog .title:contains('Warning for Test Partner #2')", + // eslint-disable-next-line no-empty-function + run: () => {}, + }, + { + content: "Test pos_partner_sale_warning: Check warning text", + extra_trigger: ".modal-dialog", + trigger: "main.modal-body:contains('Warning Message Test Message')", + // eslint-disable-next-line no-empty-function + run: () => {}, + }, + { + content: "Test pos_partner_sale_warning: Click on 'Customer' Button", + trigger: "button.set-partner:contains('Test Partner #2')", + // eslint-disable-next-line no-empty-function + run: () => {}, + }, + ...endSteps, + ].flat(), +}); diff --git a/pos_partner_sale_warning/tests/__init__.py b/pos_partner_sale_warning/tests/__init__.py new file mode 100644 index 0000000000..3c930e73c1 --- /dev/null +++ b/pos_partner_sale_warning/tests/__init__.py @@ -0,0 +1 @@ +from . import test_pos_ui diff --git a/pos_partner_sale_warning/tests/test_pos_ui.py b/pos_partner_sale_warning/tests/test_pos_ui.py new file mode 100644 index 0000000000..1ecc8d57c9 --- /dev/null +++ b/pos_partner_sale_warning/tests/test_pos_ui.py @@ -0,0 +1,38 @@ +# Copyright (C) 2023 Cetmix OÜ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests import tagged + +from odoo.addons.point_of_sale.tests.test_frontend import TestPointOfSaleHttpCommon + + +@tagged("post_install", "-at_install") +class TestUi(TestPointOfSaleHttpCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + cls.partner1 = cls.env["res.partner"].create( + { + "name": "Test Partner #1", + "sale_warn": "block", + "sale_warn_msg": "Error Message Test Message", + } + ) + cls.partner2 = cls.env["res.partner"].create( + { + "name": "Test Partner #2", + "sale_warn": "warning", + "sale_warn_msg": "Warning Message Test Message", + } + ) + + def test_pos_partner_sale_warning(self): + """Module behavior test""" + self.env.user.groups_id += self.env.ref("sale.group_warning_sale") + self.main_pos_config.open_ui() + self.start_tour( + f"/pos/ui?config_id={self.main_pos_config.id}", + "PosPartnerSaleWarning", + login="accountman", + )