From a307d4fc80f7cf2090c03292bc86f6f063e695c0 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 7 Sep 2018 11:00:15 +0200 Subject: [PATCH] [FIX] account_asset: use the last day of fiscal year for depreciation date The depreciation was hardcoded as starting the first of January. If a user changed the configuration to set a different value than 31/12 it had no impact. In saas-11.3, this was improved to allow to configure the behaviour at 805f3a610 opw-1878927 --- addons/account_asset/models/account_asset.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/account_asset/models/account_asset.py b/addons/account_asset/models/account_asset.py index afafa0e9c1f..bd423a806f8 100644 --- a/addons/account_asset/models/account_asset.py +++ b/addons/account_asset/models/account_asset.py @@ -217,7 +217,14 @@ class AccountAssetAsset(models.Model): # depreciation_date = 1st of January of purchase year if annual valuation, 1st of # purchase month in other cases if self.method_period >= 12: - asset_date = datetime.strptime(self.date[:4] + '-01-01', DF).date() + if self.company_id.fiscalyear_last_month: + asset_date = date(year=int(self.date[:4]), + month=self.company_id.fiscalyear_last_month, + day=self.company_id.fiscalyear_last_day) + \ + relativedelta(days=1) + \ + relativedelta(year=int(self.date[:4])) # e.g. 2018-12-31 +1 -> 2019 + else: + asset_date = datetime.strptime(self.date[:4] + '-01-01', DF).date() else: asset_date = datetime.strptime(self.date[:7] + '-01', DF).date() # if we already have some previous validated entries, starting date isn't 1st January but last entry + method period