Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions account_asset_management_extension/README.rst
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.
1 change: 1 addition & 0 deletions account_asset_management_extension/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions account_asset_management_extension/__manifest__.py
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",
Copy link

Copilot AI Oct 9, 2025

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'.

Copilot generated this review using guidance from repository custom instructions.
"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",
],
}
97 changes: 97 additions & 0 deletions account_asset_management_extension/i18n/es.po
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"
Copy link

Copilot AI Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .po file is missing a blank line at the end of the file as required by coding guidelines.

Copilot generated this review using guidance from repository custom instructions.
2 changes: 2 additions & 0 deletions account_asset_management_extension/models/__init__.py
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 account_asset_management_extension/models/account_asset.py
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
24 changes: 24 additions & 0 deletions account_asset_management_extension/models/account_move.py
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
3 changes: 3 additions & 0 deletions account_asset_management_extension/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
6 changes: 6 additions & 0 deletions account_asset_management_extension/readme/CONTRIBUTORS.md
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>

1 change: 1 addition & 0 deletions account_asset_management_extension/readme/DESCRIPTION.md
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.
Loading
Loading