diff --git a/pos_partner_sale_warning/README.rst b/pos_partner_sale_warning/README.rst new file mode 100644 index 0000000000..5331a51877 --- /dev/null +++ b/pos_partner_sale_warning/README.rst @@ -0,0 +1,116 @@ +========================= +POS Partner Sale Warnings +========================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:bd63148d8dab132753063218015822bb8e430375ca02319b5c8e3f1d515294c1 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_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-18-0/pos-18-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=18.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 + +- Codeforward (https://www.codeforward.nl/): + + - Jord Duineveld + +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..e594d2b750 --- /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": "18.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/app/screens/partner_list/partner_list.esm.js", + ], + "web.assets_tests": [ + "pos_partner_sale_warning/static/src/tests/tours/**/*", + ], + }, + "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..803afbfe5d --- /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 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_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..91fed54d40 --- /dev/null +++ b/pos_partner_sale_warning/models/__init__.py @@ -0,0 +1 @@ +from . import res_partner diff --git a/pos_partner_sale_warning/models/res_partner.py b/pos_partner_sale_warning/models/res_partner.py new file mode 100644 index 0000000000..2005addf8d --- /dev/null +++ b/pos_partner_sale_warning/models/res_partner.py @@ -0,0 +1,12 @@ +from odoo import models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + def _load_pos_data_fields(self, config_id): + """Override to add sale warning fields to the list of fields loaded by POS""" + fields = super()._load_pos_data_fields(config_id) + if self.env.user.has_group("sale.group_warning_sale"): + fields.extend(["sale_warn", "sale_warn_msg"]) + return fields 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..9ce26eda6d --- /dev/null +++ b/pos_partner_sale_warning/readme/CONTRIBUTORS.md @@ -0,0 +1,6 @@ +* Cetmix + * Ivan Sokolov + * Maksim Shurupov + +* Codeforward (https://www.codeforward.nl/): + * Jord Duineveld \<\> 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..3b699db6ea --- /dev/null +++ b/pos_partner_sale_warning/static/description/index.html @@ -0,0 +1,460 @@ + + + + + +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

+ +
+
+

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/app/screens/partner_list/partner_list.esm.js b/pos_partner_sale_warning/static/src/app/screens/partner_list/partner_list.esm.js new file mode 100644 index 0000000000..4af9f5b419 --- /dev/null +++ b/pos_partner_sale_warning/static/src/app/screens/partner_list/partner_list.esm.js @@ -0,0 +1,25 @@ +import {AlertDialog} from "@web/core/confirmation_dialog/confirmation_dialog"; +import {PartnerList} 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"; + +patch(PartnerList.prototype, { + clickPartner(partner) { + if (this.props.partner?.id === partner?.id) { + return super.clickPartner(...arguments); + } + + if (partner?.sale_warn && partner.sale_warn !== "no-message") { + this.dialog.add(AlertDialog, { + title: sprintf(_t("Warning for %s"), partner.name), + body: partner.sale_warn_msg, + }); + + if (partner.sale_warn === "block") { + return; + } + } + return super.clickPartner(...arguments); + }, +}); diff --git a/pos_partner_sale_warning/static/src/tests/tours/PosPartnerSaleWarning.tour.esm.js b/pos_partner_sale_warning/static/src/tests/tours/PosPartnerSaleWarning.tour.esm.js new file mode 100644 index 0000000000..d016897e83 --- /dev/null +++ b/pos_partner_sale_warning/static/src/tests/tours/PosPartnerSaleWarning.tour.esm.js @@ -0,0 +1,78 @@ +import * as Chrome from "@point_of_sale/../tests/tours/utils/chrome_util"; +import * as Dialog from "@point_of_sale/../tests/tours/utils/dialog_util"; +import {registry} from "@web/core/registry"; + +registry.category("web_tour.tours").add("PosPartnerSaleWarning", { + steps: () => + [ + Chrome.startPoS(), + Dialog.confirm("Open Register"), + // 1. Click on 'Customer' Button + { + content: "Test pos_partner_sale_warning: Click on 'Customer' Button", + trigger: "button.set-partner", + run: "click", + }, + // 2. Search for the test partners + { + content: "Test pos_partner_sale_warning: Search for 'Test Partner'", + trigger: ".modal-header input", + run: "edit Test Partner", + }, + // 3. Click the partner with the 'block' warning + { + content: + "Test pos_partner_sale_warning: Click in partner 'Test Partner #1'", + trigger: ".partner-line:contains('Test Partner #1')", + run: "click", + }, + // 4. Check for the blocking warning dialog + { + content: "Check warning title for blocking partner", + trigger: + ".modal-dialog .modal-title:contains('Warning for Test Partner #1')", + }, + { + content: "Check warning body for blocking partner", + trigger: + ".modal-dialog .modal-body:contains('Error Message Test Message')", + }, + // 5. Close the dialog and verify the partner was NOT set + { + content: "Confirm popup by clicking 'Ok'", + trigger: ".modal-footer .btn-primary", + run: "click", + }, + { + content: "Check that the partner was not selected", + trigger: "button.set-partner:contains('Customer')", + }, + // 6. Click the partner with the 'warning' + { + content: "Click on 'Test Partner #2'", + trigger: ".partner-line:contains('Test Partner #2')", + run: "click", + }, + // 7. Check for the non-blocking warning dialog + { + content: "Check warning title for warning partner", + trigger: + ".modal-dialog .modal-title:contains('Warning for Test Partner #2')", + }, + { + content: "Check warning body for warning partner", + trigger: + ".modal-dialog .modal-body:contains('Warning Message Test Message')", + }, + // 8. Close the dialog and verify the partner WAS set + { + content: "Confirm warning by clicking 'Ok'", + trigger: ".modal-footer .btn-primary", + run: "click", + }, + { + content: "Check that 'Test Partner #2' is now the selected customer", + trigger: "button.set-partner:contains('Test Partner #2')", + }, + ].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", + )