1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
6
# $Id: account.py 1005 2005-07-25 08:41:42Z nicoe $
8
# WARNING: This program as such is intended to be used by professional
9
# programmers who take the whole responsability of assessing all potential
10
# consequences resulting from its eventual inadequacies and bugs
11
# End users who are looking for a ready-to-use solution with commercial
12
# garantees and support are strongly adviced to contract a Free Software
15
# This program is Free Software; you can redistribute it and/or
16
# modify it under the terms of the GNU General Public License
17
# as published by the Free Software Foundation; either version 2
18
# of the License, or (at your option) any later version.
20
# This program is distributed in the hope that it will be useful,
21
# but WITHOUT ANY WARRANTY; without even the implied warranty of
22
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
# GNU General Public License for more details.
25
# You should have received a copy of the GNU General Public License
26
# along with this program; if not, write to the Free Software
27
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29
##############################################################################
32
from mx import DateTime
33
from mx.DateTime import now
37
from osv import fields, osv
40
class account_analytic_plan(osv.osv):
41
_name = "account.analytic.plan"
42
_description = "Analytic Plans"
44
'name': fields.char('Plan Name', size=64, required=True, select=True,),
45
'plan_ids': fields.one2many('account.analytic.plan.line','plan_id','Analytic Plans'),
48
account_analytic_plan()
50
class account_analytic_plan_line(osv.osv):
51
_name = "account.analytic.plan.line"
52
_description = "Analytic Plan Lines"
54
'plan_id':fields.many2one('account.analytic.plan','Plan Name'),
55
'name': fields.char('Plan Name', size=64, required=True, select=True),
56
'sequence':fields.integer('Sequence'),
57
'root_analytic_id': fields.many2one('account.analytic.account','Root Account',help="Root account of this plan."),
58
'default_analytic_id':fields.many2one('account.analytic.account','Default Account',help="Default account of this plan."),
60
_order = "sequence,id"
62
account_analytic_plan_line()
64
class account_analytic_plan_instance(osv.osv):
65
_name='account.analytic.plan.instance'
66
_description = 'Object for create analytic entries from invoice lines'
68
'account_ids':fields.one2many('account.analytic.plan.instance.line','plan_id','Account Id'),
69
'account1_ids':fields.one2many('account.analytic.plan.instance.line','plan_id','Account1 Id'),
70
'account2_ids':fields.one2many('account.analytic.plan.instance.line','plan_id','Account2 Id'),
71
'account3_ids':fields.one2many('account.analytic.plan.instance.line','plan_id','Account3 Id'),
72
'account4_ids':fields.one2many('account.analytic.plan.instance.line','plan_id','Account4 Id'),
73
'account5_ids':fields.one2many('account.analytic.plan.instance.line','plan_id','Account5 Id'),
74
'account6_ids':fields.one2many('account.analytic.plan.instance.line','plan_id','Account6 Id'),
77
account_analytic_plan_instance()
79
class account_analytic_plan_instance_line(osv.osv):
80
_name='account.analytic.plan.instance.line'
81
_description = 'Object for create analytic entries from invoice lines'
83
'plan_id':fields.many2one('account.analytic.plan.instance','Plan Id'),
84
'analytic_account_id':fields.many2one('account.analytic.account','Analytic Account'),
85
'rate':fields.float('Rate (%)'),
86
'generated_line_id':fields.many2one('account.analytic.line','Generated Line Id'),
88
def name_get(self, cr, uid, ids, context={}):
91
reads = self.read(cr, uid, ids, ['analytic_account_id'], context)
94
res.append((record['id'], record['analytic_account_id']))
97
account_analytic_plan_instance_line()
99
class account_journal(osv.osv):
100
_inherit='account.journal'
101
_name='account.journal'
103
'plan_id':fields.many2one('account.analytic.plan','Plan Name'),
107
class account_invoice_line(osv.osv):
108
_inherit='account.invoice.line'
109
_name='account.invoice.line'
111
'analytics_id':fields.many2one('account.analytic.plan.instance','Analytic Account'),
113
account_invoice_line()
115
class account_move_line(osv.osv):
116
_inherit='account.move.line'
117
_name='account.move.line'
119
'analytics_id':fields.many2one('account.analytic.plan.instance','Analytic Account'),