From b1d10d53badb6f830cb2113e37d63baafa88f03f Mon Sep 17 00:00:00 2001 From: Akim Juillerat Date: Mon, 15 Oct 2018 15:41:00 +0200 Subject: [PATCH] Second round of improvements --- account_asset_management/models/__init__.py | 2 +- account_asset_management/models/account_asset.py | 2 +- .../models/account_asset_line.py | 14 ++++---------- account_asset_management/models/account_invoice.py | 6 ++---- .../{res_config.py => res_config_settings.py} | 0 account_asset_management/readme/DESCRIPTION.rst | 2 +- .../tests/account_asset_test_data.xml | 2 +- account_asset_management/views/account_account.xml | 2 +- account_asset_management/views/account_asset.xml | 7 ++++--- .../views/account_asset_profile.xml | 5 +++-- account_asset_management/views/account_invoice.xml | 2 +- .../views/account_invoice_line.xml | 2 +- account_asset_management/views/account_move.xml | 2 +- .../views/account_move_line.xml | 2 +- account_asset_management/views/menuitem.xml | 2 +- 15 files changed, 23 insertions(+), 29 deletions(-) rename account_asset_management/models/{res_config.py => res_config_settings.py} (100%) diff --git a/account_asset_management/models/__init__.py b/account_asset_management/models/__init__.py index fdd6c0980..f7fea15d6 100644 --- a/account_asset_management/models/__init__.py +++ b/account_asset_management/models/__init__.py @@ -6,4 +6,4 @@ from . import account_asset_recompute_trigger from . import account_invoice from . import account_move from . import date_range -from . import res_config +from . import res_config_settings diff --git a/account_asset_management/models/account_asset.py b/account_asset_management/models/account_asset.py index db6524f2d..f689e8c87 100644 --- a/account_asset_management/models/account_asset.py +++ b/account_asset_management/models/account_asset.py @@ -106,7 +106,7 @@ class AccountAsset(models.Model): ('open', 'Running'), ('close', 'Close'), ('removed', 'Removed'), - ], string='Status', required=True, default='draft', copy='draft', + ], string='Status', required=True, default='draft', copy=False, help="When an asset is created, the status is 'Draft'.\n" "If the asset is confirmed, the status goes in 'Running' " "and the depreciation lines can be posted " diff --git a/account_asset_management/models/account_asset_line.py b/account_asset_management/models/account_asset_line.py index 4387660b5..779e8418f 100644 --- a/account_asset_management/models/account_asset_line.py +++ b/account_asset_management/models/account_asset_line.py @@ -22,11 +22,6 @@ class AccountAssetLine(models.Model): string='Previous Depreciation Line', readonly=True) parent_state = fields.Selection( - selection=[ - ('draft', 'Draft'), - ('open', 'Running'), - ('close', 'Close'), - ('removed', 'Removed')], related='asset_id.state', string='State of Asset', readonly=True, @@ -66,17 +61,16 @@ class AccountAssetLine(models.Model): init_entry = fields.Boolean( string='Initial Balance Entry', help="Set this flag for entries of previous fiscal years " - "for which OpenERP has not generated accounting entries.") + "for which Odoo has not generated accounting entries.") @api.depends('amount', 'previous_id', 'type') @api.multi def _compute_values(self): - dlines = self if self.env.context.get('no_compute_asset_line_ids'): # skip compute for lines in unlink exclude_ids = self.env.context['no_compute_asset_line_ids'] - dlines = dlines.filtered(lambda l: l.id not in exclude_ids) - dlines = self.filtered(lambda l: l.type == 'depreciate') + dlines = self.filtered(lambda l: l.id not in exclude_ids) + dlines = dlines.filtered(lambda l: l.type == 'depreciate') dlines = dlines.sorted(key=lambda l: l.line_date) for i, dl in enumerate(dlines): @@ -240,7 +234,7 @@ class AccountAssetLine(models.Model): asset_ids.add(asset.id) # we re-evaluate the assets to determine if we can close them for asset in self.env['account.asset'].browse(list(asset_ids)): - if asset.company_id.currency_id.is_zero(asset.value_residual): + if asset.company_currency_id.is_zero(asset.value_residual): asset.state = 'close' return created_move_ids diff --git a/account_asset_management/models/account_invoice.py b/account_asset_management/models/account_invoice.py index 868b2310f..188bbe1fb 100644 --- a/account_asset_management/models/account_invoice.py +++ b/account_asset_management/models/account_invoice.py @@ -74,9 +74,7 @@ class AccountInvoice(models.Model): def action_move_create(self): res = super().action_move_create() for inv in self: - move = inv.move_id - assets = [aml.asset_id for aml in - [x for x in move.line_ids if x.asset_id]] + assets = inv.move_id.line_ids.mapped('asset_id') for asset in assets: asset.code = inv.move_name asset_line_name = asset._get_depreciation_entry_name(0) @@ -90,7 +88,7 @@ class AccountInvoice(models.Model): assets = self.env['account.asset'] for inv in self: move = inv.move_id - assets = move.line_ids.mapped('asset_id') + assets |= move.line_ids.mapped('asset_id') super().action_cancel() if assets: assets.unlink() diff --git a/account_asset_management/models/res_config.py b/account_asset_management/models/res_config_settings.py similarity index 100% rename from account_asset_management/models/res_config.py rename to account_asset_management/models/res_config_settings.py diff --git a/account_asset_management/readme/DESCRIPTION.rst b/account_asset_management/readme/DESCRIPTION.rst index 00c001e8a..403e99d48 100644 --- a/account_asset_management/readme/DESCRIPTION.rst +++ b/account_asset_management/readme/DESCRIPTION.rst @@ -10,4 +10,4 @@ Assets can be created manually as well as automatically 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. \ No newline at end of file +the standard account_asset module from Odoo. diff --git a/account_asset_management/tests/account_asset_test_data.xml b/account_asset_management/tests/account_asset_test_data.xml index 26bdcafbe..594f76f55 100644 --- a/account_asset_management/tests/account_asset_test_data.xml +++ b/account_asset_management/tests/account_asset_test_data.xml @@ -1,4 +1,4 @@ - + diff --git a/account_asset_management/views/account_account.xml b/account_asset_management/views/account_account.xml index 760722f1d..d461bb316 100644 --- a/account_asset_management/views/account_account.xml +++ b/account_asset_management/views/account_account.xml @@ -1,4 +1,4 @@ - + diff --git a/account_asset_management/views/account_asset.xml b/account_asset_management/views/account_asset.xml index 078375ebe..76c1af26a 100644 --- a/account_asset_management/views/account_asset.xml +++ b/account_asset_management/views/account_asset.xml @@ -1,3 +1,4 @@ + @@ -194,9 +195,9 @@ - - - + + + diff --git a/account_asset_management/views/account_asset_profile.xml b/account_asset_management/views/account_asset_profile.xml index a8bdf2b88..f42f2fe70 100644 --- a/account_asset_management/views/account_asset_profile.xml +++ b/account_asset_management/views/account_asset_profile.xml @@ -1,4 +1,5 @@ - + + @@ -78,4 +79,4 @@ - + diff --git a/account_asset_management/views/account_invoice.xml b/account_asset_management/views/account_invoice.xml index 3de8d6895..6f1431ca6 100644 --- a/account_asset_management/views/account_invoice.xml +++ b/account_asset_management/views/account_invoice.xml @@ -1,4 +1,4 @@ - + diff --git a/account_asset_management/views/account_invoice_line.xml b/account_asset_management/views/account_invoice_line.xml index e5952315c..d44dea417 100644 --- a/account_asset_management/views/account_invoice_line.xml +++ b/account_asset_management/views/account_invoice_line.xml @@ -1,4 +1,4 @@ - + diff --git a/account_asset_management/views/account_move.xml b/account_asset_management/views/account_move.xml index 83066b4fb..ac12384b4 100644 --- a/account_asset_management/views/account_move.xml +++ b/account_asset_management/views/account_move.xml @@ -1,4 +1,4 @@ - + diff --git a/account_asset_management/views/account_move_line.xml b/account_asset_management/views/account_move_line.xml index 70824789b..63b60f19e 100644 --- a/account_asset_management/views/account_move_line.xml +++ b/account_asset_management/views/account_move_line.xml @@ -1,4 +1,4 @@ - + diff --git a/account_asset_management/views/menuitem.xml b/account_asset_management/views/menuitem.xml index 7ff132ec3..6de76d0f1 100644 --- a/account_asset_management/views/menuitem.xml +++ b/account_asset_management/views/menuitem.xml @@ -1,4 +1,4 @@ - +