Skip to content
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
26 changes: 19 additions & 7 deletions hr_expense_advance_clearing/README.rst
Original file line number Diff line number Diff line change
@@ -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

=============================
Employee Advance and Clearing
=============================
Expand All @@ -17,7 +13,7 @@ Employee Advance and Clearing
.. |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
Expand Down Expand Up @@ -71,6 +67,19 @@ Note:
- Employee Advance account code, if not already exists, you can create
one. Use type = Current Asset and check Allow Reconciliation.

**Clearing Journal**

Clearing entries are posted as journal entries (move_type 'entry'),
which only allow Miscellaneous (general) journals. By default Odoo picks
the first general journal it finds. To control it:

1. Go to Settings > Expenses > Accounting.
2. Set the "Default Clearing Journal" to the Miscellaneous journal that
should receive the clearing entries.

The clearing journal can also be set per clearing report on the report's
"Clearing Journal" field, which defaults to the company setting above.

Usage
=====

Expand Down Expand Up @@ -175,10 +184,13 @@ promote its widespread use.
.. |maintainer-kittiu| image:: https://github.com/kittiu.png?size=40px
:target: https://github.com/kittiu
:alt: kittiu
.. |maintainer-Saran440| image:: https://github.com/Saran440.png?size=40px
:target: https://github.com/Saran440
:alt: Saran440

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-kittiu|
|maintainer-kittiu| |maintainer-Saran440|

This module is part of the `OCA/hr-expense <https://github.com/OCA/hr-expense/tree/18.0/hr_expense_advance_clearing>`_ project on GitHub.

Expand Down
3 changes: 2 additions & 1 deletion hr_expense_advance_clearing/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
"depends": ["hr_expense"],
"data": [
"data/advance_product.xml",
"views/res_config_settings_views.xml",
"views/account_payment_view.xml",
"views/hr_expense_views.xml",
"views/hr_employee_views.xml",
"views/hr_employee_public_views.xml",
],
"installable": True,
"maintainers": ["kittiu"],
"maintainers": ["kittiu", "Saran440"],
}
2 changes: 2 additions & 0 deletions hr_expense_advance_clearing/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
from . import hr_employee_base
from . import account_move
from . import account_payment
from . import res_company
from . import res_config_settings
16 changes: 16 additions & 0 deletions hr_expense_advance_clearing/models/hr_expense_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,21 @@ class HrExpenseSheet(models.Model):
compute="_compute_amount_payable",
help="Final regiter payment amount even after advance clearing",
)
clearing_journal_id = fields.Many2one(
comodel_name="account.journal",
string="Clearing Journal",
check_company=True,
domain="[('type', '=', 'general')]",
compute="_compute_clearing_journal_id",
store=True,
readonly=False,
help="Miscellaneous journal used to post the clearing journal entry.",
)

@api.depends("company_id", "advance_sheet_id")
def _compute_clearing_journal_id(self):
for sheet in self:
sheet.clearing_journal_id = sheet.company_id.clearing_journal_id

