translations files are by modules
[odoo/odoo.git] / addons / account_reporting / account.py
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              ('Times-Bold','Times-Bold'),
63              ('Times-BoldItalic','Times-BoldItalic'),
64              ('Times-Italic','Times-Italic'),
65              ('Times-Roman','Times-Roman'),
66             ]
67     _color = [
68             ('', ''),
69             ('green','Green'),
70             ('red','Red'),
71             ('pink','Pink'),
72             ('blue','Blue'),
73             ('yellow','Yellow'),
74             ('cyan','Cyan'),
75             ('lightblue','Light Blue'),
76             ('orange','Orange'),
77             ]
78     _style = [
79             ('', ''),
80             ('h1','Header 1'),
81             ('h2','Header 2'),
82             ('h3','Header 3'),
83             ]
84
85     def onchange_parent_id(self, cr, uid, ids, parent_id):
86         v={}
87         if parent_id:
88             acc=self.pool.get('account.report.report').browse(cr,uid,parent_id)
89             v['type']=acc.type
90             if int(acc.style) < 6:
91                 v['style'] = str(int(acc.style)+1)
92         return {'value': v}
93
94     _columns = {
95         'name': fields.char('Name', size=64, required=True),
96         'sequence': fields.integer('Sequence'),
97         'code': fields.char('Code', size=64, required=True),
98         'account_id': fields.many2many('account.account', 'account_report_rel', 'report_id', 'account_id', 'Accounts'),
99         'note': fields.text('Note'),
100 #       'style': fields.selection(_style, 'Style'),
101         'color_font' : fields.many2one('color.rml','Font Color'),
102         'color_back' : fields.many2one('color.rml','Back Color'),
103         'font_style' : fields.selection(_font, 'Font'),
104         'parent_id': fields.many2one('account.report.bs', 'Parent'),
105         'child_id': fields.one2many('account.report.bs', 'parent_id', 'Childs'),
106         'report_type' : fields.selection([('only_obj', 'Report Objects Only'),('with_account', 'Report Objects With Accounts'),('acc_with_child', 'Report Objects With Accounts and child of Accounts')],"Report Type")
107     }
108     _defaults = {
109         'report_type': lambda *a :'only_obj'
110     }
111
112     def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
113         if not args:
114             args=[]
115         if not context:
116             context={}
117         ids = []
118         if name:
119             ids = self.search(cr, user, [('code','=',name)]+ args, limit=limit, context=context)
120             if not ids:
121                 ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit, context=context)
122         else:
123             ids = self.search(cr, user, args, limit=limit, context=context)
124         return self.name_get(cr, user, ids, context=context)
125
126     _sql_constraints = [
127         ('code_uniq', 'unique (code)', 'The code of the report entry must be unique !')
128     ]
129
130 account_report_bs()
131
132
133 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
134