[IMP] account_asset: lot of usability changes

bzr revid: qdp-launchpad@openerp.com-20110709224535-8sa9igpcx504fj7n
This commit is contained in:
Quentin (OpenERP) 2011-07-10 00:45:35 +02:00
parent 07a70035ed
commit bb1c9574b6
2 changed files with 119 additions and 108 deletions

View File

@ -39,17 +39,19 @@ 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': fields.selection([('linear','Linear'),('degressive','Degressive')], 'Computation Method', required=True, help="Choose the method to use to compute the amount of depreciation lines.\n"\
" * Linear: Calculated on basis of: Gross Value / Number of Depreciations\n" \
" * Degressive: Calculated on basis of: Remaining Value * Degressive Factor"),
'method_number': fields.integer('Number of Depreciations'),
'method_period': fields.integer('Period Length', help="State here the time between 2 depreciations, in months"),
'method_progress_factor': fields.float('Progressif Factor'),
'method_period': fields.integer('Period Length', help="State here the time between 2 depreciations, in months", required=True),
'method_progress_factor': fields.float('Degressive Factor'),
'method_time': fields.selection([('number','Number of Depreciations'),('end','Ending Date')], 'Time Method', required=True,
help="Choose the method to use to compute the dates and number of depreciation lines.\n"\
"Number of Depreciations: Fix the number of depreciation lines and the time between 2 depreciations.\n" \
"Ending Date: Choose the time between 2 depreciations and the date the depreciations won't go beyond."),
" * Number of Depreciations: Fix the number of depreciation lines and the time between 2 depreciations.\n" \
" * Ending Date: Choose the time between 2 depreciations and the date the depreciations won't go beyond."),
'method_end': fields.date('Ending date'),
'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'),
'open_asset': fields.boolean('Skip Draft State', help="Check this if you want to automatically confirm the assets of this category when created by invoice."),
'prorata':fields.boolean('Prorata Temporis', help='Indicates that the first depreciation entry for this asset have to be done from the purchase date instead of the first January'),
'open_asset': fields.boolean('Skip Draft State', help="Check this if you want to automatically confirm the assets of this category when created by invoices."),
}
_defaults = {
@ -184,52 +186,50 @@ class account_asset_asset(osv.osv):
return res
_columns = {
'period_id': fields.many2one('account.period', 'First Period', required=True, readonly=True, states={'draft':[('readonly',False)]}),
'account_move_line_ids': fields.one2many('account.move.line', 'asset_id', 'Entries', readonly=True, states={'draft':[('readonly',False)]}),
'name': fields.char('Asset', size=64, required=True, select=1, readonly=False, states={'close':[('readonly',True)]}),
'code': fields.char('Reference ', size=16, select=1, readonly=False, states={'close':[('readonly',True)]}),
'purchase_value': fields.float('Gross value ', required=True, readonly=False, states={'close':[('readonly',True)]}),
'currency_id': fields.many2one('res.currency','Currency',required=True, readonly=False, states={'close':[('readonly',True)]}),
'company_id': fields.many2one('res.company', 'Company', required=True, readonly=False, states={'close':[('readonly',True)]}),
'name': fields.char('Asset', size=64, required=True, readonly=True, states={'draft':[('readonly',False)]}),
'code': fields.char('Reference ', size=16, readonly=True, states={'draft':[('readonly',False)]}),
'purchase_value': fields.float('Gross value ', required=True, readonly=True, states={'draft':[('readonly',False)]}),
'currency_id': fields.many2one('res.currency','Currency',required=True, readonly=True, states={'draft':[('readonly',False)]}),
'company_id': fields.many2one('res.company', 'Company', required=True, readonly=True, states={'draft':[('readonly',False)]}),
'note': fields.text('Note'),
'category_id': fields.many2one('account.asset.category', 'Asset category',required=True, change_default=True, readonly=False, states={'close':[('readonly',True)]}),
'localisation': fields.char('Localisation', size=32, select=2),
'parent_id': fields.many2one('account.asset.asset', 'Parent Asset', readonly=False, states={'close':[('readonly',True)]}),
'category_id': fields.many2one('account.asset.category', 'Asset category', required=True, change_default=True, readonly=True, states={'draft':[('readonly',False)]}),
'parent_id': fields.many2one('account.asset.asset', 'Parent Asset', readonly=True, states={'draft':[('readonly',False)]}),
'child_ids': fields.one2many('account.asset.asset', 'parent_id', 'Children Assets'),
'purchase_date': fields.date('Purchase Date', required=True, readonly=False, states={'close':[('readonly',True)]}),
'purchase_date': fields.date('Purchase Date', required=True, readonly=True, states={'draft':[('readonly',False)]}),
'state': fields.selection([('draft','Draft'),('open','Running'),('close','Close')], 'State', required=True,
help="When an asset is created, the state is 'Draft'.\n" \
"If the asset is confirmed, the state goes in 'Running' and the depreciation lines can be posted in the accounting.\n" \
"You can manually close an asset when the depreciation is over. If the last line of depreciation is posted, the asset automatically goes in that state."),
'active': fields.boolean('Active', select=2),
'partner_id': fields.many2one('res.partner', 'Partner', readonly=False, states={'close':[('readonly',True)]}),
'method': fields.selection([('linear','Linear'),('degressive','Degressive')], 'Computation Method', required=True, readonly=True, states={'draft':[('readonly',False)]}, help="Linear: Calculated on basis of Gross Value/During (interval) \
\nDegressive: Calculated on basis of Gross Value * Degressive Factor"),
'active': fields.boolean('Active'),
'partner_id': fields.many2one('res.partner', 'Partner', readonly=True, states={'draft':[('readonly',False)]}),
'method': fields.selection([('linear','Linear'),('degressive','Degressive')], 'Computation Method', required=True, readonly=True, states={'draft':[('readonly',False)]}, help="Choose the method to use to compute the amount of depreciation lines.\n"\
" * Linear: Calculated on basis of: Gross Value / Number of Depreciations\n" \
" * Degressive: Calculated on basis of: Remaining Value * Degressive Factor"),
'method_number': fields.integer('Number of Depreciations', readonly=True, states={'draft':[('readonly',False)]}, help="Calculates Depreciation within specified interval"),
'method_period': fields.integer('Period Length', readonly=True, states={'draft':[('readonly',False)]}, help="State here the time during 2 depreciations, in months"),
'method_period': fields.integer('Period Length', required=True, readonly=True, states={'draft':[('readonly',False)]}, help="State here the time during 2 depreciations, in months"),
'method_end': fields.date('Ending Date', readonly=True, states={'draft':[('readonly',False)]}),
'method_progress_factor': fields.float('Progressif Factor', readonly=True, states={'draft':[('readonly',False)]}),
'method_progress_factor': fields.float('Degressive Factor', readonly=True, states={'draft':[('readonly',False)]}),
'value_residual': fields.function(_amount_residual, method=True, digits_compute=dp.get_precision('Account'), string='Residual Value'),
'method_time': fields.selection([('number','Number of Depreciations'),('end','Ending Date')], 'Time Method', required=True, readonly=True, states={'draft':[('readonly',False)]},
help="Choose the method to use to compute the dates and number of depreciation lines.\n"\
"Number of Depreciations: Fix the number of depreciation lines and the time between 2 depreciations.\n" \
"Ending Date: Choose the time between 2 depreciations and the date the depreciations won't go beyond."),
'prorata':fields.boolean('Prorata Temporis', readonly=True, states={'draft':[('readonly',False)]}, help='Indicates that the accounting entries for this asset have to be done from the purchase date instead of the first January'),
" * Number of Depreciations: Fix the number of depreciation lines and the time between 2 depreciations.\n" \
" * Ending Date: Choose the time between 2 depreciations and the date the depreciations won't go beyond."),
'prorata':fields.boolean('Prorata Temporis', readonly=True, states={'draft':[('readonly',False)]}, help='Indicates that the first depreciation entry for this asset have to be done from the purchase date instead of the first January'),
'history_ids': fields.one2many('account.asset.history', 'asset_id', 'History', readonly=True),
'depreciation_line_ids': fields.one2many('account.asset.depreciation.line', 'asset_id', 'Depreciation Lines', readonly=True, states={'draft':[('readonly',False)],'open':[('readonly',False)]}),
'salvage_value': fields.float('Salvage Value', digits_compute=dp.get_precision('Account'), help="It is the amount you plan to have that you cannot depreciate.", readonly=False, states={'close':[('readonly',True)]}),
'salvage_value': fields.float('Salvage Value', digits_compute=dp.get_precision('Account'), help="It is the amount you plan to have that you cannot depreciate.", readonly=True, states={'draft':[('readonly',False)]}),
}
_defaults = {
'code': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'account.asset.code'),
'purchase_date': lambda obj, cr, uid, context: time.strftime('%Y-%m-%d'),
'active': lambda obj, cr, uid, context: True,
'state': lambda obj, cr, uid, context: 'draft',
'period_id': _get_period,
'method': lambda obj, cr, uid, context: 'linear',
'method_number': lambda obj, cr, uid, context: 5,
'method_time': lambda obj, cr, uid, context: 'number',
'method_period': lambda obj, cr, uid, context: 12,
'method_progress_factor': lambda obj, cr, uid, context: 0.3,
'active': True,
'state': 'draft',
'method': 'linear',
'method_number': 5,
'method_time': 'number',
'method_period': 12,
'method_progress_factor': 0.3,
'currency_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.currency_id.id,
'company_id': lambda self, cr, uid, context: self.pool.get('res.company')._company_default_get(cr, uid, 'account.asset.asset',context=context),
}
@ -245,7 +245,7 @@ class account_asset_asset(osv.osv):
_constraints = [
(_check_recursion, 'Error ! You can not create recursive assets.', ['parent_id']),
(_check_prorata, '\nProrata temporis can be applied only for computation method linear and time method number.', ['prorata']),
(_check_prorata, 'Prorata temporis can be applied only for computation method "linear" and time method "number of depreciations".', ['prorata']),
]
def onchange_category_id(self, cr, uid, ids, category_id, context=None):
@ -381,6 +381,7 @@ class account_asset_depreciation_line(osv.osv):
'name': fields.char('Depreciation Name', size=64, required=True, select=1),
'sequence': fields.integer('Sequence of the depreciation', required=True),
'asset_id': fields.many2one('account.asset.asset', 'Asset', required=True),
'parent_state': fields.related('asset_id', 'state', type='char', string='State of Asset'),
'amount': fields.float('Depreciation Amount', required=True),
'remaining_value': fields.float('Amount to Depreciate', required=True),
'depreciated_value': fields.float('Amount Already Depreciated', required=True),

