[FIX] account_asset: asset depreciation should use the correct dates
authorJulien Legros <jle@odoo.com>
Wed, 5 Nov 2014 16:38:50 +0000 (17:38 +0100)
committerJulien Legros <jle@odoo.com>
Wed, 5 Nov 2014 16:38:50 +0000 (17:38 +0100)
fix a5cf71973916f3e9b6ea578a614c76b0b34689d8

addons/account_asset/account_asset.py

index 179222e..9cf4c14 100644 (file)
@@ -399,7 +399,7 @@ class account_asset_depreciation_line(osv.osv):
         created_move_ids = []
         asset_ids = []
         for line in self.browse(cr, uid, ids, context=context):
-            depreciation_date = context.get('depreciation_date') or time.strftime('%Y-%m-%d')
+            depreciation_date = context.get('depreciation_date') or line.depreciation_date or time.strftime('%Y-%m-%d')
             ctx = dict(context, account_period_prefer_normal=True)
             period_ids = period_obj.find(cr, uid, depreciation_date, context=ctx)
             company_currency = line.asset_id.company_id.currency_id.id
@@ -431,7 +431,7 @@ class account_asset_depreciation_line(osv.osv):
                 'partner_id': partner_id,
                 'currency_id': company_currency != current_currency and  current_currency or False,
                 'amount_currency': company_currency != current_currency and - sign * line.amount or 0.0,
-                'date': line.depreciation_date,
+                'date': depreciation_date,
             })
             move_line_obj.create(cr, uid, {
                 'name': asset_name,
@@ -446,7 +446,7 @@ class account_asset_depreciation_line(osv.osv):
                 'currency_id': company_currency != current_currency and  current_currency or False,
                 'amount_currency': company_currency != current_currency and sign * line.amount or 0.0,
                 'analytic_account_id': line.asset_id.category_id.account_analytic_id.id,
-                'date': line.depreciation_date,
+                'date': depreciation_date,
                 'asset_id': line.asset_id.id
             })
             self.write(cr, uid, line.id, {'move_id': move_id}, context=context)