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 + + + +