Maintainers
+Maintainers
This module is maintained by the OCA.
@@ -493,6 +488,5 @@ diff --git a/hr_expense_petty_cash/README.rst b/hr_expense_petty_cash/README.rst
index 76c23219c..3b4687222 100644
--- a/hr_expense_petty_cash/README.rst
+++ b/hr_expense_petty_cash/README.rst
@@ -1,7 +1,3 @@
-.. image:: https://odoo-community.org/readme-banner-image
- :target: https://odoo-community.org/get-involved?utm_source=readme
- :alt: Odoo Community Association
-
==========
Petty Cash
==========
@@ -17,7 +13,7 @@ Petty Cash
.. |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/license-AGPL--3-blue.png
+.. |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%2Fhr--expense-lightgray.png?logo=github
diff --git a/hr_expense_petty_cash/__manifest__.py b/hr_expense_petty_cash/__manifest__.py
index 6b55b428e..e5c10c77c 100644
--- a/hr_expense_petty_cash/__manifest__.py
+++ b/hr_expense_petty_cash/__manifest__.py
@@ -16,6 +16,7 @@
"views/hr_expense_sheet_views.xml",
"views/hr_expense_views.xml",
"views/petty_cash_views.xml",
+ "views/petty_cash_transaction_views.xml",
],
"installable": True,
}
diff --git a/hr_expense_petty_cash/models/__init__.py b/hr_expense_petty_cash/models/__init__.py
index e60741242..6d5b181f7 100644
--- a/hr_expense_petty_cash/models/__init__.py
+++ b/hr_expense_petty_cash/models/__init__.py
@@ -5,3 +5,4 @@
from . import hr_expense
from . import hr_expense_sheet
from . import petty_cash
+from . import petty_cash_transaction
diff --git a/hr_expense_petty_cash/models/petty_cash.py b/hr_expense_petty_cash/models/petty_cash.py
index 8adcae0b0..0d68e5c31 100644
--- a/hr_expense_petty_cash/models/petty_cash.py
+++ b/hr_expense_petty_cash/models/petty_cash.py
@@ -31,6 +31,10 @@ class PettyCash(models.Model):
string="Balance",
compute="_compute_petty_cash_balance",
)
+ transaction_count = fields.Integer(
+ string="Transactions",
+ compute="_compute_transaction_count",
+ )
journal_id = fields.Many2one(
comodel_name="account.journal",
check_company=True,
@@ -62,3 +66,19 @@ def _compute_petty_cash_balance(self):
)
balance = sum(line.debit - line.credit for line in aml)
rec.petty_cash_balance = balance
+
+ def _compute_transaction_count(self):
+ transaction_env = self.env["petty.cash.transaction"]
+ for rec in self:
+ rec.transaction_count = transaction_env.search_count(
+ [("petty_cash_id", "=", rec.id)]
+ )
+
+ def action_open_transactions(self):
+ self.ensure_one()
+ action = self.env["ir.actions.act_window"]._for_xml_id(
+ "hr_expense_petty_cash.action_petty_cash_transaction"
+ )
+ action["domain"] = [("petty_cash_id", "=", self.id)]
+ action["context"] = {"default_petty_cash_id": self.id}
+ return action
diff --git a/hr_expense_petty_cash/models/petty_cash_transaction.py b/hr_expense_petty_cash/models/petty_cash_transaction.py
new file mode 100644
index 000000000..cb2bd6de7
--- /dev/null
+++ b/hr_expense_petty_cash/models/petty_cash_transaction.py
@@ -0,0 +1,109 @@
+# Copyright 2026 Ecosoft Co., Ltd. (http://ecosoft.co.th)
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+from odoo import api, fields, models
+from odoo.tools.sql import SQL
+
+
+class PettyCashTransaction(models.Model):
+ _name = "petty.cash.transaction"
+ _description = "Petty Cash Transaction"
+ _auto = False
+ _order = "id desc"
+
+ _depends = {
+ "account.move.line": [
+ "date",
+ "debit",
+ "credit",
+ "partner_id",
+ "account_id",
+ "move_id",
+ "company_id",
+ "parent_state",
+ "expense_id",
+ ],
+ "account.move": ["name", "is_petty_cash", "expense_sheet_id"],
+ "petty.cash": ["partner_id", "account_id", "company_id"],
+ }
+
+ date = fields.Date()
+ name = fields.Char()
+ petty_cash_id = fields.Many2one(
+ comodel_name="petty.cash",
+ string="Petty Cash Holder",
+ )
+ move_id = fields.Many2one(
+ comodel_name="account.move",
+ string="Document",
+ )
+ sheet_id = fields.Many2one(
+ comodel_name="hr.expense.sheet",
+ string="Expense Report",
+ )
+ expense_id = fields.Many2one(
+ comodel_name="hr.expense",
+ )
+ partner_id = fields.Many2one(comodel_name="res.partner")
+ account_id = fields.Many2one(comodel_name="account.account")
+ source = fields.Selection(
+ selection=[
+ ("refill", "Refill"),
+ ("expense", "Expense"),
+ ],
+ )
+ debit = fields.Float()
+ credit = fields.Float()
+ amount = fields.Float()
+ balance = fields.Float()
+ company_id = fields.Many2one(comodel_name="res.company")
+
+ @property
+ def _table_query(self) -> SQL:
+ return SQL("%s %s %s", self._select(), self._from(), self._where())
+
+ @api.model
+ def _select(self) -> SQL:
+ return SQL(
+ """
+ SELECT
+ aml.id AS id,
+ aml.date AS date,
+ am.name AS name,
+ pc.id AS petty_cash_id,
+ aml.move_id AS move_id,
+ am.expense_sheet_id AS sheet_id,
+ aml.expense_id AS expense_id,
+ aml.partner_id AS partner_id,
+ aml.account_id AS account_id,
+ CASE
+ WHEN am.is_petty_cash THEN 'refill'
+ WHEN am.expense_sheet_id IS NOT NULL THEN 'expense'
+ END AS source,
+ aml.debit AS debit,
+ aml.credit AS credit,
+ (aml.debit - aml.credit) AS amount,
+ SUM(aml.debit - aml.credit) OVER (
+ PARTITION BY pc.id
+ ORDER BY aml.date, aml.id
+ ) AS balance,
+ aml.company_id AS company_id
+ """
+ )
+
+ @api.model
+ def _from(self) -> SQL:
+ return SQL(
+ """
+ FROM account_move_line aml
+ JOIN account_move am ON am.id = aml.move_id
+ JOIN petty_cash pc
+ ON pc.partner_id = aml.partner_id
+ AND pc.account_id = aml.account_id
+ AND pc.company_id = aml.company_id
+ """
+ )
+
+ @api.model
+ def _where(self) -> SQL:
+ return SQL("WHERE aml.parent_state = 'posted'")
diff --git a/hr_expense_petty_cash/security/ir.model.access.csv b/hr_expense_petty_cash/security/ir.model.access.csv
index 149f12a4e..8299b460f 100644
--- a/hr_expense_petty_cash/security/ir.model.access.csv
+++ b/hr_expense_petty_cash/security/ir.model.access.csv
@@ -1,3 +1,4 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_hr_expense_petty_cash,access_hr_expense_petty_cash,model_petty_cash,account.group_account_user,1,1,1,1
access_hr_expense_petty_cash_user,access_hr_expense_petty_cash_user,model_petty_cash,base.group_user,1,0,0,0
+access_petty_cash_transaction,access_petty_cash_transaction,model_petty_cash_transaction,account.group_account_user,1,0,0,0
diff --git a/hr_expense_petty_cash/security/petty_cash_security.xml b/hr_expense_petty_cash/security/petty_cash_security.xml
index 94ca0b39c..4bc69dd59 100644
--- a/hr_expense_petty_cash/security/petty_cash_security.xml
+++ b/hr_expense_petty_cash/security/petty_cash_security.xml
@@ -7,4 +7,12 @@
['|',('company_id','=',False),('company_id','in',company_ids)]
+
This module work about expense that paid by petty cash.
General Process:
Create a Petty Cash Account
Create a Petty Cash Holder
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 @@ -454,15 +449,15 @@
Do not contact contributors directly about support or help with technical issues.