Skip to content

Commit

Permalink
[MIG] account_asset_management: Migration to version 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-lopez-tecnativa committed Jan 30, 2025
1 parent 88ef3f8 commit b4f223c
Show file tree
Hide file tree
Showing 25 changed files with 188 additions and 180 deletions.
11 changes: 6 additions & 5 deletions account_asset_management/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Assets Management
: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/17.0/account_asset_management
:target: https://github.com/OCA/account-financial-tools/tree/18.0/account_asset_management
: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-17-0/account-financial-tools-17-0-account_asset_management
:target: https://translation.odoo-community.org/projects/account-financial-tools-18-0/account-financial-tools-18-0-account_asset_management
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&target_branch=17.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -116,7 +116,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-tools/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/OCA/account-financial-tools/issues/new?body=module:%20account_asset_management%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_asset_management%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.

Expand Down Expand Up @@ -148,6 +148,7 @@ Contributors
- Pedro M. Baeza
- João Marques
- Víctor Martínez
- Carlos Lopez

- `ForgeFlow <https://www.forgeflow.com>`__:

Expand All @@ -171,6 +172,6 @@ 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 <https://github.com/OCA/account-financial-tools/tree/17.0/account_asset_management>`_ project on GitHub.
This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/18.0/account_asset_management>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion account_asset_management/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

