Skip to content

Commit

Permalink
[IMP] pos_detailed_cash_register: Add detailed cash box
Browse files Browse the repository at this point in the history
  • Loading branch information
paradoxxxzero committed Jan 20, 2025
1 parent d100365 commit aa243d3
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 6 deletions.
50 changes: 47 additions & 3 deletions pos_detailed_cash_register/models/pos_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,58 @@ class PosSession(models.Model):
string="Total Real Payments",
)

# Seems unused in 14.0 but we keep it just in case
cash_box_start_id = fields.Many2one(
related="cash_register_id.cashbox_start_id",
string="Cash Box Start",
)

cash_box_start_line_ids = fields.One2many(
related="cash_box_start_id.cashbox_lines_ids",
string="Cash Box Start Lines",
)

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

# FIXME: Is it always the case?
self.ensure_one()
return self.cash_register_id.journal_id.suspense_account_id

Check warning on line 79 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#L79

Added line #L79 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 84 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#L84

Added line #L84 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 94 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#L94

Added line #L94 was not covered by tests

@api.depends("cash_register_id.line_ids")
def _compute_cash_register_statement_line_ids(self):
for session in self:
Expand Down Expand Up @@ -118,5 +162,5 @@ def _validate_session(self):
# 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(PosSession, self)._validate_session()
res = super()._validate_session()
return res
28 changes: 25 additions & 3 deletions pos_detailed_cash_register/views/pos_session_view.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2023 Akretion (http://www.akretion.com).
@author Florian Mounier <florian.mounier@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
Copyright 2023 Akretion (http://www.akretion.com).
@author Florian Mounier <florian.mounier@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="view_pos_session_form" model="ir.ui.view">
Expand Down Expand Up @@ -84,6 +84,28 @@


<page name="cash_control" position="after">
<page string="Cash Box " name="cash_box">
<group>
<group
attrs="{'invisible' : [('previous_session_cash_box_end_id', '=', False)]}"
>
<field name="previous_session_cash_box_end_id" invisible="1" />
<field
name="previous_session_cash_box_end_line_ids"
string="Previous Cash Box"
/>
</group>
<group attrs="{'invisible' : [('cash_box_start_id', '=', False)]}">
<field name="cash_box_start_id" invisible="1" />
<field name="cash_box_start_line_ids" string="Opening Cash Box" />
</group>
<group attrs="{'invisible' : [('cash_box_end_id', '=', False)]}">
<field name="cash_box_end_id" invisible="1" />
<field name="cash_box_end_line_ids" string="Closing Cash Box" />
</group>
</group>
</page>

<page
string="Cash In/Out"
name="cash_details"
Expand Down

0 comments on commit aa243d3

Please sign in to comment.