@api.constrains("advance_sheet_id", "expense_line_ids")
def _check_advance_expense(self):
Expand Down Expand Up @@ -250,6 +265,7 @@ def _prepare_bills_vals(self):
res.update(
{
"move_type": "entry",
"journal_id": self.clearing_journal_id.id,
"line_ids": [
Command.create(vals) for vals in self._get_move_line_vals()
],
Expand Down
17 changes: 17 additions & 0 deletions hr_expense_advance_clearing/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2026 Ecosoft Co., Ltd. (https://ecosoft.co.th)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class ResCompany(models.Model):
_inherit = "res.company"

clearing_journal_id = fields.Many2one(
comodel_name="account.journal",
string="Default Clearing Journal",
check_company=True,
domain="[('type', '=', 'general')]",
help="Default Miscellaneous journal used when posting the advance "
"clearing journal entry.",
)
16 changes: 16 additions & 0 deletions hr_expense_advance_clearing/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2026 Ecosoft Co., Ltd. (https://ecosoft.co.th)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

clearing_journal_id = fields.Many2one(
comodel_name="account.journal",
related="company_id.clearing_journal_id",
check_company=True,
domain="[('type', '=', 'general')]",
readonly=False,
)
14 changes: 14 additions & 0 deletions hr_expense_advance_clearing/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,17 @@ Note:
data
- Employee Advance account code, if not already exists, you can create
one. Use type = Current Asset and check Allow Reconciliation.

**Clearing Journal**

Clearing entries are posted as journal entries (move_type 'entry'), which
only allow Miscellaneous (general) journals. By default Odoo picks the
first general journal it finds. To control it:

1. Go to Settings \> Expenses \> Accounting.
2. Set the "Default Clearing Journal" to the Miscellaneous journal that
should receive the clearing entries.

The clearing journal can also be set per clearing report on the report's
"Clearing Journal" field, which defaults to the company setting above.

43 changes: 24 additions & 19 deletions hr_expense_advance_clearing/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>README.rst</title>
<title>Employee Advance and Clearing</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,21 +360,16 @@
</style>
</head>
<body>
<div class="document">
<div class="document" id="employee-advance-and-clearing">
<h1 class="title">Employee Advance and Clearing</h1>


<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="employee-advance-and-clearing">
<h1>Employee Advance and Clearing</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:e6c94f0c09e4b3cc30524e96c918c0590122f37ec4a7757001fd189a1b9406f3
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/hr-expense/tree/18.0/hr_expense_advance_clearing"><img alt="OCA/hr-expense" src="https://img.shields.io/badge/github-OCA%2Fhr--expense-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/hr-expense-18-0/hr-expense-18-0-hr_expense_advance_clearing"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/hr-expense&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/hr-expense/tree/18.0/hr_expense_advance_clearing"><img alt="OCA/hr-expense" src="https://img.shields.io/badge/github-OCA%2Fhr--expense-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/hr-expense-18-0/hr-expense-18-0-hr_expense_advance_clearing"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/hr-expense&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Standard Expenses module allow employee to do the expense reimbursement
only after the expense has been made. In other world, employee will need
to pay first and reimburse later.</p>
Expand Down Expand Up @@ -404,7 +399,7 @@ <h1>Employee Advance and Clearing</h1>
</ul>
</div>
<div class="section" id="configuration">
<h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<p>This module will create a new product “Employee Advance” automatically.
You will need to setup the Expense Account of this product to your
Employee Advance account manually.</p>
Expand All @@ -420,9 +415,20 @@ <h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
<li>Employee Advance account code, if not already exists, you can create
one. Use type = Current Asset and check Allow Reconciliation.</li>
</ul>
<p><strong>Clearing Journal</strong></p>
<p>Clearing entries are posted as journal entries (move_type ‘entry’),
which only allow Miscellaneous (general) journals. By default Odoo picks
the first general journal it finds. To control it:</p>
<ol class="arabic simple">
<li>Go to Settings &gt; Expenses &gt; Accounting.</li>
<li>Set the “Default Clearing Journal” to the Miscellaneous journal that
should receive the clearing entries.</li>
</ol>
<p>The clearing journal can also be set per clearing report on the report’s
“Clearing Journal” field, which defaults to the company setting above.</p>
</div>
<div class="section" id="usage">
<h2><a class="toc-backref" href="#toc-entry-2">Usage</a></h2>
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
<p>To use this module, you must configure product “Employee Advance” with
account type = Current Asset and check Allow Reconciliation. After that,
you can step following:</p>
Expand Down Expand Up @@ -484,45 +490,44 @@ <h2><a class="toc-backref" href="#toc-entry-2">Usage</a></h2>
</ol>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h2>
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/hr-expense/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/hr-expense/issues/new?body=module:%20hr_expense_advance_clearing%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h2><a class="toc-backref" href="#toc-entry-4">Credits</a></h2>
<h1><a class="toc-backref" href="#toc-entry-4">Credits</a></h1>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#toc-entry-5">Authors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
<ul class="simple">
<li>Ecosoft</li>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#toc-entry-6">Contributors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<ul class="simple">
<li>Kitti Upariphutthiphong &lt;<a class="reference external" href="mailto:kittiu&#64;ecosoft.co.th">kittiu&#64;ecosoft.co.th</a>&gt;</li>
<li>Tharathip Chaweewongphan &lt;<a class="reference external" href="mailto:tharathipc&#64;ecosoft.co.th">tharathipc&#64;ecosoft.co.th</a>&gt;</li>
<li>Saran Lim. &lt;<a class="reference external" href="mailto:saranl&#64;ecosoft.co.th">saranl&#64;ecosoft.co.th</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>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.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/kittiu"><img alt="kittiu" src="https://github.com/kittiu.png?size=40px" /></a></p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/kittiu"><img alt="kittiu" src="https://github.com/kittiu.png?size=40px" /></a> <a class="reference external image-reference" href="https://github.com/Saran440"><img alt="Saran440" src="https://github.com/Saran440.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/hr-expense/tree/18.0/hr_expense_advance_clearing">OCA/hr-expense</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
</div>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ def setUpClass(cls):
cls.emp_advance = cls.env.ref("hr_expense_advance_clearing.product_emp_advance")
cls.emp_advance.property_account_expense_id = advance_account
cls.product_a.standard_price = 0
# Create journal clearing
cls.other_misc = cls.env["account.journal"].create(
{
"name": "Clearing Other",
"code": "CLRO",
"type": "general",
"company_id": cls.company_data["company"].id,
}
)
# Configure a clearing journal on the company.
cls.company_data["company"].clearing_journal_id = cls.other_misc
# Create advance expense 1,000
cls.advance = cls._create_expense_sheet(
cls,
Expand Down Expand Up @@ -187,6 +198,10 @@ def test_1_clear_equal_advance(self):
self.clearing_equal.action_sheet_move_post()
# Equal amount, state change to Paid and advance is cleared
self.assertEqual(self.clearing_equal.state, "done")
# Fallback: no company clearing journal configured, move uses a general journal
clearing_move = self.clearing_equal.account_move_ids
self.assertEqual(clearing_move.move_type, "entry")
self.assertEqual(clearing_move.journal_id.type, "general")
self.assertEqual(self.clearing_equal.advance_sheet_residual, 0.0)
# Clear this with previous advance is done
self.clearing_more.advance_sheet_id = self.advance
Expand Down Expand Up @@ -229,12 +244,17 @@ def test_2_clear_more_than_advance(self):
# Clear this with previous advance
self.clearing_more.advance_sheet_id = self.advance
self.assertEqual(self.clearing_more.advance_sheet_residual, 1000.0)
self.clearing_more.clearing_journal_id = self.other_misc
self.clearing_more.action_submit_sheet()
self.clearing_more.action_approve_expense_sheets()
self.clearing_more.action_sheet_move_post()
# More amount, state not changed to paid, and has to pay 200 more
self.assertEqual(self.clearing_more.state, "post")
self.assertEqual(self.clearing_more.amount_payable, 200.0)
# Verify clearing move used the overridden journal
clearing_move = self.clearing_more.account_move_ids
self.assertEqual(clearing_move.journal_id, self.other_misc)
self.assertEqual(clearing_move.move_type, "entry")
self._register_payment(self.clearing_more.account_move_ids, 200.0)
self.assertEqual(self.clearing_more.state, "done")

Expand Down
7 changes: 7 additions & 0 deletions hr_expense_advance_clearing/views/hr_expense_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,13 @@
name="advance_sheet_residual"
invisible="not advance_sheet_id"
/>
<field
name="clearing_journal_id"
groups="account.group_account_invoice,account.group_account_readonly"
invisible="not advance_sheet_id"
required="advance_sheet_id"
readonly="state not in ['draft', 'submit', 'approve']"
/>
</group>
</xpath>
<xpath expr="//field[@name='expense_line_ids']" position="attributes">
Expand Down
20 changes: 20 additions & 0 deletions hr_expense_advance_clearing/views/res_config_settings_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field
name="name"
>res.config.settings.view.form.inherit.hr.expense.advance.clearing</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="hr_expense.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//app[@name='hr_expense']/block[last()]" position="inside">
<setting
company_dependent="1"
help="Default Miscellaneous journal used to post the advance clearing journal entry."
>
<field name="clearing_journal_id" />
</setting>
</xpath>
</field>
</record>
</odoo>
Loading