{
"name": "Assets Management",
"version": "17.0.1.0.2",
"version": "18.0.1.0.0",
"license": "AGPL-3",
"depends": ["account", "report_xlsx_helper"],
"excludes": ["account_asset"],
Expand Down
2 changes: 0 additions & 2 deletions account_asset_management/data/cron.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
<field name="user_id" ref="base.user_root" />
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field name="active" eval="False" />
<field name="doall" eval="False" />
</record>
</odoo>
4 changes: 2 additions & 2 deletions account_asset_management/models/account_account.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2009-2017 Noviat
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.exceptions import ValidationError


Expand All @@ -23,7 +23,7 @@ def _check_asset_profile(self):
and account.asset_profile_id.account_asset_id != account
):
raise ValidationError(
_(
self.env._(
"The Asset Account defined in the Asset Profile "
"must be equal to the account."
)
Expand Down
39 changes: 23 additions & 16 deletions account_asset_management/models/account_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from dateutil.relativedelta import relativedelta

from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.exceptions import UserError

_logger = logging.getLogger(__name__)
Expand All @@ -29,6 +29,7 @@ class AccountAsset(models.Model):
_description = "Asset"
_order = "date_start desc, code, name"
_check_company_auto = True
_check_company_domain = models.check_company_domain_parent_of
_rec_names_search = ["code", "name"]

account_move_line_ids = fields.One2many(
Expand Down Expand Up @@ -362,7 +363,9 @@ def _check_method(self):
lambda a: a.method == "degr-linear" and a.method_time != "year"
):
raise UserError(
_("Degressive-Linear is only supported for Time Method = Year.")
self.env._(
"Degressive-Linear is only supported for Time Method = Year."
)
)

@api.constrains("date_start", "method_end", "method_number", "method_time")
Expand All @@ -373,13 +376,13 @@ def _check_dates(self):
and a.method_end
and a.method_end <= a.date_start
):
raise UserError(_("The Start Date must precede the Ending Date."))
raise UserError(self.env._("The Start Date must precede the Ending Date."))

@api.constrains("profile_id")
def _check_profile_change(self):
if self.depreciation_line_ids.filtered("move_id"):
raise UserError(
_(
self.env._(
"You cannot change the profile of an asset "
"with accounting entries."
)
Expand Down Expand Up @@ -448,12 +451,14 @@ def _create_first_asset_line(self):
def unlink(self):
for asset in self:
if asset.state != "draft":
raise UserError(_("You can only delete assets in draft state."))
raise UserError(
self.env._("You can only delete assets in draft state.")
)
if asset.depreciation_line_ids.filtered(
lambda r: r.type == "depreciate" and r.move_check
):
raise UserError(
_(
self.env._(
"You cannot delete an asset that contains "
"posted depreciation lines."
)
Expand Down Expand Up @@ -499,7 +504,7 @@ def remove(self):
ctx.update({"early_removal": True})

return {
"name": _("Generate Asset Removal entries"),
"name": self.env._("Generate Asset Removal entries"),
"view_mode": "form",
"res_model": "account.asset.remove",
"target": "new",
Expand All @@ -516,8 +521,8 @@ def open_entries(self):
context = dict(self.env.context)
context.pop("group_by", None)
return {
"name": _("Journal Entries"),
"view_mode": "tree,form",
"name": self.env._("Journal Entries"),
"view_mode": "list,form",
"res_model": "account.move",
"view_id": False,
"type": "ir.actions.act_window",
Expand Down Expand Up @@ -653,7 +658,7 @@ def compute_depreciation_board(self):
and total_table_lines != len(move_check_lines)
):
raise UserError(
_(
self.env._(
"The duration of the asset conflicts with the "
"posted depreciation table entry dates."
)
Expand Down Expand Up @@ -863,7 +868,7 @@ def _compute_year_amount(
"""
if self.method_time != "year":
raise UserError(
_(
self.env._(
"The '_compute_year_amount' method is only intended for "
"Time Method 'Number of Years'."
)
Expand Down Expand Up @@ -892,7 +897,9 @@ def _compute_year_amount(
else:
return year_amount_degressive
else:
raise UserError(_("Illegal value %s in asset.method.") % self.method)
raise UserError(
self.env._("Illegal value %s in asset.method.") % self.method
)

def _compute_line_dates(self, table, start_date, stop_date):
"""
Expand Down Expand Up @@ -1196,12 +1203,12 @@ def _compute_entries(self, date_end, check_triggers=False):
asset_ref = depreciation.asset_id.name
if depreciation.asset_id.code:
asset_ref = f"[{depreciation.asset_id.code}] {asset_ref}"
error_log += _(
error_log += self.env._(
"\nError while processing asset '{ref}': {exception}"
).format(ref=asset_ref, exception=str(e))
error_msg = _("Error while processing asset '{ref}': \n\n{tb}").format(
ref=asset_ref, tb=tb
)
error_msg = self.env._(
"Error while processing asset '{ref}': \n\n{tb}"
).format(ref=asset_ref, tb=tb)
_logger.error("%s, %s", self._name, error_msg)

if check_triggers and recomputes:
Expand Down
3 changes: 2 additions & 1 deletion account_asset_management/models/account_asset_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ class AccountAssetGroup(models.Model):
_order = "code, name"
_parent_store = True
_check_company_auto = True
_check_company_domain = models.check_company_domain_parent_of
_rec_names_search = ["code", "name"]

name = fields.Char(size=64, required=True, index=True)
code = fields.Char(index=True)
parent_path = fields.Char(index=True, unaccent=False)
parent_path = fields.Char(index=True)
company_id = fields.Many2one(
comodel_name="res.company",
string="Company",
Expand Down
23 changes: 13 additions & 10 deletions account_asset_management/models/account_asset_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright 2021 Tecnativa - João Marques
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.exceptions import UserError


Expand All @@ -11,6 +11,7 @@ class AccountAssetLine(models.Model):
_description = "Asset depreciation table line"
_order = "type, line_date"
_check_company_auto = True
_check_company_domain = models.check_company_domain_parent_of

name = fields.Char(string="Depreciation Name", size=64, readonly=True)
asset_id = fields.Many2one(
Expand Down Expand Up @@ -132,7 +133,7 @@ def write(self, vals):
# 'Delete Move' button on the depreciation lines.
if not self.env.context.get("unlink_from_asset"):
raise UserError(
_(
self.env._(
"You are not allowed to remove an accounting entry "
"linked to an asset."
"\nYou should remove such entries from the asset."
Expand All @@ -146,7 +147,7 @@ def write(self, vals):
and dl.type != "create"
):
raise UserError(
_(
self.env._(
"You cannot change a depreciation line "
"with an associated accounting entry."
)
Expand All @@ -159,7 +160,7 @@ def write(self, vals):
)
if check:
raise UserError(
_(
self.env._(
"You cannot set the 'Initial Balance Entry' flag "
"on a depreciation line "
"with prior posted entries."
Expand All @@ -174,7 +175,7 @@ def write(self, vals):
)
if check:
raise UserError(
_(
self.env._(
"You cannot set the Asset Start Date "
"after already posted entries."
)
Expand All @@ -187,7 +188,7 @@ def write(self, vals):
)
if check:
raise UserError(
_(
self.env._(
"You cannot set the date on a depreciation line "
"prior to already posted entries."
)
Expand All @@ -198,11 +199,13 @@ def unlink(self):
for dl in self:
if dl.type == "create" and dl.amount:
raise UserError(
_("You cannot remove an asset line of type 'Depreciation Base'.")
self.env._(
"You cannot remove an asset line of type 'Depreciation Base'."
)
)
elif dl.move_id:
raise UserError(
_(
self.env._(
"You cannot delete a depreciation line with "
"an associated accounting entry."
)
Expand Down Expand Up @@ -287,7 +290,7 @@ def create_move(self):
def open_move(self):
self.ensure_one()
return {
"name": _("Journal Entry"),
"name": self.env._("Journal Entry"),
"view_mode": "form",
"res_id": self.move_id.id,
"res_model": "account.move",
Expand Down Expand Up @@ -316,7 +319,7 @@ def unlink_move(self):
}
)
return {
"name": _("Reverse Move"),
"name": self.env._("Reverse Move"),
"view_mode": "form",
"res_model": "wiz.asset.move.reverse",
"target": "new",
Expand Down
Loading

0 comments on commit b4f223c

Please sign in to comment.