[FIX] website_forum: use other attr than value to init select2
[odoo/odoo.git] / addons / account_check_writing / report / check_print.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
22 import time
23 from openerp.osv import osv
24 from openerp.report import report_sxw
25
26
27 class report_print_check(report_sxw.rml_parse):
28     def __init__(self, cr, uid, name, context):
29         super(report_print_check, self).__init__(cr, uid, name, context)
30         self.number_lines = 0
31         self.number_add = 0
32         self.localcontext.update({
33             'time': time,
34             'get_lines': self.get_lines,
35             'fill_stars' : self.fill_stars,
36         })
37
38     def fill_stars(self, amount):
39         if len(amount) < 100:
40             stars = 100 - len(amount)
41             return ' '.join([amount,'*'*stars])
42
43         else: return amount
44
45     def get_lines(self, voucher_lines):
46         result = []
47         self.number_lines = len(voucher_lines)
48         for i in range(0, min(10,self.number_lines)):
49             if i < self.number_lines:
50                 res = {
51                     'date_due' : voucher_lines[i].date_due,
52                     'name' : voucher_lines[i].name,
53                     'amount_original' : voucher_lines[i].amount_original and voucher_lines[i].amount_original or False,
54                     'amount_unreconciled' : voucher_lines[i].amount_unreconciled and voucher_lines[i].amount_unreconciled or False,
55                     'amount' : voucher_lines[i].amount and voucher_lines[i].amount or False,
56                 }
57             else :
58                 res = {
59                     'date_due' : False,
60                     'name' : False,
61                     'amount_original' : False,
62                     'amount_due' : False,
63                     'amount' : False,
64                 }
65             result.append(res)
66         return result
67
68
69 class report_check(osv.AbstractModel):
70     _name = 'report.account_check_writing.report_check'
71     _inherit = 'report.abstract_report'
72     _template = 'account_check_writing.report_check'
73     _wrapped_report_class = report_print_check
74
75 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: