[FIX] res_lang : if value of thousands_sep is not present in language,method will...
[odoo/odoo.git] / addons / event / event.py
index e45f878..e5485ed 100644 (file)
@@ -1,21 +1,20 @@
-# -*- encoding: utf-8 -*-
+# -*- coding: utf-8 -*-
 ##############################################################################
 #
 #    OpenERP, Open Source Management Solution
-#    Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
-#    $Id$
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
 #
 #    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.
+#    it under the terms of the GNU Affero 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.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
+#    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
@@ -25,6 +24,8 @@ import time
 import netsvc
 import pooler
 import tools
+from tools.translate import _
+from crm import crm
 
 class crm_case_log(osv.osv):
     _inherit = 'crm.case.log'
@@ -76,8 +77,8 @@ class event(osv.osv):
     def _get_register(self, cr, uid, ids, name, args, context=None):
         res={}
         for event in self.browse(cr, uid, ids, context):
-            query = """select sum(nb_register) from crm_case c left join crm_case_section s on (c.section_id=s.id) right join event_event e on (e.section_id=s.id) right join event_registration r on (r.case_id=c.id) where e.section_id = %s and c.state in ('open','done')""" % event.section_id.id
-            cr.execute(query)
+            query = """select sum(nb_register) from crm_case c left join crm_case_section s on (c.section_id=s.id) right join event_event e on (e.section_id=s.id) right join event_registration r on (r.case_id=c.id) where e.section_id = %s and c.state in ('open','done')"""
+            cr.execute(query,(event.section_id.id,))
             res2 = cr.fetchone()
             if res2 and res2[0]:
                 res[event.id] = res2[0]
@@ -88,8 +89,8 @@ class event(osv.osv):
     def _get_prospect(self, cr, uid, ids, name, args, context=None):
         res={}
         for event in self.browse(cr, uid, ids, context):
-            query = """select sum(nb_register) from crm_case c left join crm_case_section s on (c.section_id=s.id) right join event_event e on (e.section_id=s.id) right join event_registration r on (r.case_id=c.id) where e.section_id = %s and c.state = 'draft'""" % event.section_id.id
-            cr.execute(query)
+            query = """select sum(nb_register) from crm_case c left join crm_case_section s on (c.section_id=s.id) right join event_event e on (e.section_id=s.id) right join event_registration r on (r.case_id=c.id) where e.section_id = %s and c.state = 'draft'"""
+            cr.execute(query,(event.section_id.id,))
             res2 = cr.fetchone()
             if res2 and res2[0]:
                 res[event.id] = res2[0]
@@ -130,7 +131,9 @@ class event(osv.osv):
         'register_prospect': fields.function(_get_prospect, method=True, string='Unconfirmed Registrations'),
         'date_begin': fields.datetime('Beginning date', required=True),
         'date_end': fields.datetime('Ending date', required=True),
-        'state': fields.selection([('draft','Draft'),('confirm','Confirmed'),('done','Done'),('cancel','Canceled')], 'Status', readonly=True, required=True),
+        'state': fields.selection([('draft','Draft'),('confirm','Confirmed'),('done','Done'),('cancel','Cancelled')], 'State', readonly=True, required=True,
+                                  help='If event is created, the state is \'Draft\'.\n If event is confirmed for the particular dates the state is set to \'Confirmed\'.\
+                                  \nIf the event is over, the state is set to \'Done\'.\n If event is cancelled the state is set to \'Cancelled\'.'),
         'mail_auto_registr':fields.boolean('Mail Auto Register',help='Check this box if you want to use the automatic mailing for new registration'),
         'mail_auto_confirm':fields.boolean('Mail Auto Confirm',help='Check this box if you want ot use the automatic confirmation emailing or the reminder'),
         'mail_registr':fields.text('Registration Email',help='This email will be sent when someone subscribes to the event.'),
@@ -198,7 +201,7 @@ class event_registration(osv.osv):
             if reg_id.email_cc:
                 dest += [reg_id.email_cc]
             if dest and src:
-                tools.email_send(src, dest,'Auto Confirmation: '+'['+str(reg_id.id)+']'+' '+reg_id.name, reg_id.event_id.mail_confirm, tinycrm = str(reg_id.case_id.id))
+                tools.email_send(src, dest,'Auto Confirmation: '+'['+str(reg_id.id)+']'+' '+reg_id.name, reg_id.event_id.mail_confirm, openobject_id = str(reg_id.case_id.id))
             if not src:
                 raise osv.except_osv(_('Error!'), _('You must define a reply-to address in order to mail the participant. You can do this in the Mailing tab of your event. Note that this is also the place where you can configure your event to not send emails automaticly while registering'))
         return False
@@ -213,9 +216,9 @@ class event_registration(osv.osv):
             if reg_id.event_id.mail_auto_confirm or reg_id.event_id.mail_auto_registr:
                 if dest and src:
                     if reg_id.event_id.state in ['draft', 'fixed', 'open','confirm','running'] and reg_id.event_id.mail_auto_registr:
-                        tools.email_send(src, dest,'Auto Registration: '+'['+str(reg_id.id)+']'+' '+reg_id.name, reg_id.event_id.mail_registr, tinycrm = str(reg_id.case_id.id))
+                        tools.email_send(src, dest,'Auto Registration: '+'['+str(reg_id.id)+']'+' '+reg_id.name, reg_id.event_id.mail_registr, openobject_id = str(reg_id.case_id.id))
                     if (reg_id.event_id.state in ['confirm','running']) and reg_id.event_id.mail_auto_confirm:
-                        tools.email_send(src, dest,'Auto Confirmation: '+'['+str(reg_id.id)+']'+' '+reg_id.name, reg_id.event_id.mail_confirm, tinycrm = str(reg_id.case_id.id))
+                        tools.email_send(src, dest,'Auto Confirmation: '+'['+str(reg_id.id)+']'+' '+reg_id.name, reg_id.event_id.mail_confirm, openobject_id = str(reg_id.case_id.id))
                 if not src:
                     raise osv.except_osv(_('Error!'), _('You must define a reply-to address in order to mail the participant. You can do this in the Mailing tab of your event. Note that this is also the place where you can configure your event to not send emails automaticly while registering'))
         return False
@@ -239,6 +242,16 @@ class event_registration(osv.osv):
         "invoice_label":fields.char("Label Invoice",size=128,required=True),
         "tobe_invoiced":fields.boolean("To be Invoiced"),
         "invoice_id":fields.many2one("account.invoice","Invoice"),
+        'date_closed': fields.datetime('Closed', readonly=True),
+        'ref' : fields.reference('Reference', selection=crm._links_get, size=128),
+        'ref2' : fields.reference('Reference 2', selection=crm._links_get, size=128),  
+        'categ_id': fields.many2one('crm.case.categ','Category', domain="[('section_id','=',section_id)]"),
+        'canal_id': fields.many2one('res.partner.canal', 'Channel',help="The channels represent the different communication modes available with the customer." \
+                                                                        " With each commercial opportunity, you can indicate the canall which is this opportunity source."),
+        'som': fields.many2one('res.partner.som', 'State of Mind', help="The minds states allow to define a value scale which represents" \
+                                                                       "the partner mentality in relation to our services.The scale has" \
+                                                                       "to be created with a factor for each level from 0 (Very dissatisfied) to 10 (Extremely satisfied)."),
+                      
     }
     _defaults = {
         'nb_register': lambda *a: 1,