From f931a432aa3ecc540d2813fbca3a0671b1c699c6 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 27 Nov 2024 15:10:39 +0100 Subject: [PATCH] [ADD] pos_cash_control_override: New module TT51987 --- pos_cash_control_override/README.rst | 105 ++++ pos_cash_control_override/__init__.py | 1 + pos_cash_control_override/__manifest__.py | 15 + pos_cash_control_override/models/__init__.py | 2 + .../models/account_bank_statement_line.py | 15 + .../models/pos_session.py | 17 + pos_cash_control_override/readme/CONTEXT.md | 5 + .../readme/CONTRIBUTORS.md | 2 + .../readme/DESCRIPTION.md | 2 + pos_cash_control_override/readme/ROADMAP.md | 2 + pos_cash_control_override/readme/USAGE.md | 5 + .../static/description/index.html | 455 ++++++++++++++++++ pos_cash_control_override/tests/__init__.py | 1 + .../tests/test_frontend.py | 29 ++ .../odoo/addons/pos_cash_control_override | 1 + setup/pos_cash_control_override/setup.py | 6 + 16 files changed, 663 insertions(+) create mode 100644 pos_cash_control_override/README.rst create mode 100644 pos_cash_control_override/__init__.py create mode 100644 pos_cash_control_override/__manifest__.py create mode 100644 pos_cash_control_override/models/__init__.py create mode 100644 pos_cash_control_override/models/account_bank_statement_line.py create mode 100644 pos_cash_control_override/models/pos_session.py create mode 100644 pos_cash_control_override/readme/CONTEXT.md create mode 100644 pos_cash_control_override/readme/CONTRIBUTORS.md create mode 100644 pos_cash_control_override/readme/DESCRIPTION.md create mode 100644 pos_cash_control_override/readme/ROADMAP.md create mode 100644 pos_cash_control_override/readme/USAGE.md create mode 100644 pos_cash_control_override/static/description/index.html create mode 100644 pos_cash_control_override/tests/__init__.py create mode 100644 pos_cash_control_override/tests/test_frontend.py create mode 120000 setup/pos_cash_control_override/odoo/addons/pos_cash_control_override create mode 100644 setup/pos_cash_control_override/setup.py diff --git a/pos_cash_control_override/README.rst b/pos_cash_control_override/README.rst new file mode 100644 index 0000000000..c5c5aa96c2 --- /dev/null +++ b/pos_cash_control_override/README.rst @@ -0,0 +1,105 @@ +=================================== +Point of sale cash control override +=================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:56d19ad35a758bf8f5dbbc2b81f7cd13423c513262350bde69fb801b32e8313b + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/16.0/pos_cash_control_override + :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_cash_control_override + :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 restores the permissions requisites for Point of Sale users +to perform cash operations in their sessions. + +**Table of contents** + +.. contents:: + :local: + +Use Cases / Context +=================== + +From `this change `__ a Point +of Sale user who needs to perform cash control operations +*Accounting/Billing* permission is required. That's a huge permission +for the kind of user that only does cashing machine operations. + +We're recovering the former behavior present in previous versions. + +Usage +===== + +After this module is installed: + +1. Choose a user with all the permissions execpt *Point of Sale/User*. +2. Open a session in a Point of Sale with cash control active. +3. You'll be able to do any the cash control operations (cash in / out). + +Known issues / Roadmap +====================== + +- This module will be unnecessary if + https://github.com/odoo/odoo/pull/188798 gets merged or the former + permissions paradigm is restored in any other way. + +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 +------- + +* Tecnativa + +Contributors +------------ + +- `Tecnativa `__ + + - David Vidal + +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_cash_control_override/__init__.py b/pos_cash_control_override/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/pos_cash_control_override/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/pos_cash_control_override/__manifest__.py b/pos_cash_control_override/__manifest__.py new file mode 100644 index 0000000000..da9af4a1e5 --- /dev/null +++ b/pos_cash_control_override/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2024 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + "name": "Point of sale cash control override", + "summary": "Override bare PoS user cash control restrictions", + "version": "16.0.1.0.0", + "category": "Point of Sale", + "author": "Tecnativa, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/pos", + "license": "AGPL-3", + "depends": [ + "point_of_sale", + ], + "data": [], +} diff --git a/pos_cash_control_override/models/__init__.py b/pos_cash_control_override/models/__init__.py new file mode 100644 index 0000000000..0038997e48 --- /dev/null +++ b/pos_cash_control_override/models/__init__.py @@ -0,0 +1,2 @@ +from . import account_bank_statement_line +from . import pos_session diff --git a/pos_cash_control_override/models/account_bank_statement_line.py b/pos_cash_control_override/models/account_bank_statement_line.py new file mode 100644 index 0000000000..b19295eda6 --- /dev/null +++ b/pos_cash_control_override/models/account_bank_statement_line.py @@ -0,0 +1,15 @@ +# Copyright 2024 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import api, models + + +class AccountBankStatementLine(models.Model): + _inherit = "account.bank.statement.line" + + @api.model_create_multi + def create(self, vals_list): + if self.env.context.get( + "override_cash_control_permissions" + ) and self.user_has_groups("point_of_sale.group_pos_user"): + self = self.sudo() + return super().create(vals_list) diff --git a/pos_cash_control_override/models/pos_session.py b/pos_cash_control_override/models/pos_session.py new file mode 100644 index 0000000000..576ee0d06c --- /dev/null +++ b/pos_cash_control_override/models/pos_session.py @@ -0,0 +1,17 @@ +# Copyright 2024 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import models + + +class PosSession(models.Model): + _inherit = "pos.session" + + def try_cash_in_out(self, _type, amount, reason, extras): + if not self.user_has_groups("account.group_account_invoice"): + self = self.with_context(override_cash_control_permissions=True) + return super().try_cash_in_out(_type, amount, reason, extras) + + def _get_pos_ui_pos_config(self, params): + config = super()._get_pos_ui_pos_config(params) + config["has_cash_move_permission"] = True + return config diff --git a/pos_cash_control_override/readme/CONTEXT.md b/pos_cash_control_override/readme/CONTEXT.md new file mode 100644 index 0000000000..684fc3a777 --- /dev/null +++ b/pos_cash_control_override/readme/CONTEXT.md @@ -0,0 +1,5 @@ +From [this change](https://github.com/odoo/odoo/pull/130275) a Point of Sale user +who needs to perform cash control operations *Accounting/Billing* permission is required. +That's a huge permission for the kind of user that only does cashing machine operations. + +We're recovering the former behavior present in previous versions. diff --git a/pos_cash_control_override/readme/CONTRIBUTORS.md b/pos_cash_control_override/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..3a16ddf047 --- /dev/null +++ b/pos_cash_control_override/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- [Tecnativa](https://tecnativa.com) + - David Vidal diff --git a/pos_cash_control_override/readme/DESCRIPTION.md b/pos_cash_control_override/readme/DESCRIPTION.md new file mode 100644 index 0000000000..58e2a991bb --- /dev/null +++ b/pos_cash_control_override/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module restores the permissions requisites for Point of Sale users to perform +cash operations in their sessions. diff --git a/pos_cash_control_override/readme/ROADMAP.md b/pos_cash_control_override/readme/ROADMAP.md new file mode 100644 index 0000000000..e3f025a043 --- /dev/null +++ b/pos_cash_control_override/readme/ROADMAP.md @@ -0,0 +1,2 @@ +- This module will be unnecessary if https://github.com/odoo/odoo/pull/188798 gets + merged or the former permissions paradigm is restored in any other way. diff --git a/pos_cash_control_override/readme/USAGE.md b/pos_cash_control_override/readme/USAGE.md new file mode 100644 index 0000000000..6cca58e145 --- /dev/null +++ b/pos_cash_control_override/readme/USAGE.md @@ -0,0 +1,5 @@ +After this module is installed: + +1. Choose a user with all the permissions execpt *Point of Sale/User*. +2. Open a session in a Point of Sale with cash control active. +3. You'll be able to do any the cash control operations (cash in / out). diff --git a/pos_cash_control_override/static/description/index.html b/pos_cash_control_override/static/description/index.html new file mode 100644 index 0000000000..7655451aea --- /dev/null +++ b/pos_cash_control_override/static/description/index.html @@ -0,0 +1,455 @@ + + + + + +Point of sale cash control override + + + +
+

