[FIX] account_asset: depreciation start date

If the depreciation is not prorata temporis, the start date is defined
as:
- 1st of purchase month if frequency is < 12 month
- 1st of January instead

opw-681564
This commit is contained in:
Nicolas Martinelli
2016-06-23 15:08:02 +02:00
parent b114c9e681
commit 162edf276c
+6 -2
View File
@@ -165,8 +165,12 @@ class AccountAssetAsset(models.Model):
if self.prorata:
depreciation_date = datetime.strptime(self._get_last_depreciation_date()[self.id], DF).date()
else:
# depreciation_date = 1st of January of purchase year
asset_date = datetime.strptime(self.date[:4] + '-01-01', DF).date()
# 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()
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
if posted_depreciation_line_ids and posted_depreciation_line_ids[-1].depreciation_date:
last_depreciation_date = datetime.strptime(posted_depreciation_line_ids[-1].depreciation_date, DF).date()