Skip to content

Commit f282242

Browse files
authored
Merge pull request #544 from ecosoft-odoo/15.0-fix-budget_control_request_document_expense-check_budget_precommit
[15.0][FIX] budget_control_request_document_expense: uncommit RQ before submit EX
2 parents bce8812 + 5232ffc commit f282242

3 files changed

Lines changed: 26 additions & 0 deletions

File tree

budget_control_request_document_expense/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
from . import request_document
55
from . import request_order
66
from . import hr_expense
7+
from . import budget_period
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright 2026 Ecosoft Co., Ltd. (http://ecosoft.co.th)
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
from odoo import api, models
5+
6+
7+
class BudgetPeriod(models.Model):
8+
_inherit = "budget.period"
9+
10+
@api.model
11+
def check_budget_precommit(self, doclines, doc_type="account"):
12+
budget_moves = False
13+
if doclines._name == "hr.expense":
14+
request_documents = doclines.mapped("sheet_id.request_document_id")
15+
if request_documents:
16+
budget_moves = request_documents.budget_move_ids
17+
request_documents.with_context(
18+
force_commit=True, check_budget_precommit=True
19+
).uncommit_request_budget(doclines)
20+
budget_moves = request_documents.budget_move_ids - budget_moves
21+
res = super().check_budget_precommit(doclines, doc_type=doc_type)
22+
if budget_moves:
23+
budget_moves.unlink()
24+
return res

budget_control_request_document_expense/models/request_document.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def uncommit_request_budget(self, request_line):
2020
request_line._name == "hr.expense"
2121
and budget_move
2222
and request_line[request_line._doc_rel].state in ["approve", "post", "done"]
23+
or self.env.context("check_budget_precommit", False)
2324
):
2425
self.close_budget_move()
2526
return res

0 commit comments

Comments
 (0)