diff --git a/account_asset_number/README.rst b/account_asset_number/README.rst new file mode 100644 index 000000000..c6e25a12e --- /dev/null +++ b/account_asset_number/README.rst @@ -0,0 +1,86 @@ +======================== +Assets Management Number +======================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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_management_number + :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_management_number + :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| + +This module adds a asset number for the asset's reference. + +**Notes:** + +If you check "Auto Asset Number by Sequence", +you will not be able to edit the asset number using that asset profile. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +You can set the default asset number by going to *Invoicing > Configuration > Asset Profile*, +and check *Auto Asset Number by Sequence* then select *Asset Number Sequence*. + +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 `__: + + * 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. + +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_number/__init__.py b/account_asset_number/__init__.py new file mode 100644 index 000000000..37e105d03 --- /dev/null +++ b/account_asset_number/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models +from . import report diff --git a/account_asset_number/__manifest__.py b/account_asset_number/__manifest__.py new file mode 100644 index 000000000..516ad3df9 --- /dev/null +++ b/account_asset_number/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2021 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Assets Number", + "version": "14.0.1.0.0", + "license": "AGPL-3", + "depends": ["account_asset_management"], + "author": "Ecosoft, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/account-financial-tools", + "category": "Accounting & Finance", + "data": [ + "views/account_asset_profile.xml", + "views/account_asset.xml", + "report/account_asset_number_report.xml", + ], +} diff --git a/account_asset_number/models/__init__.py b/account_asset_number/models/__init__.py new file mode 100644 index 000000000..b2b73f37f --- /dev/null +++ b/account_asset_number/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import account_asset_profile +from . import account_asset diff --git a/account_asset_number/models/account_asset.py b/account_asset_number/models/account_asset.py new file mode 100644 index 000000000..e80cfacdf --- /dev/null +++ b/account_asset_number/models/account_asset.py @@ -0,0 +1,47 @@ +# Copyright 2021 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class AccountAsset(models.Model): + _inherit = "account.asset" + _rec_name = "number" + + number = fields.Char( + string="Asset Number", + default="", + index=True, + copy=False, + ) + use_sequence = fields.Boolean(related="profile_id.use_sequence") + + def validate(self): + res = super().validate() + for asset in self: + asset_profile = asset.profile_id + if ( + asset.number in [False, ""] + and asset_profile.use_sequence + and asset_profile.sequence_id + ): + asset.number = asset_profile.sequence_id.next_by_id() + return res + + @api.model + def _xls_acquisition_fields(self): + acquisition_fields = super()._xls_acquisition_fields() + acquisition_fields.insert(acquisition_fields.index("name"), "number") + return acquisition_fields + + @api.model + def _xls_active_fields(self): + active_fields = super()._xls_active_fields() + active_fields.insert(active_fields.index("name"), "number") + return active_fields + + @api.model + def _xls_removal_fields(self): + removal_fields = super()._xls_removal_fields() + removal_fields.insert(removal_fields.index("name"), "number") + return removal_fields diff --git a/account_asset_number/models/account_asset_profile.py b/account_asset_number/models/account_asset_profile.py new file mode 100644 index 000000000..730776a4b --- /dev/null +++ b/account_asset_number/models/account_asset_profile.py @@ -0,0 +1,23 @@ +# Copyright 2021 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class AccountAssetProfile(models.Model): + _inherit = "account.asset.profile" + + use_sequence = fields.Boolean( + string="Auto Asset Number by Sequence", + default=False, + help="If check, asset number auto run by sequence.", + ) + sequence_id = fields.Many2one( + comodel_name="ir.sequence", + string="Asset Number Sequence", + domain=lambda self: self._get_domain_sequence_id(), + ) + + @api.model + def _get_domain_sequence_id(self): + return [("company_id", "in", [False, self.env.company.id])] diff --git a/account_asset_number/readme/CONFIGURE.rst b/account_asset_number/readme/CONFIGURE.rst new file mode 100644 index 000000000..276289583 --- /dev/null +++ b/account_asset_number/readme/CONFIGURE.rst @@ -0,0 +1,2 @@ +You can set the default asset number by going to *Invoicing > Configuration > Asset Profile*, +and check *Auto Asset Number by Sequence* then select *Asset Number Sequence*. diff --git a/account_asset_number/readme/CONTRIBUTORS.rst b/account_asset_number/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..ea63aa7bc --- /dev/null +++ b/account_asset_number/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Ecosoft `__: + + * Pimolnat Suntian diff --git a/account_asset_number/readme/DESCRIPTION.rst b/account_asset_number/readme/DESCRIPTION.rst new file mode 100644 index 000000000..eb49b2a5c --- /dev/null +++ b/account_asset_number/readme/DESCRIPTION.rst @@ -0,0 +1,6 @@ +This module adds a asset number for the asset's reference. + +**Notes:** + +If you check "Auto Asset Number by Sequence", +you will not be able to edit the asset number using that asset profile. diff --git a/account_asset_number/report/__init__.py b/account_asset_number/report/__init__.py new file mode 100644 index 000000000..6203df4f1 --- /dev/null +++ b/account_asset_number/report/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import account_asset_report_xls diff --git a/account_asset_number/report/account_asset_number_report.xml b/account_asset_number/report/account_asset_number_report.xml new file mode 100644 index 000000000..d60e34b45 --- /dev/null +++ b/account_asset_number/report/account_asset_number_report.xml @@ -0,0 +1,65 @@ + + + + + + + Asset Number (PDF) + account.asset + qweb-pdf + account_asset_number.report_asset_number + account_asset_number.report_asset_number + 'Asset Number - %s' % (object.name) + + report + + diff --git a/account_asset_number/report/account_asset_report_xls.py b/account_asset_number/report/account_asset_report_xls.py new file mode 100644 index 000000000..f484b3564 --- /dev/null +++ b/account_asset_number/report/account_asset_report_xls.py @@ -0,0 +1,24 @@ +# Copyright 2021 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class AssetReportXlsx(models.AbstractModel): + _inherit = "report.account_asset_management.asset_report_xls" + + def _get_asset_template(self): + res = super()._get_asset_template() + res.update( + { + "number": { + "header": {"type": "string", "value": self._("Number")}, + "asset": { + "type": "string", + "value": self._render("asset.number or ''"), + }, + "width": 20, + } + } + ) + return res diff --git a/account_asset_number/static/description/icon.png b/account_asset_number/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/account_asset_number/static/description/icon.png differ diff --git a/account_asset_number/static/description/index.html b/account_asset_number/static/description/index.html new file mode 100644 index 000000000..53d67c911 --- /dev/null +++ b/account_asset_number/static/description/index.html @@ -0,0 +1,431 @@ + + + + + + +Assets Management Number + + + +
+

