-
Notifications
You must be signed in to change notification settings - Fork 22
[18.0][MIG] account_asset_management_extension: Migration to 18.0 #754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
deeniiz
wants to merge
10
commits into
18.0
Choose a base branch
from
18.0-mig-account_asset_management_extension
base: 18.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ad9b32d
[ADD] account_asset_management_extension: New Module
KNVx e3d2f3e
[IMP] account_asset_management_extension: quantity included on asset
KNVx 21d8448
[FIX] account_asset_management_extension: invoice_date can be modifie…
KNVx 0fdfeb2
[FIX] account_asset_management_extension: asset value computed with u…
eantones d7ee328
Revert "[FIX] account_asset_management_extension: asset value compute…
eantones cb444b2
[REF] account_asset_management_extension: optimization to not divide …
eantones d78c292
[IMP] account_asset_management_extension: pre-commit stuff
bjkumal f191648
[MIG] account_asset_management_extension: Migration to 16.0
bjkumal be67e7f
[IMP] account_asset_management_extension: pre-commit auto fixes
deeniiz df77797
[MIG] account_asset_management_extension: Migration to 18.0
deeniiz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| ================================== | ||
| Account Asset Management Extension | ||
| ================================== | ||
|
|
||
| .. | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! This file is generated by oca-gen-addon-readme !! | ||
| !! changes will be overwritten. !! | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! source digest: sha256:4efba3fd6254fdeeab7ce79dec3cf0773f88f49eb51a130c2e1f27ef00d3d9b7 | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
|
||
| .. |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-NuoBiT%2Fodoo--addons-lightgray.png?logo=github | ||
| :target: https://github.com/NuoBiT/odoo-addons/tree/18.0/account_asset_management_extension | ||
| :alt: NuoBiT/odoo-addons | ||
|
|
||
| |badge1| |badge2| |badge3| | ||
|
|
||
| This module adds additional fields on assets. | ||
|
|
||
| **Table of contents** | ||
|
|
||
| .. contents:: | ||
| :local: | ||
|
|
||
| Bug Tracker | ||
| =========== | ||
|
|
||
| Bugs are tracked on `GitHub Issues <https://github.com/NuoBiT/odoo-addons/issues>`_. | ||
| In case of trouble, please check there if your issue has already been reported. | ||
| If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
| `feedback <https://github.com/NuoBiT/odoo-addons/issues/new?body=module:%20account_asset_management_extension%0Aversion:%2018.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 | ||
| ------- | ||
|
|
||
| * NuoBiT Solutions SL | ||
|
|
||
| Contributors | ||
| ------------ | ||
|
|
||
| - `NuoBiT <https://www.nuobit.com>`__: | ||
|
|
||
| - Kilian Niubo kniubo@nuobit.com | ||
| - Eric Antones eantones@nuobit.com | ||
| - Bijaya Kumal bkumal@nuobit.com | ||
| - Deniz Gallo dgallo@nuobit.com | ||
|
|
||
| Maintainers | ||
| ----------- | ||
|
|
||
| This module is part of the `NuoBiT/odoo-addons <https://github.com/NuoBiT/odoo-addons/tree/18.0/account_asset_management_extension>`_ project on GitHub. | ||
|
|
||
| You are welcome to contribute. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import models |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Copyright NuoBiT - Kilian Niubo <kniubo@nuobit.com> | ||
| # Copyright 2025 NuoBiT Solutions - Deniz Gallo <dgallo@nuobit.com> | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
|
|
||
| { | ||
| "name": "Account Asset Management Extension", | ||
| "summary": "This module adds additional fields in assets", | ||
| "version": "18.0.1.0.0", | ||
| "category": "Accounting", | ||
| "author": "NuoBiT Solutions SL", | ||
| "website": "https://github.com/NuoBiT/odoo-addons", | ||
| "license": "AGPL-3", | ||
| "depends": [ | ||
| "account_asset_management", | ||
| ], | ||
| "data": [ | ||
| "views/account_asset.xml", | ||
| ], | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| # Translation of Odoo Server. | ||
| # This file contains the translation of the following modules: | ||
| # * account_asset_management_extension | ||
| # | ||
| msgid "" | ||
| msgstr "" | ||
| "Project-Id-Version: Odoo Server 18.0\n" | ||
| "Report-Msgid-Bugs-To: \n" | ||
| "POT-Creation-Date: 2022-09-29 12:35+0000\n" | ||
| "PO-Revision-Date: 2022-09-29 12:35+0000\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_management_extension | ||
| #: model:ir.model,name:account_asset_management_extension.model_account_asset | ||
| msgid "Asset" | ||
| msgstr "Activo" | ||
|
|
||
| #. module: account_asset_management_extension | ||
| #: model:ir.model.fields,field_description:account_asset_management_extension.field_account_asset__currency_id | ||
| msgid "Currency" | ||
| msgstr "Divisa" | ||
|
|
||
| #. module: account_asset_management_extension | ||
| #: model:ir.model.fields,field_description:account_asset_management_extension.field_account_asset__invoice_date | ||
| msgid "Invoice Date" | ||
| msgstr "Fecha de la factura" | ||
|
|
||
| #. module: account_asset_management_extension | ||
| #: model:ir.model.fields,field_description:account_asset_management_extension.field_account_asset__invoice_ref | ||
| msgid "Invoice Reference" | ||
| msgstr "Referencia de la factura" | ||
|
|
||
| #. module: account_asset_management_extension | ||
| #: model_terms:ir.ui.view,arch_db:account_asset_management_extension.account_asset_view_form | ||
| msgid "Other Information" | ||
| msgstr "Otra informacion" | ||
|
|
||
| #. module: account_asset_management_extension | ||
| #: model:ir.model.fields,field_description:account_asset_management_extension.field_account_asset__tax_base_amount | ||
| msgid "Tax Base Amount" | ||
| msgstr "Importe de la base imponible" | ||
|
|
||
| #. module: account_asset_management_extension | ||
| #: model:ir.model.fields,field_description:account_asset_management_extension.field_account_asset__invoice_move_line_id | ||
| msgid "Invoice Move Line" | ||
| msgstr "Línea de factura" | ||
|
|
||
| #. module: account_asset_management_extension | ||
| #: model:ir.model.fields,field_description:account_asset_management_extension.field_account_asset__tax_ids | ||
| msgid "Taxes" | ||
| msgstr "Impuestos" | ||
|
|
||
| #. module: account_asset_management_extension | ||
| #: model:ir.model.fields,field_description:account_asset_management_extension.field_account_asset__quantity | ||
| msgid "Quantity" | ||
| msgstr "Cantidad" | ||
|
|
||
| #. module: account_asset_management_extension | ||
| #: code:addons/account_asset_management_extension/models/account_asset.py:0 | ||
| #, python-format | ||
| msgid "Quantity in asset can't be 0" | ||
| msgstr "La cantidad del activo no puede ser 0." | ||
|
|
||
| #. module: account_asset_management_extension | ||
| #: code:addons/account_asset_management_extension/models/account_asset.py:0 | ||
| #, python-format | ||
| msgid "Invoice date must be the same as the one in the invoice: %s" | ||
| msgstr "La fecha de factura debe ser la misma que la establecida en la factura: %s" | ||
|
|
||
| #. module: account_asset_management_extension | ||
| #: code:addons/account_asset_management_extension/models/account_asset.py:0 | ||
| #, python-format | ||
| msgid "Invoice ref must be the same as the one in the invoice: %s" | ||
| msgstr "La referencia de factura debe ser la misma que la establecida en la factura: %s" | ||
|
|
||
| #. module: account_asset_management_extension | ||
| #: code:addons/account_asset_management_extension/models/account_asset.py:0 | ||
| #, python-format | ||
| msgid "Taxes must be the same as the ones in the invoice line: %s" | ||
| msgstr "Los impuestos deben ser los mismos que los establecidos en la línea de la factura: %s" | ||
|
|
||
| #. module: account_asset_management_extension | ||
| #: code:addons/account_asset_management_extension/models/account_asset.py:0 | ||
| #, python-format | ||
| msgid "Tax base amount must be the same as the one in the invoice line: %s" | ||
| msgstr "El importe de la base imponible debe ser el mismo que el establecido en la línea de factura: %s" | ||
|
|
||
| #. module: account_asset_management_extension | ||
| #: code:addons/account_asset_management_extension/models/account_asset.py:0 | ||
| #, python-format | ||
| msgid "Quantity must be the same as the one in the invoice line: %s" | ||
| msgstr "La cantidad debe ser la misma que la establecida en la línea de factura: %s" | ||
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| from . import account_asset | ||
| from . import account_move |
149 changes: 149 additions & 0 deletions
149
account_asset_management_extension/models/account_asset.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,149 @@ | ||
| # Copyright NuoBiT Solutions - Kilian Niubo <kniubo@nuobit.com> | ||
| # Copyright NuoBiT Solutions - Eric Antones <eantones@nuobit.com> | ||
| # Copyright 2025 NuoBiT Solutions - Bijaya Kumal <bkumal@nuobit.com> | ||
| # Copyright 2025 NuoBiT Solutions - Deniz Gallo <dgallo@nuobit.com> | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
|
|
||
| import json | ||
|
|
||
| from odoo import _, api, fields, models | ||
| from odoo.exceptions import ValidationError | ||
| from odoo.tools import float_compare | ||
|
|
||
|
|
||
| class AccountAsset(models.Model): | ||
| _inherit = "account.asset" | ||
|
|
||
| invoice_ref = fields.Char() | ||
| invoice_date = fields.Date() | ||
| quantity = fields.Float( | ||
| required=True, | ||
| ) | ||
| tax_base_amount = fields.Float( | ||
| compute="_compute_tax_base_amount", | ||
| readonly=False, | ||
| store=True, | ||
| ) | ||
|
|
||
| @api.depends("purchase_value") | ||
| def _compute_tax_base_amount(self): | ||
| for rec in self: | ||
| rec.tax_base_amount = rec.purchase_value | ||
|
|
||
| tax_base_amount_unit = fields.Float( | ||
| compute="_compute_tax_base_amount_unit", | ||
| ) | ||
|
|
||
| @api.model | ||
| def _get_asset_unit_price(self, amount, quantity): | ||
| if not quantity: | ||
| amount = 0 | ||
| elif abs(quantity) > 1: | ||
| prec = self.env["decimal.precision"].precision_get( | ||
| "Product Unit of Measure" | ||
| ) | ||
| if not float_compare(int(quantity), quantity, precision_digits=prec): | ||
| amount /= quantity | ||
| return amount | ||
|
|
||
| @api.depends("tax_base_amount", "quantity") | ||
| def _compute_tax_base_amount_unit(self): | ||
| for rec in self: | ||
| tax_base_amount = rec.tax_base_amount | ||
| if rec.quantity: | ||
| tax_base_amount = rec._get_asset_unit_price( | ||
| rec.tax_base_amount, rec.quantity | ||
| ) | ||
| rec.tax_base_amount_unit = tax_base_amount | ||
|
|
||
| @api.constrains("quantity") | ||
| def _check_quantity_on_asset(self): | ||
| for rec in self: | ||
| if rec.quantity == 0: | ||
| raise ValidationError(_("Quantity in asset can't be 0")) | ||
|
|
||
| @api.constrains("invoice_ref", "invoice_date", "quantity", "tax_base_amount") | ||
| def _check_invoice(self): | ||
| for rec in self: | ||
| if rec.invoice_move_line_id: | ||
| if rec.invoice_move_line_id.move_id.ref != rec.invoice_ref: | ||
| raise ValidationError( | ||
| _("Invoice ref must be the same as the one in the invoice: %s") | ||
| % rec.invoice_move_line_id.move_id.ref | ||
| ) | ||
| if rec.invoice_move_line_id.move_id.invoice_date != rec.invoice_date: | ||
| raise ValidationError( | ||
| _("Invoice date must be the same as the one in the invoice: %s") | ||
| % rec.invoice_move_line_id.move_id.invoice_date | ||
| ) | ||
| if rec.invoice_move_line_id.quantity != rec.quantity: | ||
| raise ValidationError( | ||
| _( | ||
| "Quantity must be the same" | ||
| " as the one in the invoice line: %s" | ||
| ) | ||
| % rec.invoice_move_line_id.quantity | ||
| ) | ||
| if rec.invoice_move_line_id.balance != rec.tax_base_amount: | ||
| raise ValidationError( | ||
| _( | ||
| "Tax base amount must be the same as the one in the " | ||
| "invoice line: %s" | ||
| ) | ||
| % rec.invoice_move_line_id.balance | ||
| ) | ||
| if rec.invoice_move_line_id.tax_ids != rec.tax_ids: | ||
| raise ValidationError( | ||
| _("Taxes must be the same as the ones in the invoice line: %s") | ||
| % rec.invoice_move_line_id.tax_ids.mapped("name") | ||
| ) | ||
|
|
||
| # needed for bypassing the restriction on m2m fields | ||
| # on Form class. Remove it when supported | ||
| json_tax_ids = fields.Char( | ||
| store=False, | ||
| ) | ||
|
|
||
| tax_ids = fields.Many2many( | ||
| comodel_name="account.tax", | ||
| compute="_compute_tax_ids", | ||
| store=True, | ||
| readonly=False, | ||
| ) | ||
|
|
||
| @api.depends("json_tax_ids") | ||
| def _compute_tax_ids(self): | ||
| for rec in self: | ||
| if rec.json_tax_ids: | ||
| rec.tax_ids = json.loads(rec.json_tax_ids) | ||
|
|
||
| invoice_move_line_id = fields.Many2one( | ||
| comodel_name="account.move.line", | ||
| compute="_compute_invoice_move_line_id", | ||
| store=True, | ||
| ) | ||
|
|
||
| @api.depends( | ||
| "account_move_line_ids", | ||
| "account_move_line_ids.display_type", | ||
| "account_move_line_ids.move_id", | ||
| "account_move_line_ids.move_id.move_type", | ||
| ) | ||
| def _compute_invoice_move_line_id(self): | ||
| for rec in self: | ||
| iml = rec.account_move_line_ids.filtered( | ||
| lambda x: x.move_id.move_type != "entry" | ||
| and x.display_type in ("product", "line_section", "line_note") | ||
| ) | ||
| if iml: | ||
| if len(iml) > 1: | ||
| raise ValidationError( | ||
| _( | ||
| "This asset have more than one move line linked. " | ||
| "Please, review invoices: %s" | ||
| ) | ||
| % iml.mapped("move_id").mapped("name") | ||
| ) | ||
| rec.invoice_move_line_id = iml[0] | ||
| else: | ||
| rec.invoice_move_line_id = False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # Copyright NuoBiT Solutions - Kilian Niubo <kniubo@nuobit.com> | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
|
|
||
|
|
||
| import json | ||
|
|
||
| from odoo import models | ||
|
|
||
|
|
||
| class AccountMove(models.Model): | ||
| _inherit = "account.move" | ||
|
|
||
| def _prepare_asset_vals(self, aml): | ||
| vals = super()._prepare_asset_vals(aml) | ||
| vals.update( | ||
| { | ||
| "invoice_ref": self.ref, | ||
| "invoice_date": self.invoice_date, | ||
| "quantity": aml.quantity, | ||
| "tax_base_amount": aml.balance, | ||
| "json_tax_ids": json.dumps(aml.tax_ids.ids), | ||
| } | ||
| ) | ||
| return vals |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [build-system] | ||
| requires = ["whool"] | ||
| build-backend = "whool.buildapi" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| - [NuoBiT](https://www.nuobit.com): | ||
| - Kilian Niubo <kniubo@nuobit.com> | ||
| - Eric Antones <eantones@nuobit.com> | ||
| - Bijaya Kumal <bkumal@nuobit.com> | ||
| - Deniz Gallo <dgallo@nuobit.com> | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| This module adds additional fields on assets. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The summary in the manifest should be consistent with the description in
readme/DESCRIPTION.md. The readme says 'This module adds additional fields on assets' but the manifest says 'in assets'.