diff --git a/account_asset_low_value/README.rst b/account_asset_low_value/README.rst new file mode 100644 index 000000000..a97dfbff0 --- /dev/null +++ b/account_asset_low_value/README.rst @@ -0,0 +1,96 @@ +=================================== +Assets Management - Low Value Asset +=================================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |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_low_value + :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_low_value + :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| + +Low-Value Asset (LVA) are typically asset with low values and was booked as expense on vendor bill. +In essence, the low value asset is not really and asset but an expense need to tracke as asset. +As such, it has no residual value, run no depreciation. And when removed, only status is changed (no accounting entry). + +To create low value asset, use the Asset Profile with following setting, + +1. Asset Account = Expense (low value asset) +2. Number of Years = 0 + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Ecosoft + +Contributors +~~~~~~~~~~~~ + +* `Ecosoft `__: + + * Kitti U. + * Pimolnat Suntian + +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. + +.. |maintainer-kittiu| image:: https://github.com/kittiu.png?size=40px + :target: https://github.com/kittiu + :alt: kittiu + +Current `maintainer `__: + +|maintainer-kittiu| + +This module is part of the `OCA/account-financial-tools `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_asset_low_value/__init__.py b/account_asset_low_value/__init__.py new file mode 100644 index 000000000..4d7a49b5e --- /dev/null +++ b/account_asset_low_value/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models +from . import wizard diff --git a/account_asset_low_value/__manifest__.py b/account_asset_low_value/__manifest__.py new file mode 100644 index 000000000..aa0c968ed --- /dev/null +++ b/account_asset_low_value/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2021 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Assets Management - Low Value Asset", + "version": "15.0.1.0.0", + "license": "AGPL-3", + "author": "Ecosoft, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/account-financial-tools", + "category": "Accounting & Finance", + "depends": ["account_asset_management"], + "data": [ + "wizard/account_asset_remove.xml", + "views/account_asset_views.xml", + ], + "installable": True, + "maintainers": ["kittiu"], + "development_status": "Alpha", +} diff --git a/account_asset_low_value/i18n/account_asset_low_value.pot b/account_asset_low_value/i18n/account_asset_low_value.pot new file mode 100644 index 000000000..319f140de --- /dev/null +++ b/account_asset_low_value/i18n/account_asset_low_value.pot @@ -0,0 +1,74 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_asset_low_value +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_asset_low_value +#: model:ir.model,name:account_asset_low_value.model_account_asset +msgid "Asset" +msgstr "" + +#. module: account_asset_low_value +#: model_terms:ir.ui.view,arch_db:account_asset_low_value.asset_low_value_remove_form +msgid "Cancel" +msgstr "" + +#. module: account_asset_low_value +#: model:ir.model.fields,field_description:account_asset_low_value.field_account_asset__display_name +#: model:ir.model.fields,field_description:account_asset_low_value.field_account_asset_remove__display_name +msgid "Display Name" +msgstr "" + +#. module: account_asset_low_value +#: model:ir.model.fields,field_description:account_asset_low_value.field_account_asset__id +#: model:ir.model.fields,field_description:account_asset_low_value.field_account_asset_remove__id +msgid "ID" +msgstr "" + +#. module: account_asset_low_value +#: model:ir.model.fields,field_description:account_asset_low_value.field_account_asset____last_update +#: model:ir.model.fields,field_description:account_asset_low_value.field_account_asset_remove____last_update +msgid "Last Modified on" +msgstr "" + +#. module: account_asset_low_value +#: model:ir.model.fields,field_description:account_asset_low_value.field_account_asset__low_value +#: model_terms:ir.ui.view,arch_db:account_asset_low_value.account_asset_view_search +msgid "Low Value Asset" +msgstr "" + +#. module: account_asset_low_value +#: model:ir.model.fields,help:account_asset_low_value.field_account_asset__low_value +msgid "" +"Low-Value Asset (LVA) is true when the asset profile set\n" +"1. Asset Account = Expense (low value asset)\n" +"2. Number of Years = 0 years\n" +"In essense, the low value asset is not really and asset but an expense tracked as asset, as such, it has no residual value. And when removed, only status is changed (no accounting entry)." +msgstr "" + +#. module: account_asset_low_value +#: model_terms:ir.ui.view,arch_db:account_asset_low_value.account_asset_view_search +msgid "Normal Asset" +msgstr "" + +#. module: account_asset_low_value +#: model:ir.model,name:account_asset_low_value.model_account_asset_remove +#: model_terms:ir.ui.view,arch_db:account_asset_low_value.asset_low_value_remove_form +msgid "Remove Asset" +msgstr "" + +#. module: account_asset_low_value +#: code:addons/account_asset_low_value/models/account_asset.py:0 +#, python-format +msgid "Remove Low Value Asset" +msgstr "" diff --git a/account_asset_low_value/models/__init__.py b/account_asset_low_value/models/__init__.py new file mode 100644 index 000000000..ecfd41418 --- /dev/null +++ b/account_asset_low_value/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import account_asset diff --git a/account_asset_low_value/models/account_asset.py b/account_asset_low_value/models/account_asset.py new file mode 100644 index 000000000..426d1e8ff --- /dev/null +++ b/account_asset_low_value/models/account_asset.py @@ -0,0 +1,77 @@ +# Copyright 2021 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import _, api, fields, models + + +class AccountAsset(models.Model): + _inherit = "account.asset" + + low_value = fields.Boolean( + string="Low Value Asset", + compute="_compute_low_value", + search="_search_low_value", + help="Low-Value Asset (LVA) is true when the asset profile set\n" + "1. Asset Account = Expense (low value asset)\n" + "2. Number of Years = 0 years\n" + "In essense, the low value asset is not really and asset but an expense " + "tracked as asset, as such, it has no residual value. And when removed, " + "only status is changed (no accounting entry).", + ) + + @api.depends("profile_id", "method_number") + def _compute_low_value(self): + expense_account = self.env.ref("account.data_account_type_expenses") + for asset in self: + asset.low_value = ( + asset.profile_id.account_asset_id.user_type_id == expense_account + and asset.method_number == 0 + ) + + @api.model + def _search_low_value(self, operator, value): + expense_account = self.env.ref("account.data_account_type_expenses") + if operator == "=": + return [ + ("profile_id.account_asset_id.user_type_id", "=", expense_account.id), + ("method_number", "=", 0), + ] + if operator == "!=": + return [ + "|", + ("profile_id.account_asset_id.user_type_id", "!=", expense_account.id), + ("method_number", "!=", 0), + ] + + def _compute_depreciation(self): + res = super()._compute_depreciation() + # For low value asset, there is no depreciation + for asset in self: + if asset.low_value: + asset.value_residual = 0 + return res + + def validate(self): + res = super().validate() + # For low value asset, state = "open" even value_residual = 0 + for asset in self: + if asset.low_value: + asset.state = "open" + return res + + def remove(self): + self.ensure_one() + ctx = dict(self.env.context, active_ids=self.ids, active_id=self.id) + # Removing low value asset, use different wizard + if self.low_value: + view = self.env.ref("account_asset_low_value.asset_low_value_remove_form") + return { + "name": _("Remove Low Value Asset"), + "view_mode": "form", + "res_model": "account.asset.remove", + "view_id": view.id, + "target": "new", + "type": "ir.actions.act_window", + "context": ctx, + } + return super().remove() diff --git a/account_asset_low_value/readme/CONTRIBUTORS.rst b/account_asset_low_value/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..b64335f20 --- /dev/null +++ b/account_asset_low_value/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* `Ecosoft `__: + + * Kitti U. + * Pimolnat Suntian diff --git a/account_asset_low_value/readme/DESCRIPTION.rst b/account_asset_low_value/readme/DESCRIPTION.rst new file mode 100644 index 000000000..f9ecf423e --- /dev/null +++ b/account_asset_low_value/readme/DESCRIPTION.rst @@ -0,0 +1,8 @@ +Low-Value Asset (LVA) are typically asset with low values and was booked as expense on vendor bill. +In essence, the low value asset is not really and asset but an expense need to tracke as asset. +As such, it has no residual value, run no depreciation. And when removed, only status is changed (no accounting entry). + +To create low value asset, use the Asset Profile with following setting, + +1. Asset Account = Expense (low value asset) +2. Number of Years = 0 diff --git a/account_asset_low_value/static/description/icon.png b/account_asset_low_value/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/account_asset_low_value/static/description/icon.png differ diff --git a/account_asset_low_value/static/description/index.html b/account_asset_low_value/static/description/index.html new file mode 100644 index 000000000..c3b425564 --- /dev/null +++ b/account_asset_low_value/static/description/index.html @@ -0,0 +1,438 @@ + + + + + + +Assets Management - Low Value Asset + + + +
+

