Skip to content

Commit

Permalink
Merge PR #1270 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Dec 4, 2024
2 parents 121f94e + a1560ad commit a66bcc2
Show file tree
Hide file tree
Showing 16 changed files with 667 additions and 0 deletions.
107 changes: 107 additions & 0 deletions pos_cash_control_override/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
===================================
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 <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.

Usage
=====

After this module is installed:

1. Choose a user with *Point of Sale/User* permissions but no
*Accounting/Billing* permission.
2. Open a session in a Point of Sale with cash control active.
3. You'll be able to do any of 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 <https://github.com/OCA/pos/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 <https://github.com/OCA/pos/issues/new?body=module:%20pos_cash_control_override%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Tecnativa

Contributors
------------

- `Tecnativa <https://tecnativa.com>`__

- 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 <https://github.com/OCA/pos/tree/16.0/pos_cash_control_override>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions pos_cash_control_override/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions pos_cash_control_override/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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": [],
}
2 changes: 2 additions & 0 deletions pos_cash_control_override/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import account_bank_statement_line
from . import pos_session
15 changes: 15 additions & 0 deletions pos_cash_control_override/models/account_bank_statement_line.py
Original file line number Diff line number Diff line change
@@ -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)
17 changes: 17 additions & 0 deletions pos_cash_control_override/models/pos_session.py
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions pos_cash_control_override/readme/CONTEXT.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 2 additions & 0 deletions pos_cash_control_override/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [Tecnativa](https://tecnativa.com)
- David Vidal
2 changes: 2 additions & 0 deletions pos_cash_control_override/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module restores the permissions requisites for Point of Sale users to perform
cash operations in their sessions.
2 changes: 2 additions & 0 deletions pos_cash_control_override/readme/ROADMAP.md
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 5 additions & 0 deletions pos_cash_control_override/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
After this module is installed:

1. Choose a user with *Point of Sale/User* permissions but no *Accounting/Billing* permission.
2. Open a session in a Point of Sale with cash control active.
3. You'll be able to do any of the cash control operations (cash in / out).
Loading

0 comments on commit a66bcc2

Please sign in to comment.