From db73adab598ebbbb54dfcb10f4752824dd68bd89 Mon Sep 17 00:00:00 2001 From: "vra (Tiny)" Date: Tue, 16 Jun 2009 18:44:37 +0530 Subject: [PATCH] [ADD] event_certificate module : for Certificate report. bzr revid: vra@tinyerp.com-20090616131437-bd7rr3frzlx88wsg --- addons/event/event_view.xml | 15 ++ addons/event_certificate/__init__.py | 25 +++ addons/event_certificate/__terp__.py | 51 +++++ addons/event_certificate/event_certificate.py | 32 ++++ .../event_certificate_report.xml | 14 ++ .../event_certificate_view.xml | 19 ++ addons/event_certificate/report/__init__.py | 1 + .../report/event_certificate.rml | 176 ++++++++++++++++++ .../report/report_certificate.py | 57 ++++++ addons/event_certificate/report/rml_parse.py | 170 +++++++++++++++++ 10 files changed, 560 insertions(+) create mode 100644 addons/event_certificate/__init__.py create mode 100644 addons/event_certificate/__terp__.py create mode 100644 addons/event_certificate/event_certificate.py create mode 100644 addons/event_certificate/event_certificate_report.xml create mode 100644 addons/event_certificate/event_certificate_view.xml create mode 100644 addons/event_certificate/report/__init__.py create mode 100644 addons/event_certificate/report/event_certificate.rml create mode 100644 addons/event_certificate/report/report_certificate.py create mode 100644 addons/event_certificate/report/rml_parse.py diff --git a/addons/event/event_view.xml b/addons/event/event_view.xml index bb5a4818593..060dffd4b7e 100644 --- a/addons/event/event_view.xml +++ b/addons/event/event_view.xml @@ -279,10 +279,25 @@ tree,form + + + New Registration + event.registration + form + + form,tree + + + + + Unconfirmed Registrations event.registration diff --git a/addons/event_certificate/__init__.py b/addons/event_certificate/__init__.py new file mode 100644 index 00000000000..995f64aac93 --- /dev/null +++ b/addons/event_certificate/__init__.py @@ -0,0 +1,25 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved +# $Id$ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## +import event_certificate +import report +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/event_certificate/__terp__.py b/addons/event_certificate/__terp__.py new file mode 100644 index 00000000000..9071a860e94 --- /dev/null +++ b/addons/event_certificate/__terp__.py @@ -0,0 +1,51 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved +# $Id$ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## + + +{ + 'name': 'Event Certificate', + 'version': '0.1', + 'category': 'Generic Modules/Association', + 'description': """Organization and management of events Certificate. + + This module allow you + * to print certificate related to your events and their registrations + + Note that: + - You can define new types of events in + Events / Configuration / Types of Events + - You can access predefined reports about number of registration per event or per event category in : + Events / Reporting +""", + 'author': 'Tiny', + 'depends': ['event'], + 'init_xml': [], + 'update_xml': [ + 'event_certificate_view.xml', + 'event_certificate_report.xml', + ], + 'demo_xml': [], + 'installable': True, + 'active': False, + 'certificate': '', +} +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/event_certificate/event_certificate.py b/addons/event_certificate/event_certificate.py new file mode 100644 index 00000000000..0a51f96f691 --- /dev/null +++ b/addons/event_certificate/event_certificate.py @@ -0,0 +1,32 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2008 Tiny SPRL (). All Rights Reserved +# $Id$ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## + +from osv import osv, fields + +class event(osv.osv): + _name = 'event.event' + _inherit = 'event.event' + _columns = { + 'trainer_id': fields.many2one('res.partner', 'Trainer'), + } + +event() diff --git a/addons/event_certificate/event_certificate_report.xml b/addons/event_certificate/event_certificate_report.xml new file mode 100644 index 00000000000..c0c79b8c355 --- /dev/null +++ b/addons/event_certificate/event_certificate_report.xml @@ -0,0 +1,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/addons/event_certificate/event_certificate_view.xml b/addons/event_certificate/event_certificate_view.xml new file mode 100644 index 00000000000..b8e8f29f725 --- /dev/null +++ b/addons/event_certificate/event_certificate_view.xml @@ -0,0 +1,19 @@ + + + + + + events.inherit + event.event + + form + + + + + + + + + + \ No newline at end of file diff --git a/addons/event_certificate/report/__init__.py b/addons/event_certificate/report/__init__.py new file mode 100644 index 00000000000..39ca5cd6904 --- /dev/null +++ b/addons/event_certificate/report/__init__.py @@ -0,0 +1 @@ +import report_certificate diff --git a/addons/event_certificate/report/event_certificate.rml b/addons/event_certificate/report/event_certificate.rml new file mode 100644 index 00000000000..ec0b042a8db --- /dev/null +++ b/addons/event_certificate/report/event_certificate.rml @@ -0,0 +1,176 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [[repeatIn(objects,'event')]] + + + + [[ event.event_id.type and event.event_id.type.name ]] Certifications + + + + + + + + + + + + + [[ event.partner_id and event.partner_id.name or removeParentNode('para') ]] + + + + + + + + + + + + + HAS SUCCESSFULLY COMPLETED + + + + + + + [[ event.event_id.name ]] + + + + + + + + + + + + [[ get_date( formatLang(event.event_id.date_begin, date_time=True), formatLang(event.event_id.date_end, date_time=True) ) ]] + + + + + + + + + + + + + + + + + + + [[ company.partner_id.name ]] + [[ company.partner_id.address and company.partner_id.address[0].street or '' ]] + [[ company.partner_id.address and company.partner_id.address[0].zip or '' ]] [[ company.partner_id.address and company.partner_id.address[0].city or '' ]] - [[ company.partner_id.address and company.partner_id.address[0].country_id and company.partner_id.address[0].country_id.name or '']] + Phone: [[ company.partner_id.address and company.partner_id.address[0].phone or '' ]] + Mail: [[ company.partner_id.address and company.partner_id.address[0].email or '' ]] + + + [[ event.event_id.trainer_id.name or '' ]] + Trainer + + + + + + + + diff --git a/addons/event_certificate/report/report_certificate.py b/addons/event_certificate/report/report_certificate.py new file mode 100644 index 00000000000..19a82baad2d --- /dev/null +++ b/addons/event_certificate/report/report_certificate.py @@ -0,0 +1,57 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved +# $Id$ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## + +import time +import mx.DateTime +from report import report_sxw +from osv import osv +import pooler +import rml_parse + +class event_certificate(rml_parse.rml_parse): + def __init__(self, cr, uid, name, context): + super(event_certificate, self).__init__(cr, uid, name, context) + self.localcontext.update({ + 'time': time, + 'get_date':self.get_date, + }) + + def get_date(self,st_date,end_date): + date_res = '' + print "st_date::end_date",str(st_date),str(end_date) + try: + d1 = mx.DateTime.strptime(str(st_date),'%d/%m/%Y %H:%M:%S') + d2 = mx.DateTime.strptime(str(end_date),'%d/%m/%Y %H:%M:%S') + print "d1:::d2",d1,d2 + new_d1 = d1.strftime('%d %B %Y %H:%M:%S') + new_d2 = d2.strftime('%d %B %Y %H:%M:%S') + print "new_d1:::new_d2",new_d1,new_d2 + date_res = str(new_d1) +" "+ 'To' +" "+ str(new_d2) + print "date_res:::",date_res + except Exception,e: + print "e:::",e + pass + return date_res + + +report_sxw.report_sxw('report.event.certificate','event.registration','event_certificate/report/event_certificate.rml',parser=event_certificate) +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/event_certificate/report/rml_parse.py b/addons/event_certificate/report/rml_parse.py new file mode 100644 index 00000000000..83176784be7 --- /dev/null +++ b/addons/event_certificate/report/rml_parse.py @@ -0,0 +1,170 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved +# $Id$ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## +from report import report_sxw +import xml.dom.minidom +import os, time +import osv +import re +import tools +import pooler +import re +import sys + + +class rml_parse(report_sxw.rml_parse): + def __init__(self, cr, uid, name, context): + super(rml_parse, self).__init__(cr, uid, name, context=None) + self.localcontext.update({ + 'comma_me': self.comma_me, + 'format_date': self._get_and_change_date_format_for_swiss, + 'strip_name' : self._strip_name, + 'explode_name' : self._explode_name, + }) + + def comma_me(self,amount): + #print "#" + str(amount) + "#" + if not amount: + amount = 0.0 + if type(amount) is float : + amount = str('%.2f'%amount) + else : + amount = str(amount) + if (amount == '0'): + return ' ' + orig = amount + new = re.sub("^(-?\d+)(\d{3})", "\g<1>'\g<2>", amount) + if orig == new: + return new + else: + return self.comma_me(new) + + def _ellipsis(self, string, maxlen=100, ellipsis = '...'): + ellipsis = ellipsis or '' + try: + return string[:maxlen - len(ellipsis) ] + (ellipsis, '')[len(string) < maxlen] + except Exception, e: + return False + + def _strip_name(self, name, maxlen=50): + return self._ellipsis(name, maxlen, '...') + + def _get_and_change_date_format_for_swiss (self,date_to_format): + date_formatted='' + if date_to_format: + date_formatted = strptime (date_to_format,'%Y-%m-%d').strftime('%d.%m.%Y') + return date_formatted + + def _explode_name(self,chaine,length): + # We will test if the size is less then account + full_string = '' + if (len(str(chaine)) <= length): + return chaine + # + else: + chaine = unicode(chaine,'utf8').encode('iso-8859-1') + rup = 0 + for carac in chaine: + rup = rup + 1 + if rup == length: + full_string = full_string + '\n' + full_string = full_string + carac + rup = 0 + else: + full_string = full_string + carac + + return full_string + + def makeAscii(self,str): + try: + Stringer = str.encode("utf-8") + except UnicodeDecodeError: + try: + Stringer = str.encode("utf-16") + except UnicodeDecodeError: + print "UTF_16 Error" + Stringer = str + else: + return Stringer + else: + return Stringer + return Stringer + + def explode_this(self,chaine,length): + #chaine = self.repair_string(chaine) + chaine = rstrip(chaine) + ast = list(chaine) + i = length + while i <= len(ast): + ast.insert(i,'\n') + i = i + length + chaine = str("".join(ast)) + return chaine + + def repair_string(self,chaine): + ast = list(chaine) + UnicodeAst = [] + _previouslyfound = False + i = 0 + #print str(ast) + while i < len(ast): + elem = ast[i] + try: + Stringer = elem.encode("utf-8") + except UnicodeDecodeError: + to_reencode = elem + ast[i+1] + print str(to_reencode) + Good_char = to_reencode.decode('utf-8') + UnicodeAst.append(Good_char) + i += i +2 + else: + UnicodeAst.append(elem) + i += i + 1 + + + return "".join(UnicodeAst) + + def ReencodeAscii(self,str): + print sys.stdin.encoding + try: + Stringer = str.decode("ascii") + except UnicodeEncodeError: + print "REENCODING ERROR" + return str.encode("ascii") + except UnicodeDecodeError: + print "DECODING ERROR" + return str.encode("ascii") + + else: + print Stringer + return Stringer + + def _add_header(self, node, header=1): + if header==2: + rml_head = self.rml_header2 + else: + rml_head = self.rml_header + rml_head = rml_head.replace('',''' [[company.logo]] ''') + return True + + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: