[FIX] split the button_confirm and registration_open function in event and the super function in event_moodle
bzr revid: mva@openerp.com-20120228120134-k38kkxj2d5ylrw53
This commit is contained in:
parent
5806856a7e
commit
97e7843377
|
@ -103,25 +103,31 @@ class event_event(osv.osv):
|
||||||
def button_done(self, cr, uid, ids, context=None):
|
def button_done(self, cr, uid, ids, context=None):
|
||||||
return self.write(cr, uid, ids, {'state': 'done'}, context=context)
|
return self.write(cr, uid, ids, {'state': 'done'}, context=context)
|
||||||
|
|
||||||
def button_confirm(self, cr, uid, ids, context=None):
|
def confirmation_event(self,cr,uid,ids,context=None):
|
||||||
""" Confirm Event and send confirmation email to all register peoples
|
|
||||||
"""
|
|
||||||
if isinstance(ids, (int, long)):
|
|
||||||
ids = [ids]
|
|
||||||
#renforcing method : create a list of ids
|
|
||||||
register_pool = self.pool.get('event.registration')
|
register_pool = self.pool.get('event.registration')
|
||||||
for event in self.browse(cr, uid, ids, context=context):
|
for self.event in self.browse(cr, uid, ids, context=context):
|
||||||
total_confirmed = event.register_current
|
total_confirmed = self.event.register_current
|
||||||
if total_confirmed < event.register_min or total_confirmed > event.register_max and event.register_max!=0:
|
if total_confirmed < self.event.register_min or total_confirmed > self.event.register_max and self.event.register_max!=0:
|
||||||
raise osv.except_osv(_('Error!'),_("The total of confirmed registration for the event '%s' does not meet the expected minimum/maximum. You should maybe reconsider those limits before going further") % (event.name))
|
raise osv.except_osv(_('Error!'),_("The total of confirmed registration for the event '%s' does not meet the expected minimum/maximum. You should maybe reconsider those limits before going further") % (self.event.name))
|
||||||
if event.email_confirmation_id:
|
|
||||||
|
def confirmation_email(self,cr,uid,ids,context=None):
|
||||||
|
if self.event.email_confirmation_id:
|
||||||
#send reminder that will confirm the event for all the people that were already confirmed
|
#send reminder that will confirm the event for all the people that were already confirmed
|
||||||
reg_ids = register_pool.search(cr, uid, [
|
reg_ids = register_pool.search(cr, uid, [
|
||||||
('event_id', '=', event.id),
|
('event_id', '=', self.event.id),
|
||||||
('state', 'not in', ['draft', 'cancel'])], context=context)
|
('state', 'not in', ['draft', 'cancel'])], context=context)
|
||||||
register_pool.mail_user_confirm(cr, uid, reg_ids)
|
register_pool.mail_user_confirm(cr, uid, reg_ids)
|
||||||
return self.write(cr, uid, ids, {'state': 'confirm'}, context=context)
|
return self.write(cr, uid, ids, {'state': 'confirm'}, context=context)
|
||||||
|
|
||||||
|
def button_confirm(self, cr, uid, ids, context=None):
|
||||||
|
""" Confirm Event and send confirmation email to all register peoples
|
||||||
|
"""
|
||||||
|
#renforcing method : create a list of ids
|
||||||
|
if isinstance(ids, (int, long)):
|
||||||
|
ids = [ids]
|
||||||
|
self.confirmation_event(cr,uid,ids,context=context)
|
||||||
|
self.confirmation_email(cr,uid,ids,context=context)
|
||||||
|
return True
|
||||||
def _get_register(self, cr, uid, ids, fields, args, context=None):
|
def _get_register(self, cr, uid, ids, fields, args, context=None):
|
||||||
"""Get Confirm or uncofirm register value.
|
"""Get Confirm or uncofirm register value.
|
||||||
@param ids: List of Event registration type's id
|
@param ids: List of Event registration type's id
|
||||||
|
@ -254,13 +260,19 @@ class event_registration(osv.osv):
|
||||||
def do_draft(self, cr, uid, ids, context=None):
|
def do_draft(self, cr, uid, ids, context=None):
|
||||||
return self.write(cr, uid, ids, {'state': 'draft'}, context=context)
|
return self.write(cr, uid, ids, {'state': 'draft'}, context=context)
|
||||||
|
|
||||||
|
def confirmation_registration(self, cr, uid, ids, context=None):
|
||||||
|
res = self.write(cr, uid, ids, {'state': 'open'}, context=context)
|
||||||
|
self.message_append(cr, uid, ids,_('State set to...'),body_text= _('Open'))
|
||||||
|
return res
|
||||||
|
|
||||||
|
def email_registration(self, cr, uid, ids, context=None):
|
||||||
|
self.mail_user(cr, uid, ids)
|
||||||
|
|
||||||
def registration_open(self, cr, uid, ids, context=None):
|
def registration_open(self, cr, uid, ids, context=None):
|
||||||
""" Open Registration
|
""" Open Registration
|
||||||
"""
|
"""
|
||||||
res = self.write(cr, uid, ids, {'state': 'open'}, context=context)
|
self.confirmation_registration(cr, uid, ids, context=context)
|
||||||
self.mail_user(cr, uid, ids)
|
self.email_registration(cr, uid, ids, context=context)
|
||||||
self.message_append(cr, uid, ids,_('State set to...'),body_text= _('Open'))
|
|
||||||
return res
|
|
||||||
|
|
||||||
def button_reg_close(self, cr, uid, ids, context=None):
|
def button_reg_close(self, cr, uid, ids, context=None):
|
||||||
""" Close Registration
|
""" Close Registration
|
||||||
|
|
|
@ -157,12 +157,11 @@ class event_event(osv.osv):
|
||||||
'moodle_id': fields.integer('Moodle ID', help='The identifier of this event in Moodle'),
|
'moodle_id': fields.integer('Moodle ID', help='The identifier of this event in Moodle'),
|
||||||
}
|
}
|
||||||
|
|
||||||
def button_confirm(self, cr, uid, ids, context=None):
|
def confirmation_event(self, cr, uid, ids, context=None):
|
||||||
"""
|
"""
|
||||||
create moodle courses ,users and match them when an event is confirmed
|
create moodle courses ,users and match them when an event is confirmed
|
||||||
if the event_registration is not confirmed then it doesn t nothing
|
if the event_registration is not confirmed then it doesn t nothing
|
||||||
"""
|
"""
|
||||||
res =super(event_event, self).button_confirm(cr, uid, ids, context)
|
|
||||||
moodle_pool = self.pool.get('event.moodle.config.wiz')
|
moodle_pool = self.pool.get('event.moodle.config.wiz')
|
||||||
moodle_config_wiz_id = moodle_pool.find(cr, uid, context=context)
|
moodle_config_wiz_id = moodle_pool.find(cr, uid, context=context)
|
||||||
list_users=[]
|
list_users=[]
|
||||||
|
@ -217,7 +216,7 @@ class event_event(osv.osv):
|
||||||
'courseid' :response_courses[0]['id']
|
'courseid' :response_courses[0]['id']
|
||||||
})
|
})
|
||||||
moodle_pool.moodle_enrolled(cr, uid, moodle_config_wiz_id, enrolled, context=context)
|
moodle_pool.moodle_enrolled(cr, uid, moodle_config_wiz_id, enrolled, context=context)
|
||||||
return res
|
return super(event_event, self).confirmation_event(cr, uid, ids, context)
|
||||||
|
|
||||||
event_event()
|
event_event()
|
||||||
|
|
||||||
|
@ -231,11 +230,10 @@ class event_registration(osv.osv):
|
||||||
'moodle_uid': fields.integer('Moodle User ID'),
|
'moodle_uid': fields.integer('Moodle User ID'),
|
||||||
}
|
}
|
||||||
|
|
||||||
def registration_open(self, cr, uid, ids, context=None):
|
def confirmation_registration(self, cr, uid, ids, context=None):
|
||||||
"""
|
"""
|
||||||
create a user and match to a course if the event is already confirmed
|
create a user and match to a course if the event is already confirmed
|
||||||
"""
|
"""
|
||||||
res = super(event_registration, self).registration_open(cr, uid, ids, context=context)
|
|
||||||
moodle_pool = self.pool.get('event.moodle.config.wiz')
|
moodle_pool = self.pool.get('event.moodle.config.wiz')
|
||||||
moodle_config_wiz_id = moodle_pool.find(cr, uid, context=context)
|
moodle_config_wiz_id = moodle_pool.find(cr, uid, context=context)
|
||||||
for register in self.browse(cr, uid, ids, context=context):
|
for register in self.browse(cr, uid, ids, context=context):
|
||||||
|
@ -265,7 +263,7 @@ class event_registration(osv.osv):
|
||||||
'courseid': register.event_id.moodle_id
|
'courseid': register.event_id.moodle_id
|
||||||
}]
|
}]
|
||||||
moodle_pool.moodle_enrolled(cr, uid, moodle_config_wiz_id, enrolled, context=context)
|
moodle_pool.moodle_enrolled(cr, uid, moodle_config_wiz_id, enrolled, context=context)
|
||||||
return res
|
return super(event_registration, self).confirmation_registration(cr, uid, ids, context=context)
|
||||||
|
|
||||||
def onchange_moodle_name(self, cr, uid, ids, moodle_username, context=None):
|
def onchange_moodle_name(self, cr, uid, ids, moodle_username, context=None):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue