From 83f181e6977e25f0034580842e9ea269b13b3634 Mon Sep 17 00:00:00 2001 From: Tonow-c2c Date: Thu, 15 Nov 2018 16:23:26 +0100 Subject: [PATCH] [10.0][FIX] account_asset_management - issues #731 --- account_asset_management/README.rst | 3 +++ .../models/account_asset.py | 24 +++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/account_asset_management/README.rst b/account_asset_management/README.rst index dad7db1d7..4b4eb88d2 100644 --- a/account_asset_management/README.rst +++ b/account_asset_management/README.rst @@ -20,6 +20,9 @@ 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. +* When the depreciation board an asset is compute, lines computed are flagged 'Init' + if they are before **Lock Date** `fiscalyear_lock_date` + Configuration ============= diff --git a/account_asset_management/models/account_asset.py b/account_asset_management/models/account_asset.py index 409a9eb8f..7cfcc6898 100644 --- a/account_asset_management/models/account_asset.py +++ b/account_asset_management/models/account_asset.py @@ -596,7 +596,7 @@ class AccountAsset(models.Model): 'asset_id': asset.id, 'name': name, 'line_date': line['date'].strftime('%Y-%m-%d'), - 'init_entry': entry['init'], + 'init_entry': line['init_entry'], } depreciated_value += amount depr_line = line_obj.create(vals) @@ -808,8 +808,13 @@ class AccountAsset(models.Model): return line_dates - def _compute_depreciation_table_lines(self, table, depreciation_start_date, - depreciation_stop_date, line_dates): + def _compute_depreciation_table_lines( + self, table, + depreciation_start_date, + depreciation_stop_date, + line_dates, + fiscalyear_lock_date + ): digits = self.env['decimal.precision'].precision_get('Account') asset_sign = self.depreciation_base >= 0 and 1 or -1 @@ -852,11 +857,22 @@ class AccountAsset(models.Model): else: remaining_value -= amount fy_amount_check += amount + + fiscalyear_lock_date_formated = datetime.strptime( + fiscalyear_lock_date, '%Y-%m-%d' + ) + + if line_date <= fiscalyear_lock_date_formated: + init_entry = True + else: + init_entry = False + line = { 'date': line_date, 'amount': amount, 'depreciated_value': depreciated_value, 'remaining_value': remaining_value, + 'init_entry': init_entry } lines.append(line) depreciated_value += amount @@ -1031,7 +1047,7 @@ class AccountAsset(models.Model): # over the depreciation periods. self._compute_depreciation_table_lines( table, depreciation_start_date, depreciation_stop_date, - line_dates) + line_dates, fiscalyear_lock_date) return table