[MERGE] merged with abe branch
bzr revid: qdp-launchpad@openerp.com-20110509144529-q2735cep9fyxmwlm
This commit is contained in:
@@ -22,5 +22,6 @@
|
||||
import account_asset
|
||||
import account_asset_invoice
|
||||
import wizard
|
||||
import report
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
"account_asset_view.xml",
|
||||
"account_asset_invoice_view.xml",
|
||||
"account_asset_report_view.xml",
|
||||
"report/account_asset_report_view.xml",
|
||||
#modif
|
||||
],
|
||||
# "translations" : {
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
from osv import osv, fields
|
||||
import time
|
||||
import datetime
|
||||
class account_asset_category(osv.osv):
|
||||
_name = 'account.asset.category'
|
||||
_description = 'Asset category'
|
||||
@@ -29,8 +30,11 @@ class account_asset_category(osv.osv):
|
||||
#'code': fields.char('Reference', size=16, select=1),
|
||||
'note': fields.text('Note'),
|
||||
#'type': fields.selection([('direct','Direct'),('indirect','Indirect')], 'Depr. method type', select=2, required=True),
|
||||
'journal_analytic_id': fields.many2one('account.analytic.journal', 'Analytic journal'),
|
||||
'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic account'),
|
||||
'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),
|
||||
'journal_id': fields.many2one('account.journal', 'Journal', required=True),
|
||||
'company_id': fields.many2one('res.company', 'Company'),
|
||||
}
|
||||
@@ -73,24 +77,83 @@ class account_asset_asset(osv.osv):
|
||||
return periods[0]
|
||||
else:
|
||||
return False
|
||||
|
||||
def compute_depreciation_board(self, cr, uid, ids, context=None):
|
||||
##
|
||||
def compute_depreciation_board(self, cr, uid,ids, context=None):
|
||||
#FIXME: change into a fields.function
|
||||
test = 1.0
|
||||
date_year = 1.0
|
||||
purchase_value_board = 1.0
|
||||
amountpro = 1.0
|
||||
for asset in self.browse(cr, uid, ids, context=context):
|
||||
#res[asset.id] = []
|
||||
undone_dotation_number = asset.method_delay - len(asset.account_move_line_ids) + 1
|
||||
amount = asset.value_residual
|
||||
for i in range(1,undone_dotation_number+1):
|
||||
if i == 1:
|
||||
amount = asset.value_residual / undone_dotation_number
|
||||
else:
|
||||
if asset.method == 'linear':
|
||||
amount = asset.value_residual / undone_dotation_number
|
||||
else:
|
||||
amount = asset.value_residual * asset.method_progress_factor
|
||||
#res[asset.id].append([self.pool.get('account.asset.depreciation.line').create(cr, uid, {'amount': amount, 'asset_id': asset.id, 'sequence':i, 'name': str(asset.id) +'/'+ str(i)})])
|
||||
self.pool.get('account.asset.depreciation.line').create(cr, uid, {'amount': amount, 'asset_id': asset.id, 'sequence':i, 'name': str(asset.id) +'/'+ str(i)})
|
||||
return True
|
||||
test = asset.value_residual
|
||||
purchase_value_board = amount
|
||||
if asset.prorata == 'false' :
|
||||
for i in range(1,undone_dotation_number+1):
|
||||
if i == 1:
|
||||
amount = asset.value_residual / undone_dotation_number
|
||||
test = asset.value_residual - amount
|
||||
#amountpro = ((asset.value_residual / undone_dotation_number
|
||||
else:
|
||||
if asset.method == 'linear':
|
||||
if i == undone_dotation_number+1:
|
||||
# amount = amount - amountpro
|
||||
test = test - amount
|
||||
else:
|
||||
amount = asset.value_residual / undone_dotation_number
|
||||
test = test - amount
|
||||
elif asset.method == "progressif":
|
||||
if i == undone_dotation_number+1:
|
||||
# amount = amount - amountpro
|
||||
test = test - amount
|
||||
else:
|
||||
amount = asset.value_residual * asset.method_progress_factor
|
||||
test = test - amount
|
||||
else:
|
||||
#methods
|
||||
print ""
|
||||
|
||||
else:
|
||||
deprec_date = time.strftime('%Y')
|
||||
for i in range(1,undone_dotation_number+2):
|
||||
date_year = int(time.strftime('%Y'))
|
||||
date_year += i-1
|
||||
deprec_date = '31/12/',str(date_year)
|
||||
if i == 1:
|
||||
amount = ((asset.value_residual / undone_dotation_number)*5)/12
|
||||
test = asset.value_residual - amount
|
||||
amountpro = ((asset.value_residual / undone_dotation_number)*5)/12
|
||||
else:
|
||||
if asset.method == 'linear':
|
||||
if i == undone_dotation_number+1:
|
||||
amount = amount - amountpro
|
||||
test = test - amount
|
||||
else:
|
||||
amount = asset.value_residual / undone_dotation_number
|
||||
test = test - amount
|
||||
elif asset.method == "progressif":
|
||||
if i == undone_dotation_number+1:
|
||||
amount = amount - amountpro
|
||||
test = test - amount
|
||||
else:
|
||||
amount = asset.value_residual * asset.method_progress_factor
|
||||
test = test - amount
|
||||
else:
|
||||
#methods
|
||||
print ""
|
||||
|
||||
|
||||
|
||||
#res[asset.id].append([self.pool.get('account.asset.depreciation.line').create(cr, uid, {'amount': amount, 'asset_id': asset.id, 'sequence':i, 'name': str(asset.id) +'/'+ str(i)})])
|
||||
self.pool.get('account.asset.depreciation.line').create(cr, uid, {'amount': amount,'deprec_value': test,'deprec_date': deprec_date,'purchase_value_board':purchase_value_board, 'asset_id': asset.id, 'sequence':i, 'name': str(asset.id) +'/'+ str(i)})
|
||||
return True
|
||||
|
||||
|
||||
|
||||
def account_move_line_deprec(self, cr, uid, ids, context={}):
|
||||
print "Error !!!"
|
||||
|
||||
def validate(self, cr, uid, ids, context={}):
|
||||
return self.write(cr, uid, ids, {
|
||||
@@ -128,29 +191,32 @@ class account_asset_asset(osv.osv):
|
||||
|
||||
_columns = {
|
||||
#test
|
||||
'asset_id': fields.many2one('account.asset.asset', 'Asset', required=True, select=1),
|
||||
'asset_id': fields.many2one('account.asset.asset', 'Asset', required=True, select=1), #TODO: remove this ?
|
||||
#analytic fields
|
||||
'journal_analytic_id': fields.many2one('account.analytic.journal', 'Analytic journal'),#FIXME: do not display if not in group analytic accounting OK
|
||||
'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic account'),#FIXME: do not display if not in group analytic accounting OK
|
||||
#accounting fields
|
||||
'account_asset_id': fields.many2one('account.account', 'Asset Account', required=True),
|
||||
'account_actif_id': fields.many2one('account.account', 'Depreciation account', required=True),
|
||||
'journal_analytic_id': fields.many2one('account.analytic.journal', 'Analytic journal'),
|
||||
'account_depreciation_id': fields.many2one('account.account', 'Depreciation account', required=True),
|
||||
'account_expense_depreciation_id': fields.many2one('account.account', 'Depr. Expense account', required=True),
|
||||
'journal_id': fields.many2one('account.journal', 'Depreciation Entries Journal', required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'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),
|
||||
'code': fields.char('Reference ', size=16, select=1),
|
||||
'purchase_value': fields.float('Purchase value ', required=True, size=16, select=1),
|
||||
'purchase_value': fields.float('Gross value ', required=True, size=16, select=1),
|
||||
'currency_id': fields.many2one('res.currency','Currency',required=True,size=5,select=1),
|
||||
'company_id': fields.many2one('res.company', 'Company', required=True), #FIXME: fields.many2one !! OK
|
||||
'company_id': fields.many2one('res.company', 'Company', required=True),
|
||||
'note': fields.text('Note'),
|
||||
'category_id': fields.many2one('account.asset.category', 'Asset category',required=True, change_default=True),
|
||||
'localisation': fields.char('Localisation', size=32, select=2),
|
||||
'parent_id': fields.many2one('account.asset.asset', 'Parent Asset'),
|
||||
'child_ids': fields.one2many('account.asset.asset', 'parent_id', 'Children Assets'),
|
||||
'purchase_date': fields.date('Purchase Date', required=True), #FIXME: date is not displayed currently OK
|
||||
'period_id': fields.many2one('account.period', 'Period', required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'state': fields.selection([('view','View'),('draft','Draft'),('normal','Normal'),('close','Close')], 'Global state', required=True),
|
||||
'purchase_date': fields.date('Purchase Date', required=True),
|
||||
'state': fields.selection([('view','View'),('draft','Draft'),('normal','Normal'),('close','Close')], 'state', required=True),
|
||||
'active': fields.boolean('Active', select=2),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner'),#FIXME: not displayed OK
|
||||
'account_move_line_ids': fields.one2many('account.move.line', 'asset_id', 'Entries', readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'journal_analytic_id': fields.many2one('account.analytic.journal', 'Analytic journal'),#FIXME: do not display if not in group analytic accounting OK
|
||||
'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic account'),#FIXME: do not display if not in group analytic accounting OK
|
||||
'partner_id': fields.many2one('res.partner', 'Partner'),
|
||||
|
||||
'method': fields.selection([('linear','Linear'),('progressif','Progressive')], 'Computation method', required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'method_delay': fields.integer('During (interval)', readonly=True, states={'draft':[('readonly',False)]}), #FIXME: improve label OK
|
||||
@@ -168,7 +234,8 @@ class account_asset_asset(osv.osv):
|
||||
'method_time': fields.selection([('delay','Delay'),('end','Ending Period')], 'Time Method', required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'prorata':fields.boolean('Prorata Temporis', Readonly="True", help='Si l amortissement se realise après le 1 janvier'),
|
||||
'history_ids': fields.one2many('account.asset.property.history', 'asset_id', 'History', readonly=True),
|
||||
'depreciation_line_ids': fields.one2many('account.asset.depreciation.line', 'asset_id', 'Depreciation Lines', readonly=True,),
|
||||
'depreciation_line_ids': fields.one2many('account.asset.depreciation.line', 'asset_id', 'Depreciation Lines', readonly=True,),
|
||||
|
||||
}
|
||||
_defaults = {
|
||||
'code': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'account.asset.code'),
|
||||
@@ -181,7 +248,11 @@ class account_asset_asset(osv.osv):
|
||||
'method_time': lambda obj, cr, uid, context: 'delay',
|
||||
'method_period': lambda obj, cr, uid, context: 12,
|
||||
'method_progress_factor': lambda obj, cr, uid, context: 0.3,
|
||||
'currency_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.currency_id.id,
|
||||
|
||||
}
|
||||
|
||||
|
||||
def _compute_period(self, cr, uid, property, context={}):
|
||||
if (len(property.entry_asset_ids or [])/2)>=property.method_delay:
|
||||
return False
|
||||
@@ -274,6 +345,8 @@ class account_asset_depreciation_line(osv.osv):
|
||||
'sequence': fields.integer('Sequence of the depreciation', required=True),
|
||||
'asset_id': fields.many2one('account.asset.asset', 'Asset', required=True),
|
||||
'amount': fields.float('Depreciation amount', required=True),
|
||||
'deprec_value': fields.float('Residual value', required=True),
|
||||
'deprec_date': fields.char('Date', size=64, required=True, select=1),
|
||||
}
|
||||
account_asset_depreciation_line()
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="action_account_asset_category_form">
|
||||
<!--<record model="ir.actions.act_window" id="action_account_asset_category_form">
|
||||
<field name="name">Asset Category</field>
|
||||
<field name="res_model">account.asset.category</field>
|
||||
<field name="view_type">form</field>
|
||||
@@ -50,9 +50,9 @@
|
||||
</record>
|
||||
<menuitem
|
||||
parent="menu_finance_config_Assets"
|
||||
id="menu_action_account_asset_category_form"
|
||||
action="action_account_asset_category_form"/>
|
||||
|
||||
id="menu_action_account_asset_category_form"
|
||||
action="action_account_asset_category_form"/>
|
||||
-->
|
||||
|
||||
<!-- <record model="ir.ui.view" id="view_account_asset_property_tree">
|
||||
<field name="name">account.asset.property.tree</field>
|
||||
@@ -84,7 +84,8 @@
|
||||
<field name="code" select="1"/>
|
||||
<field name="purchase_value" select="1"/>
|
||||
<field name="currency_id" select="1"/>
|
||||
<field name="company_id" select="1"/>
|
||||
<field name="company_id" select="1"/>
|
||||
<field name="value_residual"/>
|
||||
</group>
|
||||
<!-- <field name="period_id" select="2"/>-->
|
||||
<!-- <field name="name" select="1" colspan="4"/>-->
|
||||
@@ -109,11 +110,11 @@
|
||||
<field name="purchase_date"/>
|
||||
|
||||
<field name="method"/>
|
||||
<field name="method_progress_factor"/>
|
||||
<field name="method_progress_factor" attrs="{'invisible':[('method','=','linear')]}"/>
|
||||
<newline/>
|
||||
<field name="prorata" colspan="1"/>
|
||||
<field name="method_time"/>
|
||||
<field name="method_period"/>
|
||||
<field name="method_period" attrs="{'invisible':[('method_time','=','end')]}"/>
|
||||
<button
|
||||
name="%(wizard_asset_modify)d"
|
||||
states="open"
|
||||
@@ -127,25 +128,30 @@
|
||||
<!--
|
||||
<field name="method_end"/> -->
|
||||
</page>
|
||||
<page string="History">
|
||||
<field name="account_move_line_ids" colspan="4" nolabel="1" readonly="1"/>
|
||||
<field name="history_ids" colspan="4" nolabel="1" readonly="1"/>
|
||||
</page>
|
||||
<page string="Depreciation board">
|
||||
<field name="value_total"/>
|
||||
<field name="value_residual"/>
|
||||
<!-- <field name="value_total"/>
|
||||
<field name="value_residual"/>-->
|
||||
<field name="depreciation_line_ids" colspan="4" nolabel="1">
|
||||
<tree>
|
||||
<field name="name"/>
|
||||
<field name="deprec_date"/>
|
||||
<field name="sequence"/>
|
||||
<field name="amount"/></tree>
|
||||
<field name="amount"/>
|
||||
<field name="deprec_value"/></tree>
|
||||
</field>
|
||||
|
||||
<button type="object" name="compute_depreciation_board" string="Compute"/>
|
||||
<button type="object" name="compute_depreciation_board" string="Compute" icon="terp-stock_format-scientific" colspan="2"/>
|
||||
<button type="object" name="account_move_line_deprec" string="Create move line" icon="gtk-execute" colspan="2"/>
|
||||
</page>
|
||||
|
||||
<page string="History">
|
||||
<field name="account_move_line_ids" colspan="4" nolabel="1" readonly="1"/>
|
||||
<field name="history_ids" colspan="4" nolabel="1" readonly="1"/>
|
||||
</page>
|
||||
|
||||
|
||||
<page string="Notes">
|
||||
<field name="note"/>
|
||||
<field name="note" nolabel="1"/>
|
||||
</page>
|
||||
</notebook>
|
||||
<field name="state" readonly="1"/>
|
||||
@@ -202,7 +208,7 @@
|
||||
<form string="Asset board">
|
||||
<field name="name" select="1"/>
|
||||
<field name="asset_id" select="1"/>
|
||||
<field name="value_gross" select="2"/>
|
||||
<field name="value_gross" select="2"/>
|
||||
<field name="value_asset"/>
|
||||
<field name="value_asset_cumul"/>
|
||||
<field name="value_net"/>
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import account_asset_report
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import tools
|
||||
from osv import fields,osv
|
||||
|
||||
class asset_asset_report(osv.osv):
|
||||
_name = "asset.asset.report"
|
||||
_description = "Assets Analysis"
|
||||
_auto = False
|
||||
_columns = {
|
||||
'date': fields.date('Asset Date', readonly=True),
|
||||
'asset_id': fields.many2one('account.asset.asset',string='Asset'),
|
||||
# 'asset_category': fields.many2one('account.asset.category',string='Asset category'),
|
||||
'state': fields.related('asset_id','state',type='char', string='State', readonly=True),
|
||||
}
|
||||
def init(self, cr):
|
||||
tools.drop_view_if_exists(cr, 'asset_asset_report')
|
||||
cr.execute("""
|
||||
create or replace view asset_asset_report as (
|
||||
select id as id,
|
||||
asset_id as asset_id,
|
||||
date as date,
|
||||
state as state
|
||||
from
|
||||
account_move_line )""")
|
||||
|
||||
asset_asset_report()
|
||||
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="view_asset_asset_report_tree">
|
||||
<field name="name">asset.asset.report.tree</field>
|
||||
<field name="model">asset.asset.report</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Assets">
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<!-- <record model="ir.actions.act_window" id="action_account_asset_report_form">
|
||||
<field name="name">account.asset.report.graph</field>
|
||||
<field name="model">account.asset.report</field>
|
||||
<field name="type">graph</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Assets Analysis" type="bar">
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
-->
|
||||
<record id="view_asset_asset_report_search" model="ir.ui.view">
|
||||
<field name="name">asset.asset.report.search</field>
|
||||
<field name="model">asset.asset.report</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Assets Analysis">
|
||||
<group col="10" colspan="12">
|
||||
<filter string="State"
|
||||
icon="terp-stock_effects-object-colorize"
|
||||
domain="[('state','=','draft')]"
|
||||
help="Draft Assets"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="1" string="Group By...">
|
||||
<filter string="Asset" name="asset_id" context="{'group_by':'asset_id'}"/>
|
||||
<filter string="Asset Category" name="asset_category"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter string="Asset Date" name="date"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record model="ir.actions.act_window" id="action_asset_asset_report">
|
||||
<field name="name">Assets Analysis</field>
|
||||
<field name="res_model">asset.asset.report</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="search_view_id" ref="view_asset_asset_report_search"/>
|
||||
<field name="help">From this report, you can have an overview on all depreciation. The tool search can also be used to personalise your Assets reports and so, match this analysis to your needs;</field>
|
||||
</record>
|
||||
<menuitem action="action_asset_asset_report"
|
||||
id="menu_action_asset_asset_report"
|
||||
parent="account.menu_finance_statistic_report_statement"
|
||||
/>
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user