Assets Management Number

+ + +

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

+

This module adds a asset number for the asset’s reference.

+

Notes:

+

If you check “Auto Asset Number by Sequence”, +you will not be able to edit the asset number using that asset profile.

+

Table of contents

+ +
+

Configuration

+

You can set the default asset number by going to Invoicing > Configuration > Asset Profile, +and check Auto Asset Number by Sequence then select Asset Number Sequence.

+
+
+

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.

+

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_number/views/account_asset.xml b/account_asset_number/views/account_asset.xml new file mode 100644 index 000000000..ec61d4645 --- /dev/null +++ b/account_asset_number/views/account_asset.xml @@ -0,0 +1,52 @@ + + + + account.asset.form + account.asset + + +

+ +

+
+
+ + account.asset.tree + account.asset + + + + + + + + + account.asset.search + account.asset + + + + ['|', ('name', 'ilike', self), ('number', 'ilike', self)] + + + +
diff --git a/account_asset_number/views/account_asset_profile.xml b/account_asset_number/views/account_asset_profile.xml new file mode 100644 index 000000000..8122e8348 --- /dev/null +++ b/account_asset_number/views/account_asset_profile.xml @@ -0,0 +1,23 @@ + + + + account.asset.profile.form + account.asset.profile + + + + + + + + + diff --git a/setup/account_asset_number/odoo/addons/account_asset_number b/setup/account_asset_number/odoo/addons/account_asset_number new file mode 120000 index 000000000..1ae42b196 --- /dev/null +++ b/setup/account_asset_number/odoo/addons/account_asset_number @@ -0,0 +1 @@ +../../../../account_asset_number \ No newline at end of file diff --git a/setup/account_asset_number/setup.py b/setup/account_asset_number/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/account_asset_number/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)