Point of sale cash control override

+ + +

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

+

This module restores the permissions requisites for Point of Sale users +to perform cash operations in their sessions.

+

Table of contents

+ +
+

Use Cases / Context

+

From this change a Point +of Sale user who needs to perform cash control operations +Accounting/Billing permission is required. That’s a huge permission +for the kind of user that only does cashing machine operations.

+

We’re recovering the former behavior present in previous versions.

+
+
+

Usage

+

After this module is installed:

+
    +
  1. Choose a user with all the permissions execpt Point of Sale/User.
  2. +
  3. Open a session in a Point of Sale with cash control active.
  4. +
  5. You’ll be able to do any the cash control operations (cash in / out).
  6. +
+
+
+

Known issues / Roadmap

+ +
+
+

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

+
    +
  • Tecnativa
  • +
+
+
+

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_cash_control_override/tests/__init__.py b/pos_cash_control_override/tests/__init__.py new file mode 100644 index 0000000000..ab211c0007 --- /dev/null +++ b/pos_cash_control_override/tests/__init__.py @@ -0,0 +1 @@ +from . import test_frontend diff --git a/pos_cash_control_override/tests/test_frontend.py b/pos_cash_control_override/tests/test_frontend.py new file mode 100644 index 0000000000..536a0f6d23 --- /dev/null +++ b/pos_cash_control_override/tests/test_frontend.py @@ -0,0 +1,29 @@ +# Copyright 2024 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import Command +from odoo.tests import tagged + +from odoo.addons.point_of_sale.tests.test_frontend import TestPointOfSaleHttpCommon + + +@tagged("post_install", "-at_install") +class TestUi(TestPointOfSaleHttpCommon): + def test_chrome_without_accounting_permission(self): + self.env.user.write( + { + "groups_id": [ + Command.set( + [ + self.env.ref("base.group_user").id, + self.env.ref("point_of_sale.group_pos_user").id, + ] + ) + ] + } + ) + self.main_pos_config.open_ui() + self.start_tour( + "/pos/ui?config_id=%d" % self.main_pos_config.id, + "ChromeTour", + login="accountman", + ) diff --git a/setup/pos_cash_control_override/odoo/addons/pos_cash_control_override b/setup/pos_cash_control_override/odoo/addons/pos_cash_control_override new file mode 120000 index 0000000000..2582e55377 --- /dev/null +++ b/setup/pos_cash_control_override/odoo/addons/pos_cash_control_override @@ -0,0 +1 @@ +../../../../pos_cash_control_override \ No newline at end of file diff --git a/setup/pos_cash_control_override/setup.py b/setup/pos_cash_control_override/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/pos_cash_control_override/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)