~sistheo/openerp/trunk-l10n_fr_pcg

« back to all changes in this revision

Viewing changes to account_analytic_plans/account_analytic_plans.py

  • Committer: Husen Daudi
  • Date: 2008-02-15 06:18:10 UTC
  • Revision ID: hda@tinyerp.com-3c808fa0549dff098ff5a120bb8d6cb7e4af30bc
define objects and views in account_analytic_plans

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
 
5
#
 
6
# $Id: account.py 1005 2005-07-25 08:41:42Z nicoe $
 
7
#
 
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
 
13
# Service Company
 
14
#
 
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.
 
19
#
 
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.
 
24
#
 
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.
 
28
#
 
29
##############################################################################
 
30
from xml import dom
 
31
 
 
32
from mx import DateTime
 
33
from mx.DateTime import now
 
34
import time
 
35
 
 
36
import netsvc
 
37
from osv import fields, osv
 
38
import ir
 
39
 
 
40
class account_analytic_plan(osv.osv):
 
41
    _name = "account.analytic.plan"
 
42
    _description = "Analytic Plans"
 
43
    _columns = {
 
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'),
 
46
    }
 
47
 
 
48
account_analytic_plan()
 
49
 
 
50
class account_analytic_plan_line(osv.osv):
 
51
    _name = "account.analytic.plan.line"
 
52
    _description = "Analytic Plan Lines"
 
53
    _columns = {
 
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."),
 
59
    }
 
60
    _order = "sequence,id"
 
61
 
 
62
account_analytic_plan_line()
 
63
 
 
64
class account_analytic_plan_instance(osv.osv):
 
65
    _name='account.analytic.plan.instance'
 
66
    _description = 'Object for create analytic entries from invoice lines'
 
67
    _columns={
 
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'),
 
75
              }
 
76
 
 
77
account_analytic_plan_instance()
 
78
 
 
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'
 
82
    _columns={
 
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'),
 
87
              }
 
88
    def name_get(self, cr, uid, ids, context={}):
 
89
        if not len(ids):
 
90
            return []
 
91
        reads = self.read(cr, uid, ids, ['analytic_account_id'], context)
 
92
        res = []
 
93
        for record in reads:
 
94
            res.append((record['id'], record['analytic_account_id']))
 
95
        return res
 
96
 
 
97
account_analytic_plan_instance_line()
 
98
 
 
99
class account_journal(osv.osv):
 
100
    _inherit='account.journal'
 
101
    _name='account.journal'
 
102
    _columns = {
 
103
            'plan_id':fields.many2one('account.analytic.plan','Plan Name'),
 
104
                }
 
105
account_journal()
 
106
 
 
107
class account_invoice_line(osv.osv):
 
108
    _inherit='account.invoice.line'
 
109
    _name='account.invoice.line'
 
110
    _columns = {
 
111
            'analytics_id':fields.many2one('account.analytic.plan.instance','Analytic Account'),
 
112
                }
 
113
account_invoice_line()
 
114
 
 
115
class account_move_line(osv.osv):
 
116
    _inherit='account.move.line'
 
117
    _name='account.move.line'
 
118
    _columns = {
 
119
            'analytics_id':fields.many2one('account.analytic.plan.instance','Analytic Account'),
 
120
                }
 
121
account_move_line()
 
122