1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ##############################################################################
27 from report import report_sxw
29 class report_rappel(report_sxw.rml_parse):
30 def __init__(self, cr, uid, name, context):
31 super(report_rappel, self).__init__(cr, uid, name, context)
32 self.localcontext.update( {
34 'ids_to_objects': self._ids_to_objects,
35 'adr_get' : self._adr_get,
36 'getLines' : self._lines_get,
37 'get_text' : self._get_text
40 def _ids_to_objects(self, partners_ids):
41 pool = pooler.get_pool(self.cr.dbname)
43 for partner in partners_ids:
44 partners = pool.get('account_followup.stat').browse(self.cr, self.uid, partner[2])
46 all_partners.append(par.name)
49 def _adr_get(self, partner, type):
50 res_partner = pooler.get_pool(self.cr.dbname).get('res.partner')
51 res_partner_address = pooler.get_pool(self.cr.dbname).get('res.partner.address')
52 adr = res_partner.address_get(self.cr, self.uid, [partner.id], [type])[type]
53 return res_partner_address.read(self.cr, self.uid, [adr])
55 def _lines_get(self, partner):
56 moveline_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
57 movelines = moveline_obj.search(self.cr, self.uid,
58 [('partner_id', '=', partner.id),
59 ('account_id.type', '=', 'receivable'),
60 ('reconcile_id', '=', False), ('state', '<>', 'draft')])
61 movelines = moveline_obj.read(self.cr, self.uid, movelines)
64 def _get_text(self, partner):
67 partner_line = pooler.get_pool(self.cr.dbname).get('account.move.line').search(self.cr, self.uid, [('partner_id','=',partner.id)])
68 for i in pooler.get_pool(self.cr.dbname).get('account.move.line').browse(self.cr, self.uid, partner_line):
69 if i.followup_line_id and str(i.followup_line_id.delay)=='45':
70 text = i.followup_line_id.description
72 elif i.followup_line_id and str(i.followup_line_id.delay)=='30':
73 text = i.followup_line_id.description
75 elif i.followup_line_id and str(i.followup_line_id.delay)=='15':
76 text = i.followup_line_id.description
78 text = (a.has_key('45') and a['45']) or (a.has_key('30') and a['30']) or (a.has_key('15') and a['15'])
79 text = text % {'partner_name':partner.name}
83 report_sxw.report_sxw('report.account_followup.followup.print',
84 'res.partner', 'addons/account_followup/report/rappel.rml',
87 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: