2
0

analytic enhancement

This commit is contained in:
luc-demeyer 2015-06-02 10:55:44 +02:00 committed by Rodrigo
parent 7b422b6c18
commit 16d05b1397
5 changed files with 22 additions and 12 deletions

View File

@ -4,7 +4,7 @@
# OpenERP, Open Source Management Solution
#
# Copyright (C) 2010-2012 OpenERP s.a. (<http://openerp.com>).
# Copyright (c) 2014 Noviat nv/sa (www.noviat.com). All rights reserved.
# Copyright (c) 2014-2015 Noviat nv/sa (www.noviat.com).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@ -22,7 +22,7 @@
##############################################################################
{
'name': 'Assets Management',
'version': '2.4',
'version': '2.6',
'depends': ['account'],
'conflicts': ['account_asset'],
'author': "OpenERP & Noviat,Odoo Community Association (OCA)",

View File

@ -68,7 +68,8 @@ class account_asset_category(orm.Model):
'name': fields.char('Name', size=64, required=True, select=1),
'note': fields.text('Note'),
'account_analytic_id': fields.many2one(
'account.analytic.account', 'Analytic account'),
'account.analytic.account', 'Analytic account',
domain=[('type', '!=', 'view')]),
'account_asset_id': fields.many2one(
'account.account', 'Asset Account', required=True,
domain=[('type', '=', 'other')]),
@ -1100,6 +1101,9 @@ class account_asset_asset(orm.Model):
type='many2one',
relation='res.currency',
store=True, readonly=True,),
'account_analytic_id': fields.many2one(
'account.analytic.account', 'Analytic account',
domain=[('type', '!=', 'view')]),
}
_defaults = {
@ -1172,6 +1176,7 @@ class account_asset_asset(orm.Model):
'method_period': category_obj.method_period,
'method_progress_factor': category_obj.method_progress_factor,
'prorata': category_obj.prorata,
'account_analytic_id': category_obj.account_analytic_id.id,
}
return res
@ -1575,7 +1580,7 @@ class account_asset_depreciation_line(orm.Model):
elif type == 'expense':
debit = amount > 0 and amount or 0.0
credit = amount < 0 and -amount or 0.0
analytic_id = asset.category_id.account_analytic_id.id
analytic_id = asset.account_analytic_id.id
move_line_data = {
'name': asset.name,
'ref': depreciation_line.name,

View File

@ -3,12 +3,13 @@
<data>
<record model="ir.ui.view" id="view_account_invoice_asset_form">
<field name="name">account.invoice.line.form</field>
<field name="name">account.invoice.form.add.asset_category</field>
<field name="model">account.invoice.line</field>
<field name="inherit_id" ref="account.view_invoice_line_form"/>
<field name="arch" type="xml">
<field name="account_id" position="after">
<field name="asset_category_id"/>
<field name="account_id" position="before">
<field name="asset_id" groups="account.group_account_manager"/>
<field name="asset_category_id" invisible="context.get('type') not in ['in_invoice','in_refund']"/>
</field>
</field>
</record>

View File

@ -11,7 +11,7 @@
<group>
<group>
<field name="name"/>
<field name="parent_id"/>
<field name="parent_id" required="1"/>
<field name="active"/>
<field name="company_id" widget="selection" groups="base.group_multi_company"/>
</group>
@ -126,8 +126,9 @@
</group>
<separator string="Other Information" colspan="4"/>
<group colspan="4" col="4">
<field name="category_id" on_change="onchange_category_id(category_id)" attrs="{'required':[('type','=','normal')]}" colspan="4"/>
<field name="category_id" on_change="onchange_category_id(category_id)" attrs="{'required':[('type','=','normal')]}"/>
<field name="partner_id"/>
<field name="account_analytic_id" groups="analytic.group_analytic_accounting"/>
</group>
<group colspan="4">
<group>

View File

@ -239,6 +239,7 @@ class account_asset_remove(orm.TransientModel):
move_line_vals = {
'name': asset.name,
'account_id': wiz_data.account_residual_value_id.id,
'analytic_account_id': asset.account_analytic_id.id,
'debit': residual_value,
'credit': 0.0,
'partner_id': partner_id,
@ -251,6 +252,7 @@ class account_asset_remove(orm.TransientModel):
move_line_vals = {
'name': asset.name,
'account_id': wiz_data.account_sale_id.id,
'analytic_account_id': asset.account_analytic_id.id,
'debit': sale_value,
'credit': 0.0,
'partner_id': partner_id,
@ -258,12 +260,13 @@ class account_asset_remove(orm.TransientModel):
}
move_lines.append((0, 0, move_line_vals))
balance = wiz_data.sale_value - residual_value
account_id = balance > 0 \
and wiz_data.account_plus_value_id.id \
or wiz_data.account_min_value_id.id
account_id = (wiz_data.account_plus_value_id.id
if balance > 0
else wiz_data.account_min_value_id.id)
move_line_vals = {
'name': asset.name,
'account_id': account_id,
'analytic_account_id': asset.account_analytic_id.id,
'debit': balance < 0 and -balance or 0.0,
'credit': balance > 0 and balance or 0.0,
'partner_id': partner_id,