~openerp-commiter/openobject-addons/trunk-extra-addons

« back to all changes in this revision

Viewing changes to account_reporting/account.py

  • Committer: Husen Daudi
  • Date: 2007-12-03 12:46:31 UTC
  • Revision ID: hda@tinyerp.com-6aa6e597273351ab1aba092a0c5fd756e81e37e3
Module to make Account->Invoic->customer Invoice-> Invoice Line->Analytic account required. 

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
 
import time
31
 
import netsvc
32
 
from osv import fields, osv
33
 
 
34
 
from tools.misc import currency
35
 
 
36
 
import mx.DateTime
37
 
from mx.DateTime import RelativeDateTime, now, DateTime, localtime
38
 
 
39
 
 
40
 
class color_rml(osv.osv):
41
 
        _name = "color.rml"
42
 
        _description = "Rml Colors"
43
 
        _columns = {
44
 
                'name': fields.char('Name', size=64, required=True),
45
 
                'code': fields.char('code',size=64,required=True),
46
 
                }
47
 
 
48
 
color_rml()
49
 
 
50
 
class account_report_bs(osv.osv):
51
 
        _name = "account.report.bs"
52
 
        _description = "Account reporting for Balance Sheet"
53
 
        _font = [
54
 
                         ('',''),
55
 
                         ('Courier','Courier'),
56
 
                         ('Courier-Bold','Courier-Bold'),
57
 
                         ('Courier-BoldOblique','Courier-BoldOblique'),
58
 
                         ('Courier-Oblique','Courier-Oblique'),
59
 
                         ('Helvetica','Helvetica'),
60
 
                         ('Helvetica-Bold','Helvetica-Bold'),
61
 
                         ('Helvetica-Oblique','Helvetica-Oblique'),
62
 
                         ('Symbol','Symbol'),
63
 
                         ('Times-Bold','Times-Bold'),
64
 
                         ('Times-BoldItalic','Times-BoldItalic'),
65
 
                         ('Times-Italic','Times-Italic'),
66
 
                         ('Times-Roman','Times-Roman'),
67
 
                        ]
68
 
        _color = [
69
 
                        ('', ''),
70
 
                        ('green','Green'),
71
 
                        ('red','Red'),
72
 
                        ('pink','Pink'),
73
 
                        ('blue','Blue'),
74
 
                        ('yellow','Yellow'),
75
 
                        ('cyan','Cyan'),
76
 
                        ('lightblue','Light Blue'),
77
 
                        ('orange','Orange'),
78
 
                        ]
79
 
        _style = [
80
 
                        ('', ''),
81
 
                        ('h1','Header 1'),
82
 
                        ('h2','Header 2'),
83
 
                        ('h3','Header 3'),
84
 
                        ]
85
 
 
86
 
        def onchange_parent_id(self, cr, uid, ids, parent_id):
87
 
                v={}
88
 
                if parent_id:
89
 
                        acc=self.pool.get('account.report.report').browse(cr,uid,parent_id)
90
 
                        v['type']=acc.type
91
 
                        if int(acc.style) < 6:
92
 
                                v['style'] = str(int(acc.style)+1)
93
 
                return {'value': v}
94
 
 
95
 
        _columns = {
96
 
                'name': fields.char('Name', size=64, required=True),
97
 
                'sequence': fields.integer('Sequence'),
98
 
                'code': fields.char('Code', size=64, required=True),
99
 
                'account_id': fields.many2many('account.account', 'account_report_rel', 'report_id', 'account_id', 'Accounts'),
100
 
                'note': fields.text('Note'),
101
 
#               'style': fields.selection(_style, 'Style'),
102
 
                'color_font' : fields.many2one('color.rml','Font Color'),
103
 
                'color_back' : fields.many2one('color.rml','Back Color'),
104
 
                'font_style' : fields.selection(_font, 'Font'),
105
 
                'parent_id': fields.many2one('account.report.bs', 'Parent'),
106
 
                'child_id': fields.one2many('account.report.bs', 'parent_id', 'Childs'),
107
 
        }
108
 
 
109
 
        def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
110
 
                if not args:
111
 
                        args=[]
112
 
                if not context:
113
 
                        context={}
114
 
                ids = []
115
 
                if name:
116
 
                        ids = self.search(cr, user, [('code','=',name)]+ args, limit=limit, context=context)
117
 
                        if not ids:
118
 
                                ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit, context=context)
119
 
                else:
120
 
                        ids = self.search(cr, user, args, limit=limit, context=context)
121
 
                return self.name_get(cr, user, ids, context=context)
122
 
 
123
 
        _sql_constraints = [
124
 
                ('code_uniq', 'unique (code)', 'The code of the report entry must be unique !')
125
 
        ]
126
 
 
127
 
account_report_bs()
128
 
 
129