[IMP] account_asset: Improved calculations of depreciation lines for prorata feature that should work on degressive method.

bzr revid: uco@tinyerp.com-20110808120428-15jhxsfjwv8h9w0z
This commit is contained in:
Ujjvala Collins (OpenERP)
2011-08-08 17:34:28 +05:30
parent 7fe942991c
commit c65e24648c
2 changed files with 14 additions and 7 deletions
+11 -4
View File
@@ -112,6 +112,13 @@ class account_asset_asset(osv.osv):
amount = (amount_to_depr / asset.method_number) / total_days * (total_days - days)
elif asset.method == 'degressive':
amount = residual_amount * asset.method_progress_factor
#TODO: calculations need to be checked
if asset.prorata:
days = total_days - float(depreciation_date.strftime('%j'))
if i == 1:
amount = (residual_amount * asset.method_progress_factor) / total_days * days
elif i == undone_dotation_number:
amount = (residual_amount * asset.method_progress_factor) / total_days * (total_days - days)
return amount
def _compute_board_undone_dotation_nb(self, cr, uid, asset, depreciation_date, total_days, context=None):
@@ -242,13 +249,13 @@ class account_asset_asset(osv.osv):
def _check_prorata(self, cr, uid, ids, context=None):
for asset in self.browse(cr, uid, ids, context=context):
if asset.prorata and (asset.method != 'linear' or asset.method_time != 'number'):
if asset.prorata and asset.method_time != 'number':
return False
return True
_constraints = [
(_check_recursion, 'Error ! You can not create recursive assets.', ['parent_id']),
(_check_prorata, 'Prorata temporis can be applied only for computation method "linear" and time method "number of depreciations".', ['prorata']),
(_check_prorata, 'Prorata temporis can be applied only for time method "number of depreciations".', ['prorata']),
]
def onchange_category_id(self, cr, uid, ids, category_id, context=None):
@@ -267,9 +274,9 @@ class account_asset_asset(osv.osv):
}
return res
def onchange_method_time(self, cr, uid, ids, method='linear', method_time='number', context=None):
def onchange_method_time(self, cr, uid, ids, method_time='number', context=None):
res = {'value': {}}
if method != 'linear' or method_time != 'number':
if method_time != 'number':
res['value'] = {'prorata': False}
return res
+3 -3
View File
@@ -29,7 +29,7 @@
<separator string="Depreciation Method" colspan="2"/>
<field name="method"/>
<field name="method_progress_factor" attrs="{'invisible':[('method','=','linear')], 'required':[('method','=','degressive')]}"/>
<field name="prorata" attrs="{'invisible':[('method','&lt;&gt;','linear')]}"/>
<field name="prorata"/>
<field name="open_asset"/>
</group>
<group col="2" colspan="2" groups="analytic.group_analytic_accounting">
@@ -109,9 +109,9 @@
</group>
<group colspan="2" col="2">
<separator string="Depreciation Method" colspan="2"/>
<field name="method" on_change="onchange_method_time(method)"/>
<field name="method"/>
<field name="method_progress_factor" attrs="{'invisible':[('method','=','linear')], 'required':[('method','=','degressive')]}"/>
<field name="prorata" attrs="{'invisible': ['|',('method_time','=','end'),('method','!=','linear')]}"/>
<field name="prorata" attrs="{'invisible': [('method_time','=','end')]}"/>
</group>
<newline/>
<separator string="" colspan="4"/>