Skip to content

Commit 84a7e5f

Browse files
committed
Merge PR #515 into 18.0
Signed-off-by Saran440
2 parents e2eed26 + 9878ada commit 84a7e5f

File tree

15 files changed

+769
-0
lines changed

15 files changed

+769
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
==========================================
2+
Budget Control on Request Document Expense
3+
==========================================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:8ff32204bd1cf62b80ea7570e53922fdc098c7a4d8a1d9ffba15f10ada807b6f
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Alpha
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-ecosoft--odoo%2Fbudgeting-lightgray.png?logo=github
20+
:target: https://github.com/ecosoft-odoo/budgeting/tree/18.0/budget_control_request_document_expense
21+
:alt: ecosoft-odoo/budgeting
22+
23+
|badge1| |badge2| |badge3|
24+
25+
This module support commitment on request document expense
26+
27+
.. IMPORTANT::
28+
This is an alpha version, the data model and design can change at any time without warning.
29+
Only for development or testing purpose, do not use in production.
30+
`More details on development status <https://odoo-community.org/page/development-status>`_
31+
32+
**Table of contents**
33+
34+
.. contents::
35+
:local:
36+
37+
Bug Tracker
38+
===========
39+
40+
Bugs are tracked on `GitHub Issues <https://github.com/ecosoft-odoo/budgeting/issues>`_.
41+
In case of trouble, please check there if your issue has already been reported.
42+
If you spotted it first, help us to smash it by providing a detailed and welcomed
43+
`feedback <https://github.com/ecosoft-odoo/budgeting/issues/new?body=module:%20budget_control_request_document_expense%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
44+
45+
Do not contact contributors directly about support or help with technical issues.
46+
47+
Credits
48+
=======
49+
50+
Authors
51+
-------
52+
53+
* Ecosoft
54+
55+
Contributors
56+
------------
57+
58+
- Kitti Upariphutthiphong <[email protected]>
59+
- Saran Lim. <[email protected]>
60+
61+
Maintainers
62+
-----------
63+
64+
.. |maintainer-Saran440| image:: https://github.com/Saran440.png?size=40px
65+
:target: https://github.com/Saran440
66+
:alt: Saran440
67+
68+
Current maintainer:
69+
70+
|maintainer-Saran440|
71+
72+
This module is part of the `ecosoft-odoo/budgeting <https://github.com/ecosoft-odoo/budgeting/tree/18.0/budget_control_request_document_expense>`_ project on GitHub.
73+
74+
You are welcome to contribute.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
2+
3+
from . import models
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2021 Ecosoft Co., Ltd. (http://ecosoft.co.th)
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
{
5+
"name": "Budget Control on Request Document Expense",
6+
"version": "18.0.1.0.0",
7+
"license": "AGPL-3",
8+
"author": "Ecosoft, Odoo Community Association (OCA)",
9+
"website": "https://github.com/ecosoft-odoo/budgeting",
10+
"depends": [
11+
"budget_control_request_document",
12+
"budget_control_expense",
13+
"request_document_expense",
14+
],
15+
"data": [],
16+
"installable": True,
17+
"auto_install": True,
18+
"maintainers": ["Saran440"],
19+
"development_status": "Alpha",
20+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
2+
3+
from . import base_budget_move
4+
from . import request_document
5+
from . import hr_expense
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2022 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 models
5+
6+
7+
class BudgetDoclineMixin(models.AbstractModel):
8+
_inherit = "budget.docline.mixin"
9+
10+
def _init_docline_budget_vals(self, budget_vals, analytic_id):
11+
"""Use standard budget move but we need commit in request"""
12+
budget_vals = super()._init_docline_budget_vals(budget_vals, analytic_id)
13+
if (
14+
self.env.context.get("alt_budget_move_model") == "request.budget.move"
15+
and self._name == "hr.expense"
16+
):
17+
budget_vals.pop("expense_id") # Delete expense reference
18+
budget_vals["request_document_id"] = self[
19+
self._doc_rel
20+
].request_document_id.id
21+
return budget_vals
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2020 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 models
5+
6+
7+
class HRExpenseSheet(models.Model):
8+
_inherit = "hr.expense.sheet"
9+
10+
def write(self, vals):
11+
"""Uncommit budget for source request document."""
12+
res = super().write(vals)
13+
if vals.get("approval_state") in ("approve", "cancel", False):
14+
self.mapped("request_document_id").recompute_budget_move()
15+
return res
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright 2024 Ecosoft Co., Ltd. (http://ecosoft.co.th)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
3+
4+
from odoo import models
5+
6+
7+
class RequestDocument(models.Model):
8+
_inherit = "request.document"
9+
10+
def _get_origin_lines(self):
11+
vals = super()._get_origin_lines()
12+
vals["expense"] = "expense_sheet_ids.expense_line_ids"
13+
return vals
14+
15+
def _get_data_amount(self, request_line):
16+
if request_line._name == "hr.expense":
17+
data_amount = [
18+
{doc_line.id: doc_line.total_amount_currency}
19+
for doc_line in request_line
20+
]
21+
return data_amount
22+
return super()._get_data_amount(request_line)
23+
24+
def uncommit_request_budget(self, request_line):
25+
res = super().uncommit_request_budget(request_line)
26+
budget_move = request_line[request_line._budget_move_field]
27+
# Expense with state approve, posted or done will auto close budget
28+
if self.env.context.get("reverse_precommit") or (
29+
request_line._name == "hr.expense"
30+
and budget_move
31+
and request_line[request_line._doc_rel].approval_state
32+
in ["approve", "post", "done"]
33+
):
34+
budget_moves = self.close_budget_move()
35+
return budget_moves
36+
return res
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Kitti Upariphutthiphong \<<[email protected]>\>
2+
- Saran Lim. \<<[email protected]>\>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This module support commitment on request document expense
Loading

0 commit comments

Comments
 (0)