View File

@ -2,6 +2,10 @@
<openerp>
<data>
<!--
Asset Category
-->
<record model="ir.ui.view" id="view_account_asset_category_form">
<field name="name">account.asset.category.form</field>
<field name="model">account.asset.category</field>
@ -18,15 +22,15 @@
<group colspan="2" col="2">
<separator string="Depreciation Dates" colspan="2" />
<field name="method_time"/>
<field name="method_number" attrs="{'invisible':[('method_time','=','end')]}"/>
<field name="method_number" attrs="{'invisible':[('method_time','=','end')], 'required':[('method_time','=','number')]}"/>
<field name="method_period"/>
<field name="method_end" attrs="{'required': [('method_time','=','end')], 'invisible':[('method_time','=','number')]}"/>
</group>
<group colspan="2" col="2">
<separator string="Depreciation Method" colspan="2" />
<field name="method"/>
<field name="method_progress_factor" attrs="{'invisible':[('method','=','linear')]}"/>
<field name="prorata"/>
<field name="method_progress_factor" attrs="{'invisible':[('method','=','linear')], 'required':[('method','=','degressive')]}"/>
<field name="prorata" attrs="{'invisible':[('method','&lt;&gt;','linear')]}"/>
<field name="open_asset"/>
</group>
<group col="2" colspan="2" groups="analytic.group_analytic_accounting">
@ -47,12 +51,10 @@
<field name="arch" type="xml">
<tree string="Asset category">
<field name="name"/>
<field name="method_time"/>
<field name="method_number"/>
<field name="method"/>
<field name="journal_id"/>
<field name="account_asset_id"/>
<field name="account_expense_depreciation_id"/>
<field name="method_time"/>
<field name="method"/>
<field name="open_asset"/>
<field name="company_id" groups="base.group_multi_company"/>
</tree>
</field>
@ -70,6 +72,10 @@
</field>
</record>
<!--
Asset
-->
<record model="ir.ui.view" id="view_account_asset_asset_form">
<field name="name">account.asset.asset.form</field>
<field name="model">account.asset.asset</field>
@ -87,7 +93,7 @@
<field name="company_id" select="1" widget="selection" groups="base.group_multi_company"/>
</group>
<notebook colspan="4">
<page string="Depreciation">
<page string="General">
<separator string="Other Information" colspan="4"/>
<field name="parent_id"/>
<field name="partner_id"/>
@ -96,7 +102,7 @@
<group colspan="2" col="2">
<separator string="Depreciation Dates" colspan="2" />
<field name="method_time" on_change="onchange_method_time(method_time)"/>
<field name="method_number" attrs="{'invisible':[('method_time','=','end')]}"/>
<field name="method_number" attrs="{'invisible':[('method_time','=','end')], 'required':[('method_time','=','number')]}"/>
<field name="method_period"/>
<field name="method_end" attrs="{'required': [('method_time','=','end')], 'invisible':[('method_time','=','number')]}"/>
<newline/>
@ -111,7 +117,7 @@
<group colspan="2" col="2">
<separator string="Depreciation Method" colspan="2" />
<field name="method" on_change="onchange_method_time(method)"/>
<field name="method_progress_factor" attrs="{'invisible':[('method','=','linear')]}"/>
<field name="method_progress_factor" attrs="{'invisible':[('method','=','linear')], 'required':[('method','=','degressive')]}"/>
<field name="prorata" attrs="{'invisible': ['|',('method_time','=','end'),('method','!=','linear')]}"/>
</group>
<newline/>
@ -131,7 +137,8 @@
<field name="amount"/>
<field name="remaining_value" readonly="1"/>
<field name="move_check"/>
<button name="create_move" attrs="{'invisible':[('move_check','!=',False)]}" icon="gtk-execute" string="Create Move" type="object"/>
<field name="parent_state" invisible="1"/>
<button name="create_move" attrs="{'invisible':['|',('move_check','!=',False),('parent_state','!=','open')]}" icon="gtk-execute" string="Create Move" type="object"/>
</tree>
<graph type="bar">
<field name="name"/>
@ -153,6 +160,69 @@
</field>
</record>
<record model="ir.ui.view" id="view_account_asset_asset_tree">
<field name="name">account.asset.asset.tree</field>
<field name="model">account.asset.asset</field>
<field name="type">tree</field>
<field name="field_parent">child_ids</field>
<field name="arch" type="xml">
<tree string="Assets">
<field name="name"/>
<field name="category_id"/>
<field name="purchase_date"/>
<field name="partner_id"/>
<field name="purchase_value"/>
<field name="value_residual"/>
<field name="currency_id"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="state"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="view_account_asset_asset_hierarchy_tree">
<field name="name">account.asset.asset.hierarchy</field>
<field name="model">account.asset.asset</field>
<field name="type">tree</field>
<field name="field_parent">child_ids</field>
<field name="arch" type="xml">
<tree string="Assets">
<field name="name"/>
<field name="code"/>
<field name="category_id"/>
<field name="purchase_date"/>
<field name="purchase_value"/>
<field name="value_residual"/>
<field name="currency_id"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="state"/>
</tree>
</field>
</record>
<record id="view_account_asset_search" model="ir.ui.view">
<field name="name">account.asset.asset.search</field>
<field name="model">account.asset.asset</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Account Asset">
<group col="10" colspan="12">
<filter icon="terp-check" string="Current" domain="[('state','in', ('draft','open'))]" help="Assets in draft and open states"/>
<filter icon="terp-dialog-close" string="Closed" domain="[('state','=', 'close')]" help="Assets in closed state"/>
<separator orientation="vertical"/>
<field name="name"/>
<field name="category_id"/>
<field name="purchase_date"/>
<field name="partner_id"/>
</group>
</search>
</field>
</record>
<!--
Asset History
-->
<record model="ir.ui.view" id="view_account_asset_history_form">
<field name="name">account.asset.history.form</field>
<field name="model">account.asset.history</field>
@ -193,66 +263,6 @@
</field>
</record>
<record model="ir.ui.view" id="view_account_asset_asset_tree">
<field name="name">account.asset.asset.tree</field>
<field name="model">account.asset.asset</field>
<field name="type">tree</field>
<field name="field_parent">child_ids</field>
<field name="arch" type="xml">
<tree string="Assets">
<field name="name"/>
<field name="category_id"/>
<field name="purchase_date"/>
<field name="partner_id"/>
<field name="purchase_value"/>
<field name="value_residual"/>
<field name="currency_id"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="state"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="view_account_asset_asset_hierarchy_tree">
<field name="name">account.asset.asset.hierarchy</field>
<field name="model">account.asset.asset</field>
<field name="type">tree</field>
<field name="field_parent">child_ids</field>
<field name="arch" type="xml">
<tree string="Assets">
<field name="name"/>
<field name="code"/>
<field name="category_id"/>
<field name="purchase_date"/>
<field name="purchase_value"/>
<field name="value_residual"/>
<field name="currency_id"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="state"/>
</tree>
</field>
</record>
<record id="view_account_asset_search" model="ir.ui.view">
<field name="name">account.asset.asset.search</field>
<field name="model">account.asset.asset</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Account Asset Analysis">
<group col="10" colspan="12">
<filter icon="terp-document-new" string="Draft" domain="[('state','=', 'draft')]" help="Assets in Draft State"/>
<filter icon="terp-camera_test" string="Running" domain="[('state','=', 'open')]" help="Assets in Running State"/>
<separator orientation="vertical"/>
<field name="name"/>
<field name="category_id"/>
<field name="purchase_date"/>
<field name="partner_id"/>
</group>
</search>
</field>
</record>
<record model="ir.actions.act_window" id="action_account_asset_asset_tree">
<field name="name">Asset Hierarchy</field>
<field name="res_model">account.asset.asset</field>