Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0] [ADD] pos_detailed_cash_register #1288

Open
wants to merge 2 commits into
base: 14.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions pos_detailed_cash_register/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
==========================
PoS Detailed Cash Register
==========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:bbff343997230e5b781ff2ff2a3492fea678a0464f5874f9225fb876327dc3f5
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/14.0/pos_detailed_cash_register
:alt: OCA/pos
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/pos-14-0/pos-14-0-pos_detailed_cash_register
: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=14.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module splits the "+ Transactions" lines in the cash control view of a PoS
session into the current transaction and the Cash In/Out lines.

It also adds a new tab in the PoS session listing the cash in/out operations
with their reasons.

**Table of contents**

.. contents::
:local:

Usage
=====

The cash control must be enabled for the PoS session.

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_detailed_cash_register%0Aversion:%2014.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
~~~~~~~

* Akretion

Contributors
~~~~~~~~~~~~

* `Akretion <https://www.akretion.com>`_:

* Florian Mounier

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/14.0/pos_detailed_cash_register>`_ 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_detailed_cash_register/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions pos_detailed_cash_register/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2023 Akretion (http://www.akretion.com).
# @author Florian Mounier <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "PoS Detailed Cash Register",
"summary": "Add more details about cash register operations in PoS session",
"version": "14.0.1.0.0",
"license": "AGPL-3",
"author": "Akretion,Odoo Community Association (OCA)",
"category": "Point of Sale",
"website": "https://github.com/OCA/pos",
"depends": [
"point_of_sale",
],
"data": [
"views/pos_session_view.xml",
],
}
96 changes: 96 additions & 0 deletions pos_detailed_cash_register/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_detailed_cash_register
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-11-23 08:33+0000\n"
"PO-Revision-Date: 2023-11-23 08:33+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_detailed_cash_register
#: model_terms:ir.ui.view,arch_db:pos_detailed_cash_register.view_pos_session_form
msgid "+ Cash In"
msgstr "+ Cash entrant"

#. module: pos_detailed_cash_register
#: model_terms:ir.ui.view,arch_db:pos_detailed_cash_register.view_pos_session_form
msgid "+ Transactions"
msgstr "+ Transactions"

#. module: pos_detailed_cash_register
#: model_terms:ir.ui.view,arch_db:pos_detailed_cash_register.view_pos_session_form
msgid "- Cash Out"
msgstr "- Cash sortant"

#. module: pos_detailed_cash_register
#: model:ir.model.fields,field_description:pos_detailed_cash_register.field_pos_session__cash_real_total_in
msgid "Cash In"
msgstr "Cash entrant"

#. module: pos_detailed_cash_register
#: model_terms:ir.ui.view,arch_db:pos_detailed_cash_register.view_pos_session_form
msgid "Cash In/Out"
msgstr "Cash entrant/sortant"

#. module: pos_detailed_cash_register
#: model:ir.model.fields,field_description:pos_detailed_cash_register.field_pos_session__cash_real_total_out
msgid "Cash Out"
msgstr "Cash sortant"

#. module: pos_detailed_cash_register
#: model:ir.model.fields,field_description:pos_detailed_cash_register.field_pos_session__cash_register_statement_line_ids
msgid "Cash Register Statement Lines"
msgstr "Lignes de relevé de caisse"

#. module: pos_detailed_cash_register
#: model:ir.model.fields,field_description:pos_detailed_cash_register.field_pos_session__display_name
msgid "Display Name"
msgstr "Nom affiché"

#. module: pos_detailed_cash_register
#: model:ir.model.fields,field_description:pos_detailed_cash_register.field_pos_session__id
msgid "ID"
msgstr ""

#. module: pos_detailed_cash_register
#: model:ir.model.fields,field_description:pos_detailed_cash_register.field_pos_session____last_update
msgid "Last Modified on"
msgstr "Dernière modification le"

#. module: pos_detailed_cash_register
#: model:ir.model,name:pos_detailed_cash_register.model_pos_session
msgid "Point of Sale Session"
msgstr "Session du point de vente"

#. module: pos_detailed_cash_register
#: model_terms:ir.ui.view,arch_db:pos_detailed_cash_register.view_pos_session_form
msgid "Statements"
msgstr "Relevés"

#. module: pos_detailed_cash_register
#: model:ir.model.fields,field_description:pos_detailed_cash_register.field_pos_session__cash_register_total_in
msgid "Total Cash In"
msgstr "Total cash entrant"

#. module: pos_detailed_cash_register
#: model:ir.model.fields,field_description:pos_detailed_cash_register.field_pos_session__cash_register_total_out
msgid "Total Cash Out"
msgstr "Total cash sortant"

#. module: pos_detailed_cash_register
#: model:ir.model.fields,field_description:pos_detailed_cash_register.field_pos_session__total_cash_payments
msgid "Total Payments"
msgstr "Total des paiements"

#. module: pos_detailed_cash_register
#: model:ir.model.fields,field_description:pos_detailed_cash_register.field_pos_session__total_real_cash_payments
msgid "Total Real Payments"
msgstr "Total des paiements réels"
1 change: 1 addition & 0 deletions pos_detailed_cash_register/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import pos_session
155 changes: 155 additions & 0 deletions pos_detailed_cash_register/models/pos_session.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# Copyright 2023 Akretion (http://www.akretion.com).
# @author Florian Mounier <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class PosSession(models.Model):
_inherit = "pos.session"

cash_register_statement_line_ids = fields.One2many(
"account.bank.statement.line",
compute="_compute_cash_register_statement_line_ids",
string="Cash Register Statement Lines",
)

cash_register_total_in = fields.Monetary(
compute="_compute_cash_register_totals",
string="Total Cash In",
)
cash_register_total_out = fields.Monetary(
compute="_compute_cash_register_totals",
string="Total Cash Out",
)
cash_real_total_in = fields.Monetary(
string="Cash In",
readonly=True,
)
cash_real_total_out = fields.Monetary(
string="Cash Out",
readonly=True,
)

total_cash_payments = fields.Monetary(
compute="_compute_total_cash_payment",
string="Total Payments",
)

total_real_cash_payments = fields.Monetary(
compute="_compute_total_real_cash_payment",
string="Total Real Payments",
)

# We can't use cashbox_start since it's unused in pos, so we get last session end
previous_session_cash_box_end_id = fields.Many2one(
"account.bank.statement.cashbox",
compute="_compute_previous_session_cash_box_end_id",
string="Previous Session Cash Box End",
)
previous_session_cash_box_end_line_ids = fields.One2many(
related="previous_session_cash_box_end_id.cashbox_lines_ids",
string="Previous Session Cash Box End Lines",
)

cash_box_end_id = fields.Many2one(
related="cash_register_id.cashbox_end_id",
string="Cash Box End",
)
cash_box_end_line_ids = fields.One2many(
related="cash_box_end_id.cashbox_lines_ids",
string="Cash Box End Lines",
)

def _get_cash_register_counterpart_account(self):
# The cash in/out lines are in the move lines of the cash register
# attached to the suspense account

return self.cash_register_id.journal_id.suspense_account_id

Check warning on line 68 in pos_detailed_cash_register/models/pos_session.py

View check run for this annotation

Codecov / codecov/patch

pos_detailed_cash_register/models/pos_session.py#L68

Added line #L68 was not covered by tests

@api.depends("config_id")
def _compute_previous_session_cash_box_end_id(self):
for record in self:
previous_session = self.search(

Check warning on line 73 in pos_detailed_cash_register/models/pos_session.py

View check run for this annotation

Codecov / codecov/patch

pos_detailed_cash_register/models/pos_session.py#L73

Added line #L73 was not covered by tests
[
("config_id", "=", record.config_id.id),
("state", "=", "closed"),
("rescue", "=", False),
("id", "<", record.id),
],
order="id desc",
limit=1,
)
record.previous_session_cash_box_end_id = previous_session.cash_box_end_id

Check warning on line 83 in pos_detailed_cash_register/models/pos_session.py

View check run for this annotation

Codecov / codecov/patch

pos_detailed_cash_register/models/pos_session.py#L83

Added line #L83 was not covered by tests

@api.depends("cash_register_id.line_ids")
def _compute_cash_register_statement_line_ids(self):
for session in self:
# Here we can't list all cash_register_id.line_ids because if the
# session is closed we also have the closure lines.
# We need to filter these out using the account.account
cash_register_account_id = session._get_cash_register_counterpart_account()

Check warning on line 91 in pos_detailed_cash_register/models/pos_session.py

View check run for this annotation

Codecov / codecov/patch

pos_detailed_cash_register/models/pos_session.py#L91

Added line #L91 was not covered by tests

session.cash_register_statement_line_ids = (
session.cash_register_id.line_ids.filtered(
lambda line: line.move_id.line_ids.filtered(
lambda line: line.account_id == cash_register_account_id
)
)
)

@api.depends("cash_register_id.line_ids")
def _compute_cash_register_totals(self):
for session in self:
# When the cash register is opened, the cash in/out lines are the
# cash register lines.
session.cash_register_total_in = sum(
[
line.amount
for line in session.cash_register_id.line_ids
if line.amount > 0
]
)
session.cash_register_total_out = sum(
[
line.amount
for line in session.cash_register_id.line_ids
if line.amount < 0
]
)

@api.depends(
"cash_register_total_entry_encoding",
"cash_register_total_in",
"cash_register_total_out",
)
def _compute_total_cash_payment(self):
for session in self:
# The current transactions without cash in/out lines
session.total_cash_payments = (

Check warning on line 129 in pos_detailed_cash_register/models/pos_session.py

View check run for this annotation

Codecov / codecov/patch

pos_detailed_cash_register/models/pos_session.py#L129

Added line #L129 was not covered by tests
session.cash_register_total_entry_encoding
- session.cash_register_total_in
- session.cash_register_total_out
)

@api.depends(
"cash_real_transaction",
"cash_real_total_in",
"cash_real_total_out",
)
def _compute_total_real_cash_payment(self):
for session in self:
# The real transactions without cash in/out lines
session.total_real_cash_payments = (

Check warning on line 143 in pos_detailed_cash_register/models/pos_session.py

View check run for this annotation

Codecov / codecov/patch

pos_detailed_cash_register/models/pos_session.py#L143

Added line #L143 was not covered by tests
session.cash_real_transaction
- session.cash_real_total_in
- session.cash_real_total_out
)

def _validate_session(self):
# We store the cash in/out totals at the session closure to keep the
# real amounts. (Like cash_real_transaction)
self.cash_real_total_in = self.cash_register_total_in
self.cash_real_total_out = self.cash_register_total_out
res = super()._validate_session()
return res
3 changes: 3 additions & 0 deletions pos_detailed_cash_register/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Akretion <https://www.akretion.com>`_:

* Florian Mounier
5 changes: 5 additions & 0 deletions pos_detailed_cash_register/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This module splits the "+ Transactions" lines in the cash control view of a PoS
session into the current transaction and the Cash In/Out lines.

It also adds a new tab in the PoS session listing the cash in/out operations
with their reasons.
1 change: 1 addition & 0 deletions pos_detailed_cash_register/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The cash control must be enabled for the PoS session.
Loading
Loading