Skip to content

Commit

Permalink
[ADD] fixed_asset_queue
Browse files Browse the repository at this point in the history
  • Loading branch information
andhit-r committed Jun 10, 2024
1 parent ec66271 commit 7632cf6
Show file tree
Hide file tree
Showing 8 changed files with 174 additions and 0 deletions.
52 changes: 52 additions & 0 deletions fixed_asset_queue/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

====================
Fixed Asset Disposal
====================


Installation
============

To install this module, you need to:

1. Clone the branch 11.0 of the repository https://github.com/open-synergy/opnsynid-fixed-asset
2. Add the path to this repository in your configuration (addons-path)
3. Update the module list
4. Go to menu *Apps -> Apps*
5. Search For *Fixed Asset Disposal*
6. Install the module

Roadmap
=======


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

Bugs are tracked on `GitHub Issues
<https://github.com/open-synergy/opnsynid-fixed-asset/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.


Credits
=======

Contributors
------------

* Michael Viriyananda <[email protected]>
* Andhitia Rama <[email protected]>

Maintainer
----------

.. image:: https://simetri-sinergi.id/logo.png
:alt: PT. Simetri Sinergi Indonesia
:target: https://simetri-sinergi.id.com

This module is maintained by the PT. Simetri Sinergi Indonesia.
7 changes: 7 additions & 0 deletions fixed_asset_queue/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright 2022 OpenSynergy Indonesia
# Copyright 2022 PT. Simetri Sinergi Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import (
models,
wizards,
)
20 changes: 20 additions & 0 deletions fixed_asset_queue/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2022 OpenSynergy Indonesia
# Copyright 2022 PT. Simetri Sinergi Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# pylint: disable=locally-disabled, manifest-required-author
{
"name": "Fixed Asset + Queue Integration",
"version": "11.0.1.0.0",
"website": "https://simetri-sinergi.id",
"author": "OpenSynergy Indonesia",
"license": "AGPL-3",
"installable": True,
"depends": [
"fixed_asset",
"queue_job_batch",
],
"data": [
"wizards/mass_depreciation_views.xml",
],
"demo": [],
}
7 changes: 7 additions & 0 deletions fixed_asset_queue/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright 2022 OpenSynergy Indonesia
# Copyright 2022 PT. Simetri Sinergi Indonesia
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import (
fixed_asset_depreciation_line,
)
19 changes: 19 additions & 0 deletions fixed_asset_queue/models/fixed_asset_depreciation_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2022 OpenSynergy Indonesia
# Copyright 2022 PT. Simetri Sinergi Indonesia
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).


from odoo import api, models

from odoo.addons.queue_job.job import job


class FixedAssetDepreciationLine(models.Model):
_name = "fixed.asset.depreciation.line"
_inherit = "fixed.asset.depreciation.line"

@api.multi
@job
def create_move(self):
_super = super(FixedAssetDepreciationLine, self)
_super.create_move()
7 changes: 7 additions & 0 deletions fixed_asset_queue/wizards/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright 2022 OpenSynergy Indonesia
# Copyright 2022 PT. Simetri Sinergi Indonesia
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import (
mass_depreciation,
)
36 changes: 36 additions & 0 deletions fixed_asset_queue/wizards/mass_depreciation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright 2022 OpenSynergy Indonesia
# Copyright 2022 PT. Simetri Sinergi Indonesia
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import _, api, models


class AccountMassDepreciation(models.TransientModel):
_name = "account.mass_depreciation"
_inherit = "account.mass_depreciation"

@api.multi
def action_confirm_queue(self):
for wizard in self:
wizard._mass_depreciate_queue()

@api.multi
def _mass_depreciate_queue(self):
self.ensure_one()
obj_line = self.env["fixed.asset.depreciation.line"]
criteria = [
("asset_id.state", "=", "open"),
("type", "=", "depreciate"),
("init_entry", "=", False),
("move_id", "=", False),
("line_date", "=", self.date),
]
if self.category_ids:
criteria.append(("asset_id.category_id", "in", self.category_ids.ids))

for line in obj_line.search(criteria):
description = "Fixed asset depreciation ID %s %s" % (
line.asset_id.id,
self.date,
)
line.with_context().with_delay(description=_(description)).create_move()
26 changes: 26 additions & 0 deletions fixed_asset_queue/wizards/mass_depreciation_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="account_mass_depreciation_view_form" model="ir.ui.view">
<field name="name">Mass Depreciation + Queue</field>
<field name="model">account.mass_depreciation</field>
<field name="inherit_id" ref="fixed_asset.account_mass_depreciation_view_form" />
<field name="arch" type="xml">
<data>
<xpath expr="//button[@name='action_confirm']" position="after">
or
<button
string="Confirm with queue"
name="action_confirm_queue"
type="object"
class="oe_highlight"
confirm="Are you sure?"
/>
</xpath>
</data>
</field>
</record>



</odoo>

0 comments on commit 7632cf6

Please sign in to comment.