From 61f33b1b86d9542cddab54b75405fa684fc667aa Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Sat, 29 Jun 2024 17:23:24 +0200 Subject: [PATCH 1/2] [ADD] new module pos_check_accounting_settings to avoid launching new PoS session with incorrect configuration. --- pos_check_accounting_settings/README.rst | 103 +++++ pos_check_accounting_settings/__init__.py | 1 + pos_check_accounting_settings/__manifest__.py | 15 + pos_check_accounting_settings/i18n/fr.po | 35 ++ .../models/__init__.py | 1 + .../models/pos_config.py | 31 ++ .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 20 + .../description/error_oustanding_payment.png | Bin 0 -> 16116 bytes .../static/description/index.html | 434 ++++++++++++++++++ .../tests/__init__.py | 1 + .../tests/test_module.py | 30 ++ .../odoo/addons/pos_check_accounting_settings | 1 + setup/pos_check_accounting_settings/setup.py | 6 + 14 files changed, 679 insertions(+) create mode 100644 pos_check_accounting_settings/README.rst create mode 100644 pos_check_accounting_settings/__init__.py create mode 100644 pos_check_accounting_settings/__manifest__.py create mode 100644 pos_check_accounting_settings/i18n/fr.po create mode 100644 pos_check_accounting_settings/models/__init__.py create mode 100644 pos_check_accounting_settings/models/pos_config.py create mode 100644 pos_check_accounting_settings/readme/CONTRIBUTORS.rst create mode 100644 pos_check_accounting_settings/readme/DESCRIPTION.rst create mode 100644 pos_check_accounting_settings/static/description/error_oustanding_payment.png create mode 100644 pos_check_accounting_settings/static/description/index.html create mode 100644 pos_check_accounting_settings/tests/__init__.py create mode 100644 pos_check_accounting_settings/tests/test_module.py create mode 120000 setup/pos_check_accounting_settings/odoo/addons/pos_check_accounting_settings create mode 100644 setup/pos_check_accounting_settings/setup.py diff --git a/pos_check_accounting_settings/README.rst b/pos_check_accounting_settings/README.rst new file mode 100644 index 0000000000..005bf844ca --- /dev/null +++ b/pos_check_accounting_settings/README.rst @@ -0,0 +1,103 @@ +========================================= +Point of Sale - Check Accounting Settings +========================================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:95ba837ae556e8ecb7af92cc67c3a0b664e5bc119051ebb1d5a73e01bcdf16ab + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/16.0/pos_check_accounting_settings + :alt: OCA/pos +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/pos-16-0/pos-16-0-pos_check_accounting_settings + :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=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionnality of Odoo PoS adding extra +checks, when opening session, to ensure that accounting configation +is correct. + +Use case 1 +~~~~~~~~~~ + +When we create a payment method and if: +- the field 'Outstanding Payment' is not set on payment method +- AND the field 'Outstanding Receipts Account' is not on company + +if we use the payment method in the Point of sale, it is not +possible to close the session after. + +.. image:: https://raw.githubusercontent.com/OCA/pos/16.0/pos_check_accounting_settings/static/img/error_oustanding_payment.png + +As it not possible to change a payment method when a session +is not closed, this bad configuration has to be fixed by SQL. + +This module adds a check when opening session, to avoid such situation. + +**Table of contents** + +.. contents:: + :local: + +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 (https://twitter.com/legalsylvain) + +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_check_accounting_settings/__init__.py b/pos_check_accounting_settings/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/pos_check_accounting_settings/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/pos_check_accounting_settings/__manifest__.py b/pos_check_accounting_settings/__manifest__.py new file mode 100644 index 0000000000..39f106d19b --- /dev/null +++ b/pos_check_accounting_settings/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop) +# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Point of Sale - Check Accounting Settings", + "version": "16.0.1.0.0", + "category": "Point of Sale", + "summary": "Prevent incorrect accounting configuration" + " when launching Point Of Sale", + "depends": ["point_of_sale"], + "website": "https://github.com/OCA/pos", + "author": "GRAP,Odoo Community Association (OCA)", + "maintainers": ["legalsylvain"], + "license": "LGPL-3", +} diff --git a/pos_check_accounting_settings/i18n/fr.po b/pos_check_accounting_settings/i18n/fr.po new file mode 100644 index 0000000000..7f5c4c41cc --- /dev/null +++ b/pos_check_accounting_settings/i18n/fr.po @@ -0,0 +1,35 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_check_accounting_settings +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-06-29 22:22+0000\n" +"PO-Revision-Date: 2024-06-29 22:22+0000\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_check_accounting_settings +#. odoo-python +#: code:addons/pos_check_accounting_settings/models/pos_config.py:0 +#, python-format +msgid "" +"No outstanding payments/receipts account for the payment method " +"'%(payment_method_name)s'. Please set the field 'Outstanding Payment' on the" +" payment method or the field 'Outstanding Receipts Account' on the company " +"settings." +msgstr "" +"Pas de compte de paiements entrants/sortants en suspens pour la méthode de paiement " +"'%(payment_method_name)s'. Veuillez renseigner le champs 'Paiements sortants en suspens' sur la méthode de paiement, ou le champs 'Compte de paiements entrants en suspens'" +" dans les paramétrage de la société." + +#. module: pos_check_accounting_settings +#: model:ir.model,name:pos_check_accounting_settings.model_pos_config +msgid "Point of Sale Configuration" +msgstr "Configuration du point de vente" diff --git a/pos_check_accounting_settings/models/__init__.py b/pos_check_accounting_settings/models/__init__.py new file mode 100644 index 0000000000..db8634ade1 --- /dev/null +++ b/pos_check_accounting_settings/models/__init__.py @@ -0,0 +1 @@ +from . import pos_config diff --git a/pos_check_accounting_settings/models/pos_config.py b/pos_check_accounting_settings/models/pos_config.py new file mode 100644 index 0000000000..7a9b883946 --- /dev/null +++ b/pos_check_accounting_settings/models/pos_config.py @@ -0,0 +1,31 @@ +# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop) +# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import _, models +from odoo.exceptions import UserError + + +class PosConfig(models.Model): + _inherit = "pos.config" + + def _check_before_creating_new_session(self): + res = super()._check_before_creating_new_session() + for payment_method in self.payment_method_ids.filtered( + lambda x: x.journal_id and x.journal_id.type != "cash" + ): + company = payment_method.journal_id.company_id + if ( + not payment_method.outstanding_account_id + and not company.account_journal_payment_debit_account_id + ): + raise UserError( + _( + "No outstanding payments/receipts account for the payment method" + " '%(payment_method_name)s'." + " Please set the field 'Outstanding Payment' on the payment method" + " or the field 'Outstanding Receipts Account' on the company settings.", + payment_method_name=payment_method.name, + ) + ) + return res diff --git a/pos_check_accounting_settings/readme/CONTRIBUTORS.rst b/pos_check_accounting_settings/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..ae6f43a86d --- /dev/null +++ b/pos_check_accounting_settings/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Sylvain LE GAL (https://twitter.com/legalsylvain) diff --git a/pos_check_accounting_settings/readme/DESCRIPTION.rst b/pos_check_accounting_settings/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..1a25af653d --- /dev/null +++ b/pos_check_accounting_settings/readme/DESCRIPTION.rst @@ -0,0 +1,20 @@ +This module extends the functionnality of Odoo PoS adding extra +checks, when opening session, to ensure that accounting configation +is correct. + +Use case 1 +~~~~~~~~~~ + +When we create a payment method and if: +- the field 'Outstanding Payment' is not set on payment method +- AND the field 'Outstanding Receipts Account' is not on company + +if we use the payment method in the Point of sale, it is not +possible to close the session after. + +.. image:: ../static/img/error_oustanding_payment.png + +As it not possible to change a payment method when a session +is not closed, this bad configuration has to be fixed by SQL. + +This module adds a check when opening session, to avoid such situation. diff --git a/pos_check_accounting_settings/static/description/error_oustanding_payment.png b/pos_check_accounting_settings/static/description/error_oustanding_payment.png new file mode 100644 index 0000000000000000000000000000000000000000..c8b7dc983f23703501bbd4a13634749e8df196fc GIT binary patch literal 16116 zcmch;WmH_jwl0cGa0u=YAh^49un>ZDLJ02e?$$tp1$P<^37X*U?(VLQ1(yaIXylT; z_qlJp`^LWKoH5?L^`m>Osx@oX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6Q0^$xthMuUu!22e$`=QkzGzV3{E>c&LEP~Z zj{e&*?V6%lCSyD0_AG;S8sAm+j8?|{9X8f$xT3$%JNNUdZi}l~DM|DVvHrfbX~()c z*&m`-Y2_IztoS=>pKNyAjK*Hw?x~d6tS0I@G{*O{KlEP9f*V3L^R$O~TDGovpMGmy zG|*LAWJ8+4fDJ$szdg-S$9dxK8+x6+jK73suEGo75fuZ5!vg=#d+yl8PnBZx>r>%% z^GyWRo0=A_bwS62sOupn1vI9;N1Rk15#RT|;1qp#9sS#a)MVpy3-Afv8n>MxGe znLJVCGB<*Mj>^kll7IE`-y}#s(-yS~`d=F`Ynp=pQ4h@!6+Yw7U@m!4uHxU7%70%A zA~nYi|Jip%&&L+`d#fl*(M+B0`SzK>{r82p%WTl!*MDWVbL54KpVj>TC2K#nuZod8 z6VMUJwjEo2apmLbkPvu+F%UX17!VK`pQ-6l|7(VF_8foi`W + + + + +Point of Sale - Check Accounting Settings + + + +
+

