From ea23e91730803b295f7cb87dfa7ee5d9685637d4 Mon Sep 17 00:00:00 2001 From: Saran440 Date: Tue, 26 Sep 2023 13:58:08 +0700 Subject: [PATCH] [ADD] budget_control_job --- budget_control_job/__init__.py | 4 +++ budget_control_job/__manifest__.py | 21 +++++++++++++++ budget_control_job/models/__init__.py | 4 +++ .../models/budget_balance_forward.py | 20 ++++++++++++++ .../models/budget_commit_forward.py | 20 ++++++++++++++ budget_control_job/readme/CONTRIBUTORS.rst | 1 + budget_control_job/readme/DESCRIPTION.rst | 1 + budget_control_job/readme/USAGE.rst | 1 + .../views/budget_balance_forward_view.xml | 26 +++++++++++++++++++ .../views/budget_commit_forward_view.xml | 22 ++++++++++++++++ budget_control_job/wizards/__init__.py | 4 +++ .../wizards/budget_balance_forward_info.py | 12 +++++++++ .../budget_balance_forward_info_view.xml | 26 +++++++++++++++++++ .../wizards/budget_commit_forward_info.py | 12 +++++++++ .../budget_commit_forward_info_view.xml | 26 +++++++++++++++++++ .../odoo/addons/budget_control_job | 1 + setup/budget_control_job/setup.py | 6 +++++ 17 files changed, 207 insertions(+) create mode 100644 budget_control_job/__init__.py create mode 100644 budget_control_job/__manifest__.py create mode 100644 budget_control_job/models/__init__.py create mode 100644 budget_control_job/models/budget_balance_forward.py create mode 100644 budget_control_job/models/budget_commit_forward.py create mode 100644 budget_control_job/readme/CONTRIBUTORS.rst create mode 100644 budget_control_job/readme/DESCRIPTION.rst create mode 100644 budget_control_job/readme/USAGE.rst create mode 100644 budget_control_job/views/budget_balance_forward_view.xml create mode 100644 budget_control_job/views/budget_commit_forward_view.xml create mode 100644 budget_control_job/wizards/__init__.py create mode 100644 budget_control_job/wizards/budget_balance_forward_info.py create mode 100644 budget_control_job/wizards/budget_balance_forward_info_view.xml create mode 100644 budget_control_job/wizards/budget_commit_forward_info.py create mode 100644 budget_control_job/wizards/budget_commit_forward_info_view.xml create mode 120000 setup/budget_control_job/odoo/addons/budget_control_job create mode 100644 setup/budget_control_job/setup.py diff --git a/budget_control_job/__init__.py b/budget_control_job/__init__.py new file mode 100644 index 00000000..7588e52c --- /dev/null +++ b/budget_control_job/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models +from . import wizards diff --git a/budget_control_job/__manifest__.py b/budget_control_job/__manifest__.py new file mode 100644 index 00000000..41f918a7 --- /dev/null +++ b/budget_control_job/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2023 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Budget Control - Queue Job", + "version": "14.0.1.0.0", + "category": "Accounting", + "license": "AGPL-3", + "author": "Ecosoft, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/account-budgeting", + "depends": ["budget_control", "queue_job"], + "data": [ + "wizards/budget_commit_forward_info_view.xml", + "wizards/budget_balance_forward_info_view.xml", + "views/budget_commit_forward_view.xml", + "views/budget_balance_forward_view.xml", + ], + "installable": True, + "maintainers": ["Saran440"], + "development_status": "Alpha", +} diff --git a/budget_control_job/models/__init__.py b/budget_control_job/models/__init__.py new file mode 100644 index 00000000..93db3d34 --- /dev/null +++ b/budget_control_job/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import budget_balance_forward +from . import budget_commit_forward diff --git a/budget_control_job/models/budget_balance_forward.py b/budget_control_job/models/budget_balance_forward.py new file mode 100644 index 00000000..7fcaa4c2 --- /dev/null +++ b/budget_control_job/models/budget_balance_forward.py @@ -0,0 +1,20 @@ +# Copyright 2023 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import _, fields, models + + +class BudgetBalanceForward(models.Model): + _inherit = "budget.balance.forward" + + job_uuid = fields.Char( + string="Job UUID", + readonly=True, + ) + + def action_budget_balance_forward_job(self): + description = _("Creating forward balance budget with id %s") % (self.id,) + job = self.with_delay(description=description).action_budget_balance_forward() + # Update UUID in forward commit + self.job_uuid = job.uuid + return "Job created with uuid {}".format(job.uuid) diff --git a/budget_control_job/models/budget_commit_forward.py b/budget_control_job/models/budget_commit_forward.py new file mode 100644 index 00000000..e34c57ac --- /dev/null +++ b/budget_control_job/models/budget_commit_forward.py @@ -0,0 +1,20 @@ +# Copyright 2020 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import _, fields, models + + +class BudgetCommitForward(models.Model): + _inherit = "budget.commit.forward" + + job_uuid = fields.Char( + string="Job UUID", + readonly=True, + ) + + def action_budget_commit_forward_job(self): + description = _("Creating forward commit budget with id %s") % (self.id,) + job = self.with_delay(description=description).action_budget_commit_forward() + # Update UUID in forward commit + self.job_uuid = job.uuid + return "Job created with uuid {}".format(job.uuid) diff --git a/budget_control_job/readme/CONTRIBUTORS.rst b/budget_control_job/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..cc6b2310 --- /dev/null +++ b/budget_control_job/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Saran Lim. diff --git a/budget_control_job/readme/DESCRIPTION.rst b/budget_control_job/readme/DESCRIPTION.rst new file mode 100644 index 00000000..c50ac63f --- /dev/null +++ b/budget_control_job/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module add job queue for run carry forward with many records. diff --git a/budget_control_job/readme/USAGE.rst b/budget_control_job/readme/USAGE.rst new file mode 100644 index 00000000..8ee487cf --- /dev/null +++ b/budget_control_job/readme/USAGE.rst @@ -0,0 +1 @@ +Create forward balance/commit > review > Forward Budget Balance/Commitment with will select forward with job queue diff --git a/budget_control_job/views/budget_balance_forward_view.xml b/budget_control_job/views/budget_balance_forward_view.xml new file mode 100644 index 00000000..a9b49457 --- /dev/null +++ b/budget_control_job/views/budget_balance_forward_view.xml @@ -0,0 +1,26 @@ + + + + view.budget.balance.forward.form + budget.balance.forward + + + + + + + + {'invisible': ['|', ('state', '!=', 'review'), ('job_uuid', '!=', False)]} + + + + + diff --git a/budget_control_job/views/budget_commit_forward_view.xml b/budget_control_job/views/budget_commit_forward_view.xml new file mode 100644 index 00000000..e6713798 --- /dev/null +++ b/budget_control_job/views/budget_commit_forward_view.xml @@ -0,0 +1,22 @@ + + + + view.budget.commit.forward.form + budget.commit.forward + + + + + + + + {'invisible': ['|', ('state', '!=', 'review'), ('job_uuid', '!=', False)]} + + + + diff --git a/budget_control_job/wizards/__init__.py b/budget_control_job/wizards/__init__.py new file mode 100644 index 00000000..aa88604c --- /dev/null +++ b/budget_control_job/wizards/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import budget_commit_forward_info +from . import budget_balance_forward_info diff --git a/budget_control_job/wizards/budget_balance_forward_info.py b/budget_control_job/wizards/budget_balance_forward_info.py new file mode 100644 index 00000000..6cbeb0aa --- /dev/null +++ b/budget_control_job/wizards/budget_balance_forward_info.py @@ -0,0 +1,12 @@ +# Copyright 2023 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models + + +class BudgetBalanceForwardInfo(models.TransientModel): + _inherit = "budget.balance.forward.info" + + def action_budget_balance_forward_job(self): + self.ensure_one() + self.forward_id.action_budget_balance_forward_job() diff --git a/budget_control_job/wizards/budget_balance_forward_info_view.xml b/budget_control_job/wizards/budget_balance_forward_info_view.xml new file mode 100644 index 00000000..914d70eb --- /dev/null +++ b/budget_control_job/wizards/budget_balance_forward_info_view.xml @@ -0,0 +1,26 @@ + + + + + budget.balance.forward.info.form + budget.balance.forward.info + + + +