Assets Management - Low Value Asset

+ + +

Alpha License: AGPL-3 OCA/account-financial-tools Translate me on Weblate Try me on Runbot

+

Low-Value Asset (LVA) are typically asset with low values and was booked as expense on vendor bill. +In essence, the low value asset is not really and asset but an expense need to tracke as asset. +As such, it has no residual value, run no depreciation. And when removed, only status is changed (no accounting entry).

+

To create low value asset, use the Asset Profile with following setting,

+
    +
  1. Asset Account = Expense (low value asset)
  2. +
  3. Number of Years = 0
  4. +
+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Ecosoft
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

Current maintainer:

+

kittiu

+

This module is part of the OCA/account-financial-tools project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/account_asset_low_value/tests/__init__.py b/account_asset_low_value/tests/__init__.py new file mode 100644 index 000000000..544e8be16 --- /dev/null +++ b/account_asset_low_value/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_asset_low_value diff --git a/account_asset_low_value/tests/test_asset_low_value.py b/account_asset_low_value/tests/test_asset_low_value.py new file mode 100644 index 000000000..6295a5123 --- /dev/null +++ b/account_asset_low_value/tests/test_asset_low_value.py @@ -0,0 +1,81 @@ +# Copyright 2021 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import fields +from odoo.tests import tagged +from odoo.tests.common import Form + +from odoo.addons.account.tests.common import AccountTestInvoicingCommon + + +@tagged("post_install", "-at_install") +class TestAssetLowValue(AccountTestInvoicingCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.asset_model = cls.env["account.asset"] + cls.asset_profile_model = cls.env["account.asset.profile"] + cls.remove_model = cls.env["account.asset.remove"] + # Low value asset profile + expense_account = cls.company_data["default_account_expense"] + cls.profile_low_value = cls.asset_profile_model.create( + { + "account_expense_depreciation_id": expense_account.id, + "account_asset_id": expense_account.id, + "account_depreciation_id": expense_account.id, + "account_residual_value_id": expense_account.id, + "journal_id": cls.company_data["default_journal_purchase"].id, + "name": "Asset Low Value", + "method_time": "year", + "method_number": 0, + "method_period": "year", + } + ) + + # Invoice + cls.partner = cls.env["res.partner"].create({"name": "Test Partner"}) + cls.product = cls.env["product.product"].create( + {"name": "Test", "standard_price": 500.0} + ) + move_form = Form( + cls.env["account.move"].with_context( + default_move_type="in_invoice", check_move_validity=False + ) + ) + move_form.invoice_date = fields.Date.context_today(cls.env.user) + move_form.partner_id = cls.partner + with move_form.invoice_line_ids.new() as line_form: + line_form.name = "test" + line_form.product_id = cls.product + line_form.price_unit = 2000.00 + line_form.quantity = 1 + cls.invoice = move_form.save() + + def test_01_asset_low_value(self): + invoice = self.invoice + move_form = Form(invoice) + with move_form.invoice_line_ids.edit(0) as line_form: + line_form.asset_profile_id = self.profile_low_value + invoice = move_form.save() + invoice.action_post() + asset = invoice.invoice_line_ids.mapped("asset_id") + move_count = len(asset.account_move_line_ids) + self.assertTrue(asset.low_value) + asset.validate() + + self.assertEqual(asset.value_residual, 0) + self.assertEqual(asset.state, "open") + asset.remove() + remove_model = self.env["account.asset.remove"].with_context(active_id=asset.id) + with Form(remove_model) as f: + f.posting_regime = "residual_value" + remove = f.save() + remove.remove() + self.assertEqual(asset.state, "removed") + self.assertEqual( + len(asset.account_move_line_ids), move_count + ) # no new account moves + # Search test + low_value_assets = self.asset_model.search([("low_value", "=", True)]) + self.assertIn(asset, low_value_assets) + normal_assets = self.asset_model.search([("low_value", "!=", True)]) + self.assertNotIn(asset, normal_assets) diff --git a/account_asset_low_value/views/account_asset_views.xml b/account_asset_low_value/views/account_asset_views.xml new file mode 100644 index 000000000..beb0e83a4 --- /dev/null +++ b/account_asset_low_value/views/account_asset_views.xml @@ -0,0 +1,41 @@ + + + account.asset.form + account.asset + + + + + + + + + account.asset.search + account.asset + + + + + + + + + + diff --git a/account_asset_low_value/wizard/__init__.py b/account_asset_low_value/wizard/__init__.py new file mode 100644 index 000000000..5b4df2eb4 --- /dev/null +++ b/account_asset_low_value/wizard/__init__.py @@ -0,0 +1 @@ +from . import account_asset_remove diff --git a/account_asset_low_value/wizard/account_asset_remove.py b/account_asset_low_value/wizard/account_asset_remove.py new file mode 100644 index 000000000..51dfd6251 --- /dev/null +++ b/account_asset_low_value/wizard/account_asset_remove.py @@ -0,0 +1,17 @@ +# Copyright 2021 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models + + +class AccountAssetRemove(models.TransientModel): + _inherit = "account.asset.remove" + + def remove(self): + self.ensure_one() + asset_id = self.env.context.get("active_id") + asset = self.env["account.asset"].browse(asset_id) + if asset.low_value: + asset.write({"state": "removed", "date_remove": self.date_remove}) + return True + return super().remove() diff --git a/account_asset_low_value/wizard/account_asset_remove.xml b/account_asset_low_value/wizard/account_asset_remove.xml new file mode 100644 index 000000000..ab16e3387 --- /dev/null +++ b/account_asset_low_value/wizard/account_asset_remove.xml @@ -0,0 +1,28 @@ + + + asset.low.value.remove.form + account.asset.remove + + +
+ + + + + + + + + +
+
+
+
diff --git a/setup/account_asset_low_value/odoo/addons/account_asset_low_value b/setup/account_asset_low_value/odoo/addons/account_asset_low_value new file mode 120000 index 000000000..c720ca33b --- /dev/null +++ b/setup/account_asset_low_value/odoo/addons/account_asset_low_value @@ -0,0 +1 @@ +../../../../account_asset_low_value \ No newline at end of file diff --git a/setup/account_asset_low_value/setup.py b/setup/account_asset_low_value/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/account_asset_low_value/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)