[IMP] account_asset: Improved create_move method

bzr revid: pso@tinyerp.com-20110512112350-1mqjopaoewcuc1m0
This commit is contained in:
pso (OpenERP) 2011-05-12 16:53:50 +05:30
parent f51b4b8a0f
commit ca431c8f68
2 changed files with 7 additions and 4 deletions

View File

@ -33,7 +33,7 @@ class account_asset_category(osv.osv):
'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic account'), #FIXME:add in the form view with group = analytic
'account_asset_id': fields.many2one('account.account', 'Asset Account', required=True),
'account_depreciation_id': fields.many2one('account.account', 'Depreciation Account', required=True),
'account_expense_depreciation_id': fields.many2one('account.account', 'Depr. Expense Account', required=True),#FIXME: required=True + add in the form view
'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'),
}
@ -300,14 +300,16 @@ class account_asset_depreciation_line(osv.osv):
move_vals = {
'name': line.name,
'date': depreciation_date,
'ref': line.name,
'period_id': period_ids and period_ids[0] or False,
'journal_id': line.asset_id.category_id.journal_id.id,
}
move_id = move_obj.create(cr, uid, move_vals, context=context)
move_line_obj.create(cr, uid, {
'name': line.name,
'ref': line.name,
'move_id': move_id,
'account_id': line.asset_id.category_id.account_expense_depreciation_id.id,
'account_id': line.asset_id.category_id.account_depreciation_id.id,
'debit': 0.0,
'credit': line.amount,
'period_id': period_ids and period_ids[0] or False,
@ -319,8 +321,9 @@ class account_asset_depreciation_line(osv.osv):
})
move_line_obj.create(cr, uid, {
'name': line.name,
'ref': line.name,
'move_id': move_id,
'account_id': line.asset_id.category_id.account_depreciation_id.id,
'account_id': line.asset_id.category_id.account_expense_depreciation_id.id,
'credit': 0.0,
'debit': line.amount,
'period_id': period_ids and period_ids[0] or False,

View File

@ -89,7 +89,7 @@
<field name="depreciated_value"/>
<field name="remaining_value"/>
<field name="move_id" invisible="1"/>
<button name="create_move" attrs="{'invisible':[('move_id','!=',False)]}" icon="gtk-execute" string="Create Move" type="object"/>
<button name="create_move" attrs="{'invisible':[('move_id','!=',False)]}" icon="gtk-execute" string="Create Move" type="object"/>
</tree>
<graph type="bar">
<field name="name"/>