Point of Sale - Check Accounting Settings

+ + +

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

+

This module extends the functionnality of Odoo PoS adding extra +checks, when opening session, to ensure that accounting configation +is correct.

+
+

Use case 1

+

When we create a payment method and if: +- the field ‘Outstanding Payment’ is not set on payment method +- AND the field ‘Outstanding Receipts Account’ is not on company

+

if we use the payment method in the Point of sale, it is not +possible to close the session after.

+https://raw.githubusercontent.com/OCA/pos/16.0/pos_check_accounting_settings/static/img/error_oustanding_payment.png +

As it not possible to change a payment method when a session +is not closed, this bad configuration has to be fixed by SQL.

+

This module adds a check when opening session, to avoid such situation.

+

Table of contents

+ +
+

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.

+
+ +
+
+

Authors

+
    +
  • GRAP
  • +
+
+
+

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.

+

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_check_accounting_settings/tests/__init__.py b/pos_check_accounting_settings/tests/__init__.py new file mode 100644 index 0000000000..d9b96c4fa5 --- /dev/null +++ b/pos_check_accounting_settings/tests/__init__.py @@ -0,0 +1 @@ +from . import test_module diff --git a/pos_check_accounting_settings/tests/test_module.py b/pos_check_accounting_settings/tests/test_module.py new file mode 100644 index 0000000000..20c1f5e4d3 --- /dev/null +++ b/pos_check_accounting_settings/tests/test_module.py @@ -0,0 +1,30 @@ +# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop) +# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.exceptions import UserError +from odoo.tests.common import TransactionCase + + +class TestModule(TransactionCase): + def setUp(self): + super().setUp() + self.pos_config = self.env.ref("point_of_sale.pos_config_main").copy( + default={ + "payment_method_ids": self.env.ref( + "point_of_sale.pos_config_main" + ).payment_method_ids.ids + } + ) + self.bank_payment_method = self.pos_config.payment_method_ids.filtered( + lambda x: x.journal_id.type == "bank" and not x.split_transactions + ) + + def test_correct_configuration(self): + self.pos_config.open_ui() + + def test_incorrect_configuration(self): + self.bank_payment_method.outstanding_account_id = False + self.env.company.account_journal_payment_debit_account_id = False + with self.assertRaises(UserError): + self.pos_config.open_ui() diff --git a/setup/pos_check_accounting_settings/odoo/addons/pos_check_accounting_settings b/setup/pos_check_accounting_settings/odoo/addons/pos_check_accounting_settings new file mode 120000 index 0000000000..db11b735e3 --- /dev/null +++ b/setup/pos_check_accounting_settings/odoo/addons/pos_check_accounting_settings @@ -0,0 +1 @@ +../../../../pos_check_accounting_settings \ No newline at end of file diff --git a/setup/pos_check_accounting_settings/setup.py b/setup/pos_check_accounting_settings/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/pos_check_accounting_settings/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) From 9224c3ec810a0d7459fa80bc02beccbe858b976a Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Sun, 30 Jun 2024 01:30:02 +0200 Subject: [PATCH 2/2] [IMP] pos_payment_change : simplify code of test, and make it compatible with pos_check_accounting_settings_company module --- pos_payment_change/tests/test_module.py | 44 +++++++++---------------- 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/pos_payment_change/tests/test_module.py b/pos_payment_change/tests/test_module.py index 53a7162cbc..4239ff6db2 100644 --- a/pos_payment_change/tests/test_module.py +++ b/pos_payment_change/tests/test_module.py @@ -22,35 +22,21 @@ def setUp(self): "pos.payment.change.wizard.new.line" ] self.product = self.env.ref("product.product_product_3") - self.pos_config = self.env.ref("point_of_sale.pos_config_main").copy() - - def _initialize_journals_open_session(self): - account_id = self.env.company.account_default_pos_receivable_account_id - self.bank_payment_method = self.PosPaymentMethod.create( - { - "name": "Bank", - "receivable_account_id": account_id.id, + self.pos_config = self.env.ref("point_of_sale.pos_config_main").copy( + default={ + "payment_method_ids": self.env.ref( + "point_of_sale.pos_config_main" + ).payment_method_ids.ids } ) - self.cash_payment_method = self.PosPaymentMethod.create( - { - "name": "Cash", - "is_cash_count": True, - "receivable_account_id": account_id.id, - "journal_id": self.env["account.journal"] - .search( - [("type", "=", "cash"), ("company_id", "=", self.env.company.id)], - limit=1, - ) - .id, - } + self.cash_payment_method = self.pos_config.payment_method_ids.filtered( + lambda x: x.journal_id.type == "cash" + ) + self.bank_payment_method = self.pos_config.payment_method_ids.filtered( + lambda x: x.journal_id.type == "bank" and not x.split_transactions ) - # create new session and open it - self.pos_config.payment_method_ids = [ - self.bank_payment_method.id, - self.cash_payment_method.id, - ] + def _open_session(self): self.pos_config.open_ui() self.session = self.pos_config.current_session_id @@ -120,7 +106,7 @@ def _change_payment( def test_01_payment_change_policy_update(self): self.pos_config.payment_change_policy = "update" - self._initialize_journals_open_session() + self._open_session() # Make a sale with 35 in cash journal and 65 in check order = self._sale(self.cash_payment_method, 35, self.bank_payment_method, 65) @@ -165,7 +151,7 @@ def test_01_payment_change_policy_update(self): def test_02_payment_change_policy_refund(self): self.pos_config.payment_change_policy = "refund" - self._initialize_journals_open_session() + self._open_session() # Make a sale with 35 in cash journal and 65 in check order = self._sale(self.cash_payment_method, 35, self.bank_payment_method, 65) @@ -185,7 +171,7 @@ def test_02_payment_change_policy_refund(self): def test_03_payment_change_closed_orders(self): self.pos_config.payment_change_policy = "update" - self._initialize_journals_open_session() + self._open_session() # Make a sale with 35 in cash journal and 65 in check order = self._sale(self.cash_payment_method, 35, self.bank_payment_method, 65) @@ -198,7 +184,7 @@ def test_03_payment_change_closed_orders(self): def test_04_payment_change_security(self): self.pos_config.payment_change_policy = "refund" - self._initialize_journals_open_session() + self._open_session() order = self._sale(self.cash_payment_method, 35, self.bank_payment_method, 65) # the demo user should be able to do this