Skip to content
Merged
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
1 change: 1 addition & 0 deletions budget_control_request_document_expense/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
from . import request_document
from . import request_order
from . import hr_expense
from . import budget_period
24 changes: 24 additions & 0 deletions budget_control_request_document_expense/models/budget_period.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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, models


class BudgetPeriod(models.Model):
_inherit = "budget.period"

@api.model
def check_budget_precommit(self, doclines, doc_type="account"):
budget_moves = False
if doclines._name == "hr.expense":
request_documents = doclines.mapped("sheet_id.request_document_id")
if request_documents:
budget_moves = request_documents.budget_move_ids
request_documents.with_context(
force_commit=True, check_budget_precommit=True
).uncommit_request_budget(doclines)
budget_moves = request_documents.budget_move_ids - budget_moves
res = super().check_budget_precommit(doclines, doc_type=doc_type)
if budget_moves:
budget_moves.unlink()
return res
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def uncommit_request_budget(self, request_line):
request_line._name == "hr.expense"
and budget_move
and request_line[request_line._doc_rel].state in ["approve", "post", "done"]
or self.env.context("check_budget_precommit", False)
):
self.close_budget_move()
return res