[ADD] account_asset: Added fields on asset category which will reflect into the same fields of asset.

bzr revid: uco@tinyerp.com-20110517103753-kh2v1z9pupi8s1dh
This commit is contained in:
Ujjvala Collins (OpenERP) 2011-05-17 16:07:53 +05:30
parent a2ffcb5888
commit 1b7975285a
2 changed files with 12 additions and 2 deletions

View File

@ -37,6 +37,8 @@ class account_asset_category(osv.osv):
'account_expense_depreciation_id': fields.many2one('account.account', 'Depr. Expense Account', required=True),
'journal_id': fields.many2one('account.journal', 'Journal', required=True),
'company_id': fields.many2one('res.company', 'Company', required=True),
'method': fields.selection([('linear','Linear'),('progressif','Progressive')], 'Computation method', required=True),
'method_delay': fields.integer('During (interval)'),
}
_defaults = {
@ -198,7 +200,13 @@ class account_asset_asset(osv.osv):
'company_id': lambda self, cr, uid, context: self.pool.get('res.company')._company_default_get(cr, uid, 'account.asset.asset',context=context),
}
def onchange_category_id(self, cr, uid, ids, category_id, context=None):
res = {'value':{}}
if category_id:
category_obj = self.pool.get('account.asset.category').browse(cr, uid, category_id, context=context)
res['value'] = {'method': category_obj.method, 'method_delay': category_obj.method_delay}
return res
def _compute_period(self, cr, uid, property, context={}):
if (len(property.entry_asset_ids or [])/2)>=property.method_delay:
return False

View File

@ -15,6 +15,8 @@
<field name="account_asset_id"/>
<field name="account_depreciation_id"/>
<field name="account_expense_depreciation_id"/>
<field name="method"/>
<field name="method_delay"/>
<group col="4" colspan="4" groups="analytic.group_analytic_accounting">
<separator string="Analytic information" colspan="4" />
<newline/>
@ -50,7 +52,7 @@
<form string="Asset">
<group col="6" colspan="4">
<field name="name" select="1"/>
<field name="category_id" select="1"/>
<field name="category_id" select="1" on_change="onchange_category_id(category_id)"/>
<field name="code" select="1"/>
<field name="purchase_value" select="1"/>
<field name="currency_id" select="1"/>