bzr revid: qdp-launchpad@openerp.com-20110524144823-mb1xsfru90ze4uo5
This commit is contained in:
Quentin (OpenERP)
2011-05-24 16:48:23 +02:00
2 changed files with 41 additions and 2 deletions
+26 -1
View File
@@ -37,10 +37,21 @@ 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)'),
'method_period': fields.integer('Depre. all (period)'),
'method_progress_factor': fields.float('Progressif Factor'),
'method_time': fields.selection([('delay','Delay'),('end','Ending Period')], 'Time Method', required=True),
'prorata':fields.boolean('Prorata Temporis', help='Indicates that the accounting entries for this asset have to be done from the purchase date instead of the first January'),
}
_defaults = {
'company_id': lambda self, cr, uid, context: self.pool.get('res.company')._company_default_get(cr, uid, 'account.asset.category', context=context),
'method': 'linear',
'method_delay': 5,
'method_time': 'delay',
'method_period': 12,
'method_progress_factor': 0.3,
}
account_asset_category()
@@ -198,7 +209,21 @@ 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':{}}
asset_categ_obj = self.pool.get('account.asset.category')
if category_id:
category_obj = asset_categ_obj.browse(cr, uid, category_id, context=context)
res['value'] = {
'method': category_obj.method,
'method_delay': category_obj.method_delay,
'method_time': category_obj.method_time,
'method_period': category_obj.method_period,
'method_progress_factor': category_obj.method_progress_factor,
'prorata': category_obj.prorata,
}
return res
def _compute_period(self, cr, uid, property, context={}):
if (len(property.entry_asset_ids or [])/2)>=property.method_delay:
return False
+15 -1
View File
@@ -15,6 +15,20 @@
<field name="account_asset_id"/>
<field name="account_depreciation_id"/>
<field name="account_expense_depreciation_id"/>
<group colspan="2" col="2">
<separator string="Depreciation Dates" colspan="2" />
<field name="method_time"/>
<field name="method_delay"/>
<field name="method_period" attrs="{'invisible':[('method_time','=','end')]}"/>
</group>
<group colspan="2" col="3">
<separator string="Depreciation Method" colspan="4" />
<field name="method"/>
<newline/>
<field name="method_progress_factor" attrs="{'invisible':[('method','=','linear')]}"/>
<newline/>
<field name="prorata" colspan="1"/>
</group>
<group col="4" colspan="4" groups="analytic.group_analytic_accounting">
<separator string="Analytic information" colspan="4" />
<newline/>
@@ -50,7 +64,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"/>