Launchpad automatic translations update.
[odoo/odoo.git] / addons / account_reporting / account.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #    
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6 #
7 #    This program is free software: you can redistribute it and/or modify
8 #    it under the terms of the GNU Affero General Public License as
9 #    published by the Free Software Foundation, either version 3 of the
10 #    License, or (at your option) any later version.
11 #
12 #    This program is distributed in the hope that it will be useful,
13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #    GNU Affero General Public License for more details.
16 #
17 #    You should have received a copy of the GNU Affero General Public License
18 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.     
19 #
20 ##############################################################################
21 import time
22 import netsvc
23 from osv import fields, osv
24
25 from tools.misc import currency
26
27 import mx.DateTime
28 from mx.DateTime import RelativeDateTime, now, DateTime, localtime
29
30
31 class color_rml(osv.osv):
32     _name = "color.rml"
33     _description = "Rml Colors"
34     _columns = {
35         'name': fields.char('Name', size=64, required=True),
36         'code': fields.char('code',size=64,required=True),
37         }
38
39 color_rml()
40
41 class account_report_bs(osv.osv):
42     _name = "account.report.bs"
43     _description = "Account reporting for Balance Sheet"
44     _font = [
45              ('',''),
46              ('Courier','Courier'),
47              ('Courier-Bold','Courier-Bold'),
48              ('Courier-BoldOblique','Courier-BoldOblique'),
49              ('Courier-Oblique','Courier-Oblique'),
50              ('Helvetica','Helvetica'),
51              ('Helvetica-Bold','Helvetica-Bold'),
52              ('Helvetica-Oblique','Helvetica-Oblique'),
53              ('Times-Bold','Times-Bold'),
54              ('Times-BoldItalic','Times-BoldItalic'),
55              ('Times-Italic','Times-Italic'),
56              ('Times-Roman','Times-Roman'),
57             ]
58     _color = [
59             ('', ''),
60             ('green','Green'),
61             ('red','Red'),
62             ('pink','Pink'),
63             ('blue','Blue'),
64             ('yellow','Yellow'),
65             ('cyan','Cyan'),
66             ('lightblue','Light Blue'),
67             ('orange','Orange'),
68             ]
69     _style = [
70             ('', ''),
71             ('h1','Header 1'),
72             ('h2','Header 2'),
73             ('h3','Header 3'),
74             ]
75
76     def onchange_parent_id(self, cr, uid, ids, parent_id):
77         v={}
78         if parent_id:
79             acc=self.pool.get('account.report.report').browse(cr,uid,parent_id)
80             v['type']=acc.type
81             if int(acc.style) < 6:
82                 v['style'] = str(int(acc.style)+1)
83         return {'value': v}
84
85     _columns = {
86         'name': fields.char('Name', size=64, required=True),
87         'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of account reporting for balance sheet."),
88         'code': fields.char('Code', size=64, required=True),
89         'account_id': fields.many2many('account.account', 'account_report_rel', 'report_id', 'account_id', 'Accounts'),
90         'note': fields.text('Note'),
91 #       'style': fields.selection(_style, 'Style'),
92         'color_font' : fields.many2one('color.rml','Font Color'),
93         'color_back' : fields.many2one('color.rml','Back Color'),
94         'font_style' : fields.selection(_font, 'Font'),
95         'parent_id': fields.many2one('account.report.bs', 'Parent'),
96         'child_id': fields.one2many('account.report.bs', 'parent_id', 'Children'),
97         '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")
98     }
99     _defaults = {
100         'report_type': lambda *a :'only_obj',
101         'color_font': lambda *a :'',
102         'color_back': lambda *a :'',
103         'font_style': lambda *a :'',
104     }
105
106     def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100):
107         if not args:
108             args=[]
109         if not context:
110             context={}
111         ids = []
112         if name:
113             ids = self.search(cr, user, [('code','=',name)]+ args, limit=limit, context=context)
114             if not ids:
115                 ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit, context=context)
116         else:
117             ids = self.search(cr, user, args, limit=limit, context=context)
118         return self.name_get(cr, user, ids, context=context)
119
120 account_report_bs()
121
122
123 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
124