Skip to content

Commit

Permalink
[14.0][ADD] account_asset_compute_batch_job
Browse files Browse the repository at this point in the history
  • Loading branch information
Saran440 authored and ps-tubtim committed Jan 11, 2023
1 parent 6387011 commit 495d3ba
Show file tree
Hide file tree
Showing 16 changed files with 803 additions and 0 deletions.
83 changes: 83 additions & 0 deletions account_asset_compute_batch_job/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
===============================================
Assets - Compute Depre. with Job Queue in Batch
===============================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github
:target: https://github.com/OCA/account-financial-tools/tree/14.0/account_asset_compute_batch_job
:alt: OCA/account-financial-tools
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-financial-tools-14-0/account-financial-tools-14-0-account_asset_compute_batch_job
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/92/14.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

Add the possibility to compute assets batch with job queue.
This module adds a new button for compute in order to execute this process in job queue.

**Table of contents**

.. contents::
:local:

Usage
=====

To use this module, you need to:

#. Configured job queue
#. Create Compute Asset Batch directly
#. Click "Compute as Background" button to compute asset with job.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-tools/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_asset_compute_batch_job%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Ecosoft

Contributors
~~~~~~~~~~~~

* Saran Lim. <[email protected]>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/14.0/account_asset_compute_batch_job>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions account_asset_compute_batch_job/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
17 changes: 17 additions & 0 deletions account_asset_compute_batch_job/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2022 Ecosoft Co., Ltd. (http://ecosoft.co.th)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Assets - Compute Depre. with Job Queue in Batch",
"version": "14.0.1.0.0",
"license": "AGPL-3",
"depends": ["account_asset_compute_batch", "queue_job"],
"author": "Ecosoft, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-financial-tools",
"category": "Accounting & Finance",
"data": [
"security/ir.model.access.csv",
"data/queue_data.xml",
"views/account_asset_compute_batch.xml",
],
}
18 changes: 18 additions & 0 deletions account_asset_compute_batch_job/data/queue_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record id="channel_account_asset_compute_batch" model="queue.job.channel">
<field name="name">account_asset_compute_batch</field>
<field name="parent_id" ref="queue_job.channel_root" />
</record>
<record
id="job_function_account_asset_compute_batch_job"
model="queue.job.function"
>
<field
name="model_id"
ref="account_asset_compute_batch_job.model_account_asset_compute_batch"
/>
<field name="method">action_compute</field>
<field name="channel_id" ref="channel_account_asset_compute_batch" />
</record>
</odoo>
3 changes: 3 additions & 0 deletions account_asset_compute_batch_job/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import account_asset_compute_batch
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright 2022 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 AssetComputeBatch(models.Model):
_inherit = "account.asset.compute.batch"

job_ids = fields.Many2many(
comodel_name="queue.job",
column1="batch_id",
column2="job_id",
relation="asset_batch_job_rel",
copy=False,
)
job_current = fields.Many2one(comodel_name="queue.job", readonly=True)
job_state = fields.Selection(string="Job State", related="job_current.state")

def action_compute_job(self):
self.ensure_one()
queue_obj = self.env["queue.job"]
if not self.env.context.get("job_uuid") and not self.env.context.get(
"test_queue_job_no_delay"
):
description = _("Creating jobs to create moves for assets to %s") % (
self.date_end,
)
new_delay = self.with_delay(description=description).action_compute()
job = queue_obj.search([("uuid", "=", new_delay.uuid)])
self.job_ids = [(4, job.id)]
self.job_current = job.id
return "Job created with uuid {}".format(new_delay.uuid)
return super().action_compute()

def open_queue_job(self):
self.ensure_one()
action = {
"name": _("Jobs"),
"view_type": "tree",
"view_mode": "list,form",
"res_model": "queue.job",
"type": "ir.actions.act_window",
"domain": [("id", "in", self.job_ids.ids)],
}
return action
1 change: 1 addition & 0 deletions account_asset_compute_batch_job/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Saran Lim. <[email protected]>
2 changes: 2 additions & 0 deletions account_asset_compute_batch_job/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add the possibility to compute assets batch with job queue.
This module adds a new button for compute in order to execute this process in job queue.
5 changes: 5 additions & 0 deletions account_asset_compute_batch_job/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
To use this module, you need to:

#. Configured job queue
#. Create Compute Asset Batch directly
#. Click "Compute as Background" button to compute asset with job.
2 changes: 2 additions & 0 deletions account_asset_compute_batch_job/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_job_queue_account_readonly,access_job_queue_account_readonly,queue_job.model_queue_job,account.group_account_invoice,1,0,0,0
Loading

0 comments on commit 495d3ba

Please sign in to comment.