Skip to content

Commit

Permalink
[IMP] account_asset_management: Add reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
luc-demeyer authored and StefanRijnhart committed Feb 9, 2021
1 parent 85c5031 commit e3dee68
Show file tree
Hide file tree
Showing 15 changed files with 1,014 additions and 6 deletions.
1 change: 1 addition & 0 deletions account_asset_management/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import models
from . import report
from . import wizard
5 changes: 3 additions & 2 deletions account_asset_management/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Copyright 2009-2018 Noviat
# Copyright 2009-2019 Noviat
# Copyright 2019 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Assets Management",
"version": "13.0.1.3.2",
"license": "AGPL-3",
"depends": ["account"],
"depends": ["account", "report_xlsx_helper"],
"excludes": ["account_asset"],
"external_dependencies": {"python": ["python-dateutil"]},
"author": "Noviat, Odoo Community Association (OCA)",
Expand All @@ -25,5 +25,6 @@
"views/account_move_line.xml",
"views/menuitem.xml",
"data/cron.xml",
"wizard/wiz_account_asset_report.xml",
],
}
82 changes: 82 additions & 0 deletions account_asset_management/models/account_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1192,3 +1192,85 @@ def _compute_entries(self, date_end, check_triggers=False):
triggers.sudo().write(recompute_vals)

return (result, error_log)

@api.model
def _xls_acquisition_fields(self):
"""
Update list in custom module to add/drop columns or change order
"""
return [
"account",
"name",
"code",
"date_start",
"depreciation_base",
"salvage_value",
]

@api.model
def _xls_active_fields(self):
"""
Update list in custom module to add/drop columns or change order
"""
return [
"account",
"name",
"code",
"date_start",
"depreciation_base",
"salvage_value",
"period_start_value",
"period_depr",
"period_end_value",
"period_end_depr",
"method",
"method_number",
"prorata",
"state",
]

@api.model
def _xls_removal_fields(self):
"""
Update list in custom module to add/drop columns or change order
"""
return [
"account",
"name",
"code",
"date_remove",
"depreciation_base",
"salvage_value",
]

@api.model
def _xls_asset_template(self):
"""
Template updates
"""
return {}

@api.model
def _xls_acquisition_template(self):
"""
Template updates
"""
return {}

@api.model
def _xls_active_template(self):
"""
Template updates
"""
return {}

@api.model
def _xls_removal_template(self):
"""
Template updates
"""
return {}
51 changes: 49 additions & 2 deletions account_asset_management/models/account_asset_group.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# Copyright 2009-2018 Noviat
# Copyright 2009-2020 Noviat
# Copyright 2019 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models
from odoo.osv import expression


class AccountAssetGroup(models.Model):
_name = "account.asset.group"
_description = "Asset Group"
_order = "name"
_order = "code, name"
_parent_store = True

name = fields.Char(string="Name", size=64, required=True, index=True)
Expand All @@ -25,7 +26,53 @@ class AccountAssetGroup(models.Model):
string="Parent Asset Group",
ondelete="restrict",
)
child_ids = fields.One2many(
comodel_name="account.asset.group",
inverse_name="parent_id",
string="Child Asset Groups",
)

@api.model
def _default_company_id(self):
return self.env.company

def name_get(self):
result = []
params = self.env.context.get("params")
list_view = params and params.get("view_type") == "list"
short_name_len = 16
for rec in self:
if rec.code:
full_name = rec.code + " " + rec.name
short_name = rec.code
else:
full_name = rec.name
if len(full_name) > short_name_len:
short_name = full_name[:16] + "..."
else:
short_name = full_name
if list_view:
name = short_name
else:
name = full_name
result.append((rec.id, name))
return result

@api.model
def _name_search(
self, name, args=None, operator="ilike", limit=100, name_get_uid=None
):
args = args or []
domain = []
if name:
domain = [
"|",
("code", "=ilike", name.split(" ")[0] + "%"),
("name", operator, name),
]
if operator in expression.NEGATIVE_TERM_OPERATORS:
domain = ["&", "!"] + domain[1:]
rec_ids = self._search(
expression.AND([domain, args]), limit=limit, access_rights_uid=name_get_uid
)
return self.browse(rec_ids).name_get()
2 changes: 0 additions & 2 deletions account_asset_management/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,5 @@ or automatically by two ways:

These options are compatibles each other.

Excel based reporting is available via the 'account_asset_management_xls' module.

The module contains a large number of functional enhancements compared to
the standard account_asset module from Odoo.
1 change: 1 addition & 0 deletions account_asset_management/report/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import account_asset_report_xls
Loading

0 comments on commit e3dee68

Please sign in to comment.