diff --git a/account_asset_management/README.rst b/account_asset_management/README.rst
index ea273c5b6a7..45eca40e263 100644
--- a/account_asset_management/README.rst
+++ b/account_asset_management/README.rst
@@ -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|
@@ -116,7 +116,7 @@ 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 to smash it by providing a detailed and welcomed
-`feedback `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -148,6 +148,7 @@ Contributors
- Pedro M. Baeza
- João Marques
- Víctor Martínez
+ - Carlos Lopez
- `ForgeFlow `__:
@@ -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 `_ project on GitHub.
+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_management/__manifest__.py b/account_asset_management/__manifest__.py
index 9afd3522a40..9f5fe5d1aef 100644
--- a/account_asset_management/__manifest__.py
+++ b/account_asset_management/__manifest__.py
@@ -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"],
diff --git a/account_asset_management/data/cron.xml b/account_asset_management/data/cron.xml
index 580c07a4d3f..f91b38c9538 100644
--- a/account_asset_management/data/cron.xml
+++ b/account_asset_management/data/cron.xml
@@ -8,8 +8,6 @@
1
days
- -1
-
diff --git a/account_asset_management/models/account_account.py b/account_asset_management/models/account_account.py
index 3e7104c9c9d..437ba2cb172 100644
--- a/account_asset_management/models/account_account.py
+++ b/account_asset_management/models/account_account.py
@@ -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
@@ -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."
)
diff --git a/account_asset_management/models/account_asset.py b/account_asset_management/models/account_asset.py
index 9551727cddb..ad618767d38 100644
--- a/account_asset_management/models/account_asset.py
+++ b/account_asset_management/models/account_asset.py
@@ -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__)
@@ -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(
@@ -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")
@@ -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."
)
@@ -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."
)
@@ -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",
@@ -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",
@@ -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."
)
@@ -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'."
)
@@ -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):
"""
@@ -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:
diff --git a/account_asset_management/models/account_asset_group.py b/account_asset_management/models/account_asset_group.py
index 996509efdbb..57fc0f21519 100644
--- a/account_asset_management/models/account_asset_group.py
+++ b/account_asset_management/models/account_asset_group.py
@@ -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",
diff --git a/account_asset_management/models/account_asset_line.py b/account_asset_management/models/account_asset_line.py
index 87a67a0d0ce..e97b86659e8 100644
--- a/account_asset_management/models/account_asset_line.py
+++ b/account_asset_management/models/account_asset_line.py
@@ -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
@@ -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(
@@ -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."
@@ -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."
)
@@ -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."
@@ -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."
)
@@ -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."
)
@@ -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."
)
@@ -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",
@@ -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",
diff --git a/account_asset_management/models/account_asset_profile.py b/account_asset_management/models/account_asset_profile.py
index a6be523fb93..839e2dc7952 100644
--- a/account_asset_management/models/account_asset_profile.py
+++ b/account_asset_management/models/account_asset_profile.py
@@ -1,7 +1,7 @@
# Copyright 2009-2018 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 UserError
@@ -9,6 +9,7 @@ class AccountAssetProfile(models.Model):
_name = "account.asset.profile"
_inherit = "analytic.mixin"
_check_company_auto = True
+ _check_company_domain = models.check_company_domain_parent_of
_description = "Asset profile"
_order = "name"
@@ -16,40 +17,40 @@ class AccountAssetProfile(models.Model):
note = fields.Text()
account_asset_id = fields.Many2one(
comodel_name="account.account",
- domain="[('deprecated', '=', False), ('company_id', '=', company_id)]",
+ domain=[("deprecated", "=", False)],
string="Asset Account",
check_company=True,
required=True,
)
account_depreciation_id = fields.Many2one(
comodel_name="account.account",
- domain="[('deprecated', '=', False), ('company_id', '=', company_id)]",
+ domain=[("deprecated", "=", False)],
string="Depreciation Account",
check_company=True,
required=True,
)
account_expense_depreciation_id = fields.Many2one(
comodel_name="account.account",
- domain="[('deprecated', '=', False), ('company_id', '=', company_id)]",
+ domain=[("deprecated", "=", False)],
string="Depr. Expense Account",
check_company=True,
required=True,
)
account_plus_value_id = fields.Many2one(
comodel_name="account.account",
- domain="[('deprecated', '=', False), ('company_id', '=', company_id)]",
+ domain=[("deprecated", "=", False)],
check_company=True,
string="Plus-Value Account",
)
account_min_value_id = fields.Many2one(
comodel_name="account.account",
- domain="[('deprecated', '=', False), ('company_id', '=', company_id)]",
+ domain=[("deprecated", "=", False)],
check_company=True,
string="Min-Value Account",
)
account_residual_value_id = fields.Many2one(
comodel_name="account.account",
- domain="[('deprecated', '=', False), ('company_id', '=', company_id)]",
+ domain=[("deprecated", "=", False)],
check_company=True,
string="Residual Value Account",
)
@@ -171,29 +172,35 @@ def _default_company_id(self):
@api.model
def _selection_method(self):
return [
- ("linear", _("Linear")),
- ("linear-limit", _("Linear up to Salvage Value")),
- ("degressive", _("Degressive")),
- ("degr-linear", _("Degressive-Linear")),
- ("degr-limit", _("Degressive up to Salvage Value")),
+ ("linear", self.env._("Linear")),
+ ("linear-limit", self.env._("Linear up to Salvage Value")),
+ ("degressive", self.env._("Degressive")),
+ ("degr-linear", self.env._("Degressive-Linear")),
+ ("degr-limit", self.env._("Degressive up to Salvage Value")),
]
@api.model
def _selection_method_period(self):
- return [("month", _("Month")), ("quarter", _("Quarter")), ("year", _("Year"))]
+ return [
+ ("month", self.env._("Month")),
+ ("quarter", self.env._("Quarter")),
+ ("year", self.env._("Year")),
+ ]
@api.model
def _selection_method_time(self):
return [
- ("year", _("Number of Years or end date")),
- ("number", _("Number of Depreciations")),
+ ("year", self.env._("Number of Years or end date")),
+ ("number", self.env._("Number of Depreciations")),
]
@api.constrains("method", "method_time")
def _check_method(self):
if any(a.method == "degr-linear" and a.method_time != "year" for a in self):
raise UserError(
- _("Degressive-Linear is only supported for Time Method = Year.")
+ self.env._(
+ "Degressive-Linear is only supported for Time Method = Year."
+ )
)
@api.depends("method_time")
diff --git a/account_asset_management/models/account_move.py b/account_asset_management/models/account_move.py
index 75361e5361b..82d5a113f3f 100644
--- a/account_asset_management/models/account_move.py
+++ b/account_asset_management/models/account_move.py
@@ -3,15 +3,12 @@
# Copyright 2021 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-import logging
from markupsafe import Markup
-from odoo import _, api, fields, models
+from odoo import api, fields, models
from odoo.exceptions import UserError
-from odoo.tests.common import Form
-
-_logger = logging.getLogger(__name__)
+from odoo.tests import Form
# List of move's fields that can't be modified if move is linked
# with a depreciation line
@@ -53,7 +50,7 @@ def unlink(self):
)
if deprs and 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."
@@ -72,7 +69,7 @@ def write(self, vals):
)
if deprs:
raise UserError(
- _(
+ self.env._(
"You cannot change an accounting entry "
"linked to an asset depreciation line."
)
@@ -98,7 +95,7 @@ def action_post(self):
):
if not aml.name:
raise UserError(
- _("Asset name must be set in the label of the line.")
+ self.env._("Asset name must be set in the label of the line.")
)
if aml.asset_id:
continue
@@ -119,10 +116,11 @@ def action_post(self):
for asset in move.line_ids.filtered("asset_profile_id").asset_id:
new_name_get = [asset.id, asset.display_name]
if new_name_get:
- message = _(
+ message = self.env._(
"This invoice created the asset(s): %s",
Markup(
- f"""{new_name_get[1]} """
),
)
@@ -210,7 +208,7 @@ def create(self, vals_list):
if not move.is_sale_document():
if vals.get("asset_id") and not self.env.context.get("allow_asset"):
raise UserError(
- _(
+ self.env._(
"You are not allowed to link "
"an accounting entry to an asset."
"\nYou should generate such entries from the asset."
@@ -232,7 +230,7 @@ def write(self, vals):
linked_asset = move_line.asset_id
if linked_asset:
raise UserError(
- _(
+ self.env._(
"You cannot change an accounting item "
"linked to an asset depreciation line."
)
@@ -244,7 +242,7 @@ def write(self, vals):
and not self.env.context.get("allow_asset")
):
raise UserError(
- _(
+ self.env._(
"You are not allowed to link "
"an accounting entry to an asset."
"\nYou should generate such entries from the asset."
diff --git a/account_asset_management/readme/CONTRIBUTORS.md b/account_asset_management/readme/CONTRIBUTORS.md
index 33ed0f08153..9c77641c634 100644
--- a/account_asset_management/readme/CONTRIBUTORS.md
+++ b/account_asset_management/readme/CONTRIBUTORS.md
@@ -14,6 +14,7 @@
- Pedro M. Baeza
- João Marques
- Víctor Martínez
+ - Carlos Lopez
- [ForgeFlow](https://www.forgeflow.com):
- Jordi Ballester \<\>
- Miquel Raïch \<\>
diff --git a/account_asset_management/report/account_asset_report_xls.py b/account_asset_management/report/account_asset_report_xls.py
index 81fde8319cd..5e2ef3d4127 100644
--- a/account_asset_management/report/account_asset_report_xls.py
+++ b/account_asset_management/report/account_asset_report_xls.py
@@ -1,9 +1,8 @@
# Copyright 2009-2019 Noviat
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-import logging
-from odoo import _, models
+from odoo import models
from odoo.exceptions import UserError
from odoo.addons.report_xlsx_helper.report.report_xlsx_format import (
@@ -11,9 +10,6 @@
XLS_HEADERS,
)
-_logger = logging.getLogger(__name__)
-
-
IR_TRANSLATION_NAME = "account.asset.report"
@@ -32,18 +28,18 @@ def _get_ws_params(self, wb, data, wiz):
def _get_asset_template(self):
asset_template = {
"account": {
- "header": {"type": "string", "value": _("Account")},
+ "header": {"type": "string", "value": self.env._("Account")},
"asset": {
"type": "string",
"value": self._render(
"asset.profile_id.account_asset_id.code or ''"
),
},
- "totals": {"type": "string", "value": _("Totals")},
+ "totals": {"type": "string", "value": self.env._("Totals")},
"width": 20,
},
"name": {
- "header": {"type": "string", "value": _("Name")},
+ "header": {"type": "string", "value": self.env._("Name")},
"asset_group": {
"type": "string",
"value": self._render("group.name or ''"),
@@ -52,7 +48,7 @@ def _get_asset_template(self):
"width": 40,
},
"code": {
- "header": {"type": "string", "value": _("Reference")},
+ "header": {"type": "string", "value": self.env._("Reference")},
"asset_group": {
"type": "string",
"value": self._render("group.code or ''"),
@@ -61,7 +57,7 @@ def _get_asset_template(self):
"width": 20,
},
"date_start": {
- "header": {"type": "string", "value": _("Asset Start Date")},
+ "header": {"type": "string", "value": self.env._("Asset Start Date")},
"asset": {
"value": self._render("asset.date_start or ''"),
"format": FORMATS["format_tcell_date_left"],
@@ -69,7 +65,7 @@ def _get_asset_template(self):
"width": 20,
},
"date_remove": {
- "header": {"type": "string", "value": _("Asset Removal Date")},
+ "header": {"type": "string", "value": self.env._("Asset Removal Date")},
"asset": {
"value": self._render("asset.date_remove or ''"),
"format": FORMATS["format_tcell_date_left"],
@@ -79,7 +75,7 @@ def _get_asset_template(self):
"depreciation_base": {
"header": {
"type": "string",
- "value": _("Depreciation Base"),
+ "value": self.env._("Depreciation Base"),
"format": FORMATS["format_theader_yellow_right"],
},
"asset_group": {
@@ -102,7 +98,7 @@ def _get_asset_template(self):
"salvage_value": {
"header": {
"type": "string",
- "value": _("Salvage Value"),
+ "value": self.env._("Salvage Value"),
"format": FORMATS["format_theader_yellow_right"],
},
"asset_group": {
@@ -125,7 +121,7 @@ def _get_asset_template(self):
"purchase_value": {
"header": {
"type": "string",
- "value": _("Purchase Value"),
+ "value": self.env._("Purchase Value"),
"format": FORMATS["format_theader_yellow_right"],
},
"asset_group": {
@@ -148,7 +144,7 @@ def _get_asset_template(self):
"period_start_value": {
"header": {
"type": "string",
- "value": _("Period Start Value"),
+ "value": self.env._("Period Start Value"),
"format": FORMATS["format_theader_yellow_right"],
},
"asset_group": {
@@ -171,7 +167,7 @@ def _get_asset_template(self):
"period_depr": {
"header": {
"type": "string",
- "value": _("Period Depreciation"),
+ "value": self.env._("Period Depreciation"),
"format": FORMATS["format_theader_yellow_right"],
},
"asset_group": {
@@ -194,7 +190,7 @@ def _get_asset_template(self):
"period_end_value": {
"header": {
"type": "string",
- "value": _("Period End Value"),
+ "value": self.env._("Period End Value"),
"format": FORMATS["format_theader_yellow_right"],
},
"asset_group": {
@@ -217,7 +213,7 @@ def _get_asset_template(self):
"period_end_depr": {
"header": {
"type": "string",
- "value": _("Tot. Depreciation"),
+ "value": self.env._("Tot. Depreciation"),
"format": FORMATS["format_theader_yellow_right"],
},
"asset_group": {
@@ -240,7 +236,7 @@ def _get_asset_template(self):
"method": {
"header": {
"type": "string",
- "value": _("Comput. Method"),
+ "value": self.env._("Comput. Method"),
"format": FORMATS["format_theader_yellow_center"],
},
"asset": {
@@ -253,7 +249,7 @@ def _get_asset_template(self):
"method_number": {
"header": {
"type": "string",
- "value": _("Number of Years"),
+ "value": self.env._("Number of Years"),
"format": FORMATS["format_theader_yellow_center"],
},
"asset": {
@@ -266,7 +262,7 @@ def _get_asset_template(self):
"prorata": {
"header": {
"type": "string",
- "value": _("Prorata Temporis"),
+ "value": self.env._("Prorata Temporis"),
"format": FORMATS["format_theader_yellow_center"],
},
"asset": {
@@ -279,7 +275,7 @@ def _get_asset_template(self):
"state": {
"header": {
"type": "string",
- "value": _("Status"),
+ "value": self.env._("Status"),
"format": FORMATS["format_theader_yellow_center"],
},
"asset": {
@@ -351,17 +347,17 @@ def _get_title(self, wiz, report, frmt="normal"):
prefix = f"{wiz.date_from} - {wiz.date_to}"
if report == "acquisition":
if frmt == "normal":
- title = prefix + " : " + _("New Acquisitions")
+ title = prefix + " : " + self.env._("New Acquisitions")
else:
title = "ACQ"
elif report == "active":
if frmt == "normal":
- title = prefix + " : " + _("Active Assets")
+ title = prefix + " : " + self.env._("Active Assets")
else:
title = "ACT"
else:
if frmt == "normal":
- title = prefix + " : " + _("Removed Assets")
+ title = prefix + " : " + self.env._("Removed Assets")
else:
title = "DSP"
return title
@@ -372,12 +368,12 @@ def _report_title(self, ws, row_pos, ws_params, data, wiz):
def _empty_report(self, ws, row_pos, ws_params, data, wiz):
report = ws_params["report_type"]
if report == "acquisition":
- suffix = _("New Acquisitions")
+ suffix = self.env._("New Acquisitions")
elif report == "active":
- suffix = _("Active Assets")
+ suffix = self.env._("Active Assets")
else:
- suffix = _("Removed Assets")
- no_entries = _("No") + " " + suffix
+ suffix = self.env._("Removed Assets")
+ no_entries = self.env._("No") + " " + suffix
ws.write_string(row_pos, 0, no_entries, FORMATS["format_left_bold"])
def _get_assets(self, wiz, data):
@@ -399,7 +395,7 @@ def _child_get(parent):
for child in children:
if child in groups:
raise UserError(
- _(
+ self.env._(
"Inconsistent reporting structure."
"\nPlease correct Asset Group '{group}' (id {id})"
).format(group=child.name, id=child.id)
@@ -542,7 +538,7 @@ def _asset_report(self, workbook, ws, ws_params, data, wiz):
wl = ws_params["wanted_list"]
if "account" not in wl:
raise UserError(
- _(
+ self.env._(
"The 'account' field is a mandatory entry of the "
"'_xls_%s_fields' list !"
)
@@ -716,15 +712,15 @@ def asset_filter(asset):
for k in error_dict:
if error_dict[k]:
if k == "no_table":
- reason = _("Missing depreciation table")
+ reason = self.env._("Missing depreciation table")
elif k == "dups":
- reason = _("Duplicate reporting entries")
+ reason = self.env._("Duplicate reporting entries")
else:
- reason = _("Undetermined error")
+ reason = self.env._("Undetermined error")
row_pos += 1
- err_msg = _("Assets to be corrected") + ": "
+ err_msg = self.env._("Assets to be corrected") + ": "
err_msg += "%s" % [
x[1] for x in [(error_dict[k].id, error_dict[k].display_name)]
]
- err_msg += " - " + _("Reason") + ": " + reason
+ err_msg += " - " + self.env._("Reason") + ": " + reason
ws.write_string(row_pos, 0, err_msg, FORMATS["format_left_bold"])
diff --git a/account_asset_management/security/account_asset_security.xml b/account_asset_management/security/account_asset_security.xml
index 00201502c6f..3c1a54afac1 100644
--- a/account_asset_management/security/account_asset_security.xml
+++ b/account_asset_management/security/account_asset_security.xml
@@ -4,24 +4,18 @@
Account Asset Profile multi-company
- ['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]
+ [('company_id', 'in', company_ids)]
Account Asset multi-company
- ['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]
+ [('company_id', 'in', company_ids)]
Account Asset Group multi-company
- ['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]
+ [('company_id', 'in', company_ids)]
diff --git a/account_asset_management/static/description/index.html b/account_asset_management/static/description/index.html
index a40962a64f5..b17a0f073a5 100644
--- a/account_asset_management/static/description/index.html
+++ b/account_asset_management/static/description/index.html
@@ -369,7 +369,7 @@ Assets Management
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:0f553e3c80a7b598bf5b0dd0646fd937d7da71cae697eae6c6fee4e050d07c97
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-
+
This Module manages the assets owned by a company. It will keep track of
depreciation’s occurred on those assets. And it allows to create
accounting entries from the depreciation lines.
@@ -476,7 +476,7 @@
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 to smash it by providing a detailed and welcomed
-feedback .
+feedback .
Do not contact contributors directly about support or help with technical issues.
@@ -506,6 +506,7 @@
Pedro M. Baeza
João Marques
Víctor Martínez
+
Carlos Lopez
ForgeFlow :
diff --git a/account_asset_management/tests/test_account_asset_management.py b/account_asset_management/tests/test_account_asset_management.py
index 19e356df218..bf1eb58527a 100644
--- a/account_asset_management/tests/test_account_asset_management.py
+++ b/account_asset_management/tests/test_account_asset_management.py
@@ -8,8 +8,7 @@
from datetime import date, datetime
from odoo import Command, fields
-from odoo.tests import tagged
-from odoo.tests.common import Form
+from odoo.tests import Form, tagged
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
@@ -884,7 +883,7 @@ def test_18_reverse_entries(self):
ict0.invalidate_recordset()
self.assertEqual(ict0.value_depreciated, 500)
self.assertEqual(ict0.value_residual, 1000)
- self.assertEqual(len(original_move.reversal_move_id), 0)
+ self.assertEqual(len(original_move.reversal_move_ids), 0)
def test_19_unlink_entries(self):
"""Test that cancelling a posted entry creates a reversal, if the
diff --git a/account_asset_management/tests/test_asset_management_xls.py b/account_asset_management/tests/test_asset_management_xls.py
index 582035c7b63..628e928ac01 100644
--- a/account_asset_management/tests/test_asset_management_xls.py
+++ b/account_asset_management/tests/test_asset_management_xls.py
@@ -82,7 +82,8 @@ def test_01_action_xls(self):
"report_name": self.xls_report_name,
}.items(),
)
- model = self.env["report.%s" % self.report_action["report_name"]].with_context(
+ report_model = f"report.{self.report_action['report_name']}"
+ model = self.env[report_model].with_context(
active_model=self.xls_report._name, **self.report_action["context"]
)
model.create_xlsx_report(self.xls_report.ids, data=self.report_action["data"])
diff --git a/account_asset_management/views/account_asset.xml b/account_asset_management/views/account_asset.xml
index c81e53766d8..a54c952e7a9 100644
--- a/account_asset_management/views/account_asset.xml
+++ b/account_asset_management/views/account_asset.xml
@@ -4,7 +4,7 @@
account.asset.form
account.asset
-
- account.asset.group.tree
+ account.asset.group.list
account.asset.group
-
+
@@ -36,7 +36,7 @@
options="{'no_create': True}"
groups="base.group_multi_company"
/>
-
+
@@ -53,6 +53,6 @@
Asset Groups
account.asset.group
- tree,form
+ list,form
diff --git a/account_asset_management/views/account_asset_profile.xml b/account_asset_management/views/account_asset_profile.xml
index 83c25588c69..992ae87551a 100644
--- a/account_asset_management/views/account_asset_profile.xml
+++ b/account_asset_management/views/account_asset_profile.xml
@@ -4,7 +4,7 @@
account.asset.profile.form
account.asset.profile
-
+
@@ -78,10 +78,10 @@
- account.asset.profile.tree
+ account.asset.profile.list
account.asset.profile
-
+
@@ -98,14 +98,14 @@
groups="base.group_multi_company"
optional="show"
/>
-
+
account.asset.profile.search
account.asset.profile
-
+
@@ -127,6 +127,6 @@
Asset Profiles
account.asset.profile
- tree,form
+ list,form
diff --git a/account_asset_management/views/account_move.xml b/account_asset_management/views/account_move.xml
index 0f058507a05..b1e41eac2a2 100644
--- a/account_asset_management/views/account_move.xml
+++ b/account_asset_management/views/account_move.xml
@@ -23,7 +23,7 @@
account.asset.compute
account.asset.compute
-
+
account.asset.compute
20
-
+
@@ -46,7 +46,7 @@
Compute Assets
account.asset.compute
- tree,form
+ list,form
new
diff --git a/account_asset_management/wizard/account_asset_remove.py b/account_asset_management/wizard/account_asset_remove.py
index f55f88a32e5..5ee4ef869b7 100644
--- a/account_asset_management/wizard/account_asset_remove.py
+++ b/account_asset_management/wizard/account_asset_remove.py
@@ -2,20 +2,18 @@
# Copyright 2021 Tecnativa - João Marques
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-import logging
from dateutil.relativedelta import relativedelta
-from odoo import _, api, fields, models
+from odoo import api, fields, models
from odoo.exceptions import UserError, ValidationError
-_logger = logging.getLogger(__name__)
-
class AccountAssetRemove(models.TransientModel):
_name = "account.asset.remove"
_description = "Remove Asset"
_check_company_auto = True
+ _check_company_domain = models.check_company_domain_parent_of
company_id = fields.Many2one(
comodel_name="res.company",
@@ -41,25 +39,29 @@ class AccountAssetRemove(models.TransientModel):
account_sale_id = fields.Many2one(
comodel_name="account.account",
string="Asset Sale Account",
- domain="[('deprecated', '=', False), ('company_id', '=', company_id)]",
+ domain=[("deprecated", "=", False)],
+ check_company=True,
default=lambda self: self._default_account_sale_id(),
)
account_plus_value_id = fields.Many2one(
comodel_name="account.account",
string="Plus-Value Account",
- domain="[('deprecated', '=', False), ('company_id', '=', company_id)]",
+ domain=[("deprecated", "=", False)],
+ check_company=True,
default=lambda self: self._default_account_plus_value_id(),
)
account_min_value_id = fields.Many2one(
comodel_name="account.account",
string="Min-Value Account",
- domain="[('deprecated', '=', False), ('company_id', '=', company_id)]",
+ domain=[("deprecated", "=", False)],
+ check_company=True,
default=lambda self: self._default_account_min_value_id(),
)
account_residual_value_id = fields.Many2one(
comodel_name="account.account",
string="Residual Value Account",
- domain="[('deprecated', '=', False), ('company_id', '=', company_id)]",
+ domain=[("deprecated", "=", False)],
+ check_company=True,
default=lambda self: self._default_account_residual_value_id(),
)
posting_regime = fields.Selection(
@@ -78,7 +80,7 @@ class AccountAssetRemove(models.TransientModel):
@api.constrains("sale_value", "company_id")
def _check_sale_value(self):
if self.company_id.currency_id.compare_amounts(self.sale_value, 0) < 0:
- raise ValidationError(_("The Sale Value must be positive!"))
+ raise ValidationError(self.env._("The Sale Value must be positive!"))
@api.model
def _default_company_id(self):
@@ -138,8 +140,8 @@ def _default_account_residual_value_id(self):
@api.model
def _selection_posting_regime(self):
return [
- ("residual_value", _("Residual Value")),
- ("gain_loss_on_sale", _("Gain/Loss on Sale")),
+ ("residual_value", self.env._("Residual Value")),
+ ("gain_loss_on_sale", self.env._("Gain/Loss on Sale")),
]
@api.model
@@ -186,7 +188,9 @@ def remove(self):
if self.date_remove < last_date:
raise UserError(
- _("The removal date must be after " "the last depreciation date.")
+ self.env._(
+ "The removal date must be after " "the last depreciation date."
+ )
)
line_name = asset._get_depreciation_entry_name(len(dlines) + 1)
@@ -222,8 +226,8 @@ def remove(self):
move.with_context(allow_asset=True).write({"line_ids": move_lines})
return {
- "name": _("Asset '%s' Removal Journal Entry") % asset_ref,
- "view_mode": "tree,form",
+ "name": self.env._("Asset '%s' Removal Journal Entry", asset_ref),
+ "view_mode": "list,form",
"res_model": "account.move",
"view_id": False,
"type": "ir.actions.act_window",
@@ -261,7 +265,7 @@ def _dlines(asset):
first_date = first_to_depreciate_dl.line_date
if date_remove > first_date:
raise UserError(
- _(
+ self.env._(
"You can't make an early removal if all the depreciation "
"lines for previous periods are not posted."
)
diff --git a/account_asset_management/wizard/account_asset_remove.xml b/account_asset_management/wizard/account_asset_remove.xml
index f65316ea6ce..d9ee3efecd4 100644
--- a/account_asset_management/wizard/account_asset_remove.xml
+++ b/account_asset_management/wizard/account_asset_remove.xml
@@ -4,7 +4,7 @@
account.asset.remove.form
account.asset.remove
-
+
diff --git a/account_asset_management/wizard/wiz_account_asset_report.py b/account_asset_management/wizard/wiz_account_asset_report.py
index 986913d85b9..110dc8bd995 100644
--- a/account_asset_management/wizard/wiz_account_asset_report.py
+++ b/account_asset_management/wizard/wiz_account_asset_report.py
@@ -3,7 +3,7 @@
import unicodedata
-from odoo import _, api, fields, models
+from odoo import api, fields, models
from odoo.exceptions import UserError
@@ -48,7 +48,9 @@ def _onchange_company_id(self):
def _check_dates(self):
for wiz in self:
if wiz.date_to <= wiz.date_from:
- raise UserError(_("The Start Date must precede the Ending Date."))
+ raise UserError(
+ self.env._("The Start Date must precede the Ending Date.")
+ )
def xls_export(self):
self.ensure_one()
diff --git a/account_asset_management/wizard/wiz_account_asset_report.xml b/account_asset_management/wizard/wiz_account_asset_report.xml
index 6f4a13a7a3a..fca10bd6c7c 100644
--- a/account_asset_management/wizard/wiz_account_asset_report.xml
+++ b/account_asset_management/wizard/wiz_account_asset_report.xml
@@ -4,7 +4,7 @@
Financial Assets report
wiz.account.asset.report
-
+
+
+