[IMP] event,event_sale: refactoring; remove crappy 9999 hardcoded values; remove visibility; add constraints
bzr revid: chm@openerp.com-20140127135828-z848mvpis5d9xyh8
This commit is contained in:
parent
33d349f33b
commit
43044d8ee7
|
@ -10,7 +10,7 @@
|
||||||
<field name="event_id"/>
|
<field name="event_id"/>
|
||||||
<field name="draft_state" operator="+"/>
|
<field name="draft_state" operator="+"/>
|
||||||
<field name="confirm_state" operator="+"/>
|
<field name="confirm_state" operator="+"/>
|
||||||
<field name="register_max" operator="+"/>
|
<field name="seats_max" operator="+"/>
|
||||||
</graph>
|
</graph>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
|
@ -91,69 +91,34 @@ 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 check_registration_limits(self, cr, uid, ids, context=None):
|
|
||||||
for self.event in self.browse(cr, uid, ids, context=context):
|
|
||||||
total_confirmed = self.event.register_current
|
|
||||||
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. Please reconsider those limits before going further.") % (self.event.name))
|
|
||||||
|
|
||||||
def check_registration_limits_before(self, cr, uid, ids, no_of_registration, context=None):
|
|
||||||
for event in self.browse(cr, uid, ids, context=context):
|
|
||||||
available_seats = event.register_avail
|
|
||||||
if available_seats and no_of_registration > available_seats:
|
|
||||||
raise osv.except_osv(_('Warning!'),_("Only %d Seats are Available!") % (available_seats))
|
|
||||||
elif available_seats == 0:
|
|
||||||
raise osv.except_osv(_('Warning!'),_("No Tickets Available!"))
|
|
||||||
|
|
||||||
def confirm_event(self, cr, uid, ids, context=None):
|
def confirm_event(self, cr, uid, ids, context=None):
|
||||||
register_pool = self.pool.get('event.registration')
|
register_pool = self.pool.get('event.registration')
|
||||||
if self.event.email_confirmation_id:
|
for event in self.browse(cr, uid, ids, context=context):
|
||||||
#send reminder that will confirm the event for all the people that were already confirmed
|
if event.email_confirmation_id:
|
||||||
reg_ids = register_pool.search(cr, uid, [
|
#send reminder that will confirm the event for all the people that were already confirmed
|
||||||
('event_id', '=', self.event.id),
|
reg_ids = register_pool.search(cr, uid, [
|
||||||
('state', 'not in', ['draft', 'cancel'])], context=context)
|
('event_id', '=', event.id),
|
||||||
register_pool.mail_user_confirm(cr, uid, reg_ids)
|
('state', 'not in', ['draft', 'cancel'])], context=context)
|
||||||
|
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):
|
def button_confirm(self, cr, uid, ids, context=None):
|
||||||
""" Confirm Event and send confirmation email to all register peoples
|
""" Confirm Event and send confirmation email to all register peoples
|
||||||
"""
|
"""
|
||||||
if isinstance(ids, (int, long)):
|
return self.confirm_event(cr, uid, isinstance(ids, (int, long)) and [ids] or ids, context=context)
|
||||||
ids = [ids]
|
|
||||||
self.check_registration_limits(cr, uid, ids, context=context)
|
|
||||||
return self.confirm_event(cr, uid, ids, context=context)
|
|
||||||
|
|
||||||
def _get_register(self, cr, uid, ids, fields, args, context=None):
|
def _get_seats(self, cr, uid, ids, fields, args, context=None):
|
||||||
"""Get Confirm or uncofirm register value.
|
"""Get reserved, available, reserved but unconfirmed and used seats.
|
||||||
@param ids: List of Event registration type's id
|
@return: Dictionary of function field values.
|
||||||
@param fields: List of function fields(register_current and register_prospect).
|
|
||||||
@param context: A standard dictionary for contextual values
|
|
||||||
@return: Dictionary of function fields value.
|
|
||||||
"""
|
"""
|
||||||
res = {}
|
res = dict([(i, {}) for i in ids])
|
||||||
for event in self.browse(cr, uid, ids, context=context):
|
for event in self.browse(cr, uid, ids, context=context):
|
||||||
res[event.id] = {}
|
res[event.id]['seats_reserved'] = sum(reg.nb_register for reg in event.registration_ids if reg.state == "open")
|
||||||
reg_open = reg_done = reg_draft =0
|
res[event.id]['seats_used'] = sum(reg.nb_register for reg in event.registration_ids if reg.state == "done")
|
||||||
for registration in event.registration_ids:
|
res[event.id]['seats_unconfirmed'] = sum(reg.nb_register for reg in event.registration_ids if reg.state == "draft")
|
||||||
if registration.state == 'open':
|
res[event.id]['seats_available'] = event.seats_max - \
|
||||||
reg_open += registration.nb_register
|
(res[event.id]['seats_reserved'] + res[event.id]['seats_used']) \
|
||||||
elif registration.state == 'done':
|
if event.seats_max > 0 else None
|
||||||
reg_done += registration.nb_register
|
|
||||||
elif registration.state == 'draft':
|
|
||||||
reg_draft += registration.nb_register
|
|
||||||
for field in fields:
|
|
||||||
number = 0
|
|
||||||
if field == 'register_current':
|
|
||||||
number = reg_open
|
|
||||||
elif field == 'register_attended':
|
|
||||||
number = reg_done
|
|
||||||
elif field == 'register_prospect':
|
|
||||||
number = reg_draft
|
|
||||||
elif field == 'register_avail':
|
|
||||||
#the number of ticket is unlimited if the event.register_max field is not set.
|
|
||||||
#In that cas we arbitrary set it to 9999, it is used in the kanban view to special case the display of the 'subscribe' button
|
|
||||||
number = event.register_max - reg_open if event.register_max != 0 else 9999
|
|
||||||
res[event.id][field] = number
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _subscribe_fnc(self, cr, uid, ids, fields, args, context=None):
|
def _subscribe_fnc(self, cr, uid, ids, fields, args, context=None):
|
||||||
|
@ -171,22 +136,16 @@ class event_event(osv.osv):
|
||||||
continue
|
continue
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _get_visibility_selection(self, cr, uid, context=None):
|
|
||||||
return [('public', 'All Users'),
|
|
||||||
('employees', 'Employees Only')]
|
|
||||||
# Lambda indirection method to avoid passing a copy of the overridable method when declaring the field
|
|
||||||
_visibility_selection = lambda self, *args, **kwargs: self._get_visibility_selection(*args, **kwargs)
|
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'name': fields.char('Event Name', size=64, required=True, translate=True, readonly=False, states={'done': [('readonly', True)]}),
|
'name': fields.char('Event Name', size=64, required=True, translate=True, readonly=False, states={'done': [('readonly', True)]}),
|
||||||
'user_id': fields.many2one('res.users', 'Responsible User', readonly=False, states={'done': [('readonly', True)]}),
|
'user_id': fields.many2one('res.users', 'Responsible User', readonly=False, states={'done': [('readonly', True)]}),
|
||||||
'type': fields.many2one('event.type', 'Type of Event', readonly=False, states={'done': [('readonly', True)]}),
|
'type': fields.many2one('event.type', 'Type of Event', readonly=False, states={'done': [('readonly', True)]}),
|
||||||
'register_max': fields.integer('Maximum Registrations', help="You can for each event define a maximum registration level. If you have too much registrations you are not able to confirm your event. (put 0 to ignore this rule )", readonly=True, states={'draft': [('readonly', False)]}),
|
'seats_max': fields.integer('Maximum Avalaible Seats', oldname='register_max', help="You can for each event define a maximum registration level. If you have too much registrations you are not able to confirm your event. (put 0 to ignore this rule )", readonly=True, states={'draft': [('readonly', False)]}),
|
||||||
'register_min': fields.integer('Minimum Registrations', help="You can for each event define a minimum registration level. If you do not enough registrations you are not able to confirm your event. (put 0 to ignore this rule )", readonly=True, states={'draft': [('readonly', False)]}),
|
'seats_min': fields.integer('Minimum Reserved Seats', oldname='register_min', help="You can for each event define a minimum registration level. If you do not enough registrations you are not able to confirm your event. (put 0 to ignore this rule )", readonly=True, states={'draft': [('readonly', False)]}),
|
||||||
'register_current': fields.function(_get_register, string='Confirmed Registrations', multi='register_numbers'),
|
'seats_reserved': fields.function(_get_seats, oldname='register_current', string='Reserved Seats', type='integer', multi='seats_reserved'),
|
||||||
'register_avail': fields.function(_get_register, string='Available Registrations', multi='register_numbers',type='integer'),
|
'seats_available': fields.function(_get_seats, oldname='register_avail', string='Available Seats', type='integer', multi='seats_reserved'),
|
||||||
'register_prospect': fields.function(_get_register, string='Unconfirmed Registrations', multi='register_numbers'),
|
'seats_unconfirmed': fields.function(_get_seats, oldname='register_prospect', string='Unconfirmed Seat Reservations', type='integer', multi='seats_reserved'),
|
||||||
'register_attended': fields.function(_get_register, string='# of Participations', multi='register_numbers'),
|
'seats_used': fields.function(_get_seats, oldname='register_attended', string='Number of Participations', type='integer', multi='seats_reserved'),
|
||||||
'registration_ids': fields.one2many('event.registration', 'event_id', 'Registrations', readonly=False, states={'done': [('readonly', True)]}),
|
'registration_ids': fields.one2many('event.registration', 'event_id', 'Registrations', readonly=False, states={'done': [('readonly', True)]}),
|
||||||
'date_begin': fields.datetime('Start Date', required=True, readonly=True, states={'draft': [('readonly', False)]}),
|
'date_begin': fields.datetime('Start Date', required=True, readonly=True, states={'draft': [('readonly', False)]}),
|
||||||
'date_end': fields.datetime('End Date', required=True, readonly=True, states={'draft': [('readonly', False)]}),
|
'date_end': fields.datetime('End Date', required=True, readonly=True, states={'draft': [('readonly', False)]}),
|
||||||
|
@ -196,45 +155,42 @@ class event_event(osv.osv):
|
||||||
('confirm', 'Confirmed'),
|
('confirm', 'Confirmed'),
|
||||||
('done', 'Done')],
|
('done', 'Done')],
|
||||||
'Status', readonly=True, required=True,
|
'Status', readonly=True, required=True,
|
||||||
track_visibility='onchange',
|
|
||||||
help='If event is created, the status is \'Draft\'.If event is confirmed for the particular dates the status is set to \'Confirmed\'. If the event is over, the status is set to \'Done\'.If event is cancelled the status is set to \'Cancelled\'.'),
|
help='If event is created, the status is \'Draft\'.If event is confirmed for the particular dates the status is set to \'Confirmed\'. If the event is over, the status is set to \'Done\'.If event is cancelled the status is set to \'Cancelled\'.'),
|
||||||
'email_registration_id' : fields.many2one('email.template','Registration Confirmation Email', help='This field contains the template of the mail that will be automatically sent each time a registration for this event is confirmed.'),
|
'email_registration_id' : fields.many2one('email.template','Registration Confirmation Email', help='This field contains the template of the mail that will be automatically sent each time a registration for this event is confirmed.'),
|
||||||
'email_confirmation_id' : fields.many2one('email.template','Event Confirmation Email', help="If you set an email template, each participant will receive this email announcing the confirmation of the event."),
|
'email_confirmation_id' : fields.many2one('email.template','Event Confirmation Email', help="If you set an email template, each participant will receive this email announcing the confirmation of the event."),
|
||||||
'reply_to': fields.char('Reply-To Email', size=64, readonly=False, states={'done': [('readonly', True)]}, help="The email address of the organizer is likely to be put here, with the effect to be in the 'Reply-To' of the mails sent automatically at event or registrations confirmation. You can also put the email address of your mail gateway if you use one."),
|
'reply_to': fields.char('Reply-To Email', size=64, readonly=False, states={'done': [('readonly', True)]}, help="The email address of the organizer is likely to be put here, with the effect to be in the 'Reply-To' of the mails sent automatically at event or registrations confirmation. You can also put the email address of your mail gateway if you use one."),
|
||||||
'address_id': fields.many2one('res.partner','Location', readonly=False, states={'done': [('readonly', True)]}),
|
'address_id': fields.many2one('res.partner','Location', readonly=False, states={'done': [('readonly', True)]}),
|
||||||
'street': fields.related('address_id','street',type='char',string='Street'),
|
|
||||||
'street2': fields.related('address_id','street2',type='char',string='Street2'),
|
|
||||||
'state_id': fields.related('address_id','state_id',type='many2one', relation="res.country.state", string='State'),
|
|
||||||
'zip': fields.related('address_id','zip',type='char',string='zip'),
|
|
||||||
'city': fields.related('address_id','city',type='char',string='city'),
|
|
||||||
'country_id': fields.related('address_id', 'country_id',
|
|
||||||
type='many2one', relation='res.country', string='Country', readonly=False, states={'done': [('readonly', True)]}, store=True),
|
|
||||||
'description': fields.html(
|
'description': fields.html(
|
||||||
'Description', readonly=False,
|
'Description', readonly=False,
|
||||||
states={'done': [('readonly', True)]},
|
states={'done': [('readonly', True)]},
|
||||||
oldname='note'),
|
oldname='note'),
|
||||||
'company_id': fields.many2one('res.company', 'Company', required=False, change_default=True, readonly=False, states={'done': [('readonly', True)]}),
|
'company_id': fields.many2one('res.company', 'Company', required=False, change_default=True, readonly=False, states={'done': [('readonly', True)]}),
|
||||||
'is_subscribed' : fields.function(_subscribe_fnc, type="boolean", string='Subscribed'),
|
'is_subscribed' : fields.function(_subscribe_fnc, type="boolean", string='Subscribed'),
|
||||||
'visibility': fields.selection(_visibility_selection, 'Privacy / Visibility',
|
|
||||||
select=True, required=True),
|
|
||||||
'organizer_id': fields.many2one('res.partner', "Organizer"),
|
'organizer_id': fields.many2one('res.partner', "Organizer"),
|
||||||
'phone': fields.related('organizer_id', 'phone', type='char', string='Phone'),
|
|
||||||
'email': fields.related('organizer_id', 'email', type='char', string='Email'),
|
|
||||||
}
|
}
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'state': 'draft',
|
'state': 'draft',
|
||||||
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'event.event', context=c),
|
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'event.event', context=c),
|
||||||
'user_id': lambda obj, cr, uid, context: uid,
|
'user_id': lambda obj, cr, uid, context: uid,
|
||||||
'visibility': 'public',
|
|
||||||
'organizer_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, uid, context=c).company_id.partner_id.id,
|
'organizer_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, uid, context=c).company_id.partner_id.id,
|
||||||
'address_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, uid, context=c).company_id.partner_id.id
|
'address_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, uid, context=c).company_id.partner_id.id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _check_seats_limit(self, cr, uid, ids, context=None):
|
||||||
|
print "event _check_seats_limit"
|
||||||
|
for event in self.browse(cr, uid, ids, context=context):
|
||||||
|
if event.seats_max and event.seats_available < 0:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
_constraints = [
|
||||||
|
(_check_seats_limit, 'No more available seats.', ['registration_ids','seats_max']),
|
||||||
|
]
|
||||||
|
|
||||||
def subscribe_to_event(self, cr, uid, ids, context=None):
|
def subscribe_to_event(self, cr, uid, ids, context=None):
|
||||||
register_pool = self.pool.get('event.registration')
|
register_pool = self.pool.get('event.registration')
|
||||||
user_pool = self.pool.get('res.users')
|
user_pool = self.pool.get('res.users')
|
||||||
num_of_seats = int(context.get('ticket', 1))
|
num_of_seats = int(context.get('ticket', 1))
|
||||||
self.check_registration_limits_before(cr, uid, ids, num_of_seats, context=context)
|
|
||||||
user = user_pool.browse(cr, uid, uid, context=context)
|
user = user_pool.browse(cr, uid, uid, context=context)
|
||||||
curr_reg_ids = register_pool.search(cr, uid, [('user_id', '=', user.id), ('event_id', '=' , ids[0])])
|
curr_reg_ids = register_pool.search(cr, uid, [('user_id', '=', user.id), ('event_id', '=' , ids[0])])
|
||||||
#the subscription is done with SUPERUSER_ID because in case we share the kanban view, we want anyone to be able to subscribe
|
#the subscription is done with SUPERUSER_ID because in case we share the kanban view, we want anyone to be able to subscribe
|
||||||
|
@ -267,8 +223,8 @@ class event_event(osv.osv):
|
||||||
'reply_to': type_info.default_reply_to,
|
'reply_to': type_info.default_reply_to,
|
||||||
'email_registration_id': type_info.default_email_registration.id,
|
'email_registration_id': type_info.default_email_registration.id,
|
||||||
'email_confirmation_id': type_info.default_email_event.id,
|
'email_confirmation_id': type_info.default_email_event.id,
|
||||||
'register_min': type_info.default_registration_min,
|
'seats_min': type_info.default_registration_min,
|
||||||
'register_max': type_info.default_registration_max,
|
'seats_max': type_info.default_registration_max,
|
||||||
}
|
}
|
||||||
return {'value': dic}
|
return {'value': dic}
|
||||||
|
|
||||||
|
@ -307,7 +263,6 @@ class event_registration(osv.osv):
|
||||||
('cancel', 'Cancelled'),
|
('cancel', 'Cancelled'),
|
||||||
('open', 'Confirmed'),
|
('open', 'Confirmed'),
|
||||||
('done', 'Attended')], 'Status',
|
('done', 'Attended')], 'Status',
|
||||||
track_visibility='onchange',
|
|
||||||
size=16, readonly=True),
|
size=16, readonly=True),
|
||||||
'email': fields.char('Email', size=64),
|
'email': fields.char('Email', size=64),
|
||||||
'phone': fields.char('Phone', size=64),
|
'phone': fields.char('Phone', size=64),
|
||||||
|
@ -319,6 +274,18 @@ class event_registration(osv.osv):
|
||||||
}
|
}
|
||||||
_order = 'name, create_date desc'
|
_order = 'name, create_date desc'
|
||||||
|
|
||||||
|
|
||||||
|
def _check_seats_limit(self, cr, uid, ids, context=None):
|
||||||
|
for registration in self.browse(cr, uid, ids, context=context):
|
||||||
|
if registration.event_id.seats_max and \
|
||||||
|
registration.event_id.seats_available < (registration.state == 'draft' and registration.nb_register or 0):
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
_constraints = [
|
||||||
|
(_check_seats_limit, 'No more available seats.', ['event_id','nb_register','state']),
|
||||||
|
]
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
@ -330,11 +297,6 @@ class event_registration(osv.osv):
|
||||||
def registration_open(self, cr, uid, ids, context=None):
|
def registration_open(self, cr, uid, ids, context=None):
|
||||||
""" Open Registration
|
""" Open Registration
|
||||||
"""
|
"""
|
||||||
event_obj = self.pool.get('event.event')
|
|
||||||
for register in self.browse(cr, uid, ids, context=context):
|
|
||||||
event_id = register.event_id.id
|
|
||||||
no_of_registration = register.nb_register
|
|
||||||
event_obj.check_registration_limits_before(cr, uid, [event_id], no_of_registration, context=context)
|
|
||||||
res = self.confirm_registration(cr, uid, ids, context=context)
|
res = self.confirm_registration(cr, uid, ids, context=context)
|
||||||
self.mail_user(cr, uid, ids, context=context)
|
self.mail_user(cr, uid, ids, context=context)
|
||||||
return res
|
return res
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
<field name="name">Open Days in Los Angeles</field>
|
<field name="name">Open Days in Los Angeles</field>
|
||||||
<field eval="(DateTime.now() + timedelta(days=1)).strftime('%Y-%m-%d 8:00:00')" name="date_begin"/>
|
<field eval="(DateTime.now() + timedelta(days=1)).strftime('%Y-%m-%d 8:00:00')" name="date_begin"/>
|
||||||
<field eval="(DateTime.now() + timedelta(days=5)).strftime('%Y-%m-%d 18:00:00')" name="date_end"/>
|
<field eval="(DateTime.now() + timedelta(days=5)).strftime('%Y-%m-%d 18:00:00')" name="date_end"/>
|
||||||
<field name="register_max">500</field>
|
<field name="seats_max">500</field>
|
||||||
<field name="address_id" ref="base.res_partner_6"/>
|
<field name="address_id" ref="base.res_partner_6"/>
|
||||||
<field name="type" ref="event_type_1"/>
|
<field name="type" ref="event_type_1"/>
|
||||||
<field name="description"><![CDATA[
|
<field name="description"><![CDATA[
|
||||||
|
@ -78,7 +78,7 @@
|
||||||
<field eval="(DateTime.now() + timedelta(days=3)).strftime('%Y-%m-%d 11:00:00')" name="date_end"/>
|
<field eval="(DateTime.now() + timedelta(days=3)).strftime('%Y-%m-%d 11:00:00')" name="date_end"/>
|
||||||
<field name="type" ref="event_type_0"/>
|
<field name="type" ref="event_type_0"/>
|
||||||
<field name="address_id" ref="base.res_partner_5"/>
|
<field name="address_id" ref="base.res_partner_5"/>
|
||||||
<field name="register_max">350</field>
|
<field name="seats_max">350</field>
|
||||||
<field name="description"><![CDATA[
|
<field name="description"><![CDATA[
|
||||||
<div class="oe_structure">
|
<div class="oe_structure">
|
||||||
<center><strong>Functional Webinar</strong></center>
|
<center><strong>Functional Webinar</strong></center>
|
||||||
|
@ -113,7 +113,7 @@
|
||||||
<field eval="(DateTime.today()+ timedelta(days=5)).strftime('%Y-%m-%d 16:30:00')" name="date_end"/>
|
<field eval="(DateTime.today()+ timedelta(days=5)).strftime('%Y-%m-%d 16:30:00')" name="date_end"/>
|
||||||
<field name="type" ref="event_type_2"/>
|
<field name="type" ref="event_type_2"/>
|
||||||
<field name="address_id" ref="base.res_partner_14"/>
|
<field name="address_id" ref="base.res_partner_14"/>
|
||||||
<field name="register_max">200</field>
|
<field name="seats_max">200</field>
|
||||||
<field name="description"><![CDATA[
|
<field name="description"><![CDATA[
|
||||||
<div class="oe_structure">
|
<div class="oe_structure">
|
||||||
<center><strong>Conference on Business Applications</strong></center>
|
<center><strong>Conference on Business Applications</strong></center>
|
||||||
|
|
|
@ -83,23 +83,22 @@
|
||||||
<field name="type" on_change="onchange_event_type(type,context)" />
|
<field name="type" on_change="onchange_event_type(type,context)" />
|
||||||
<field name="date_begin" on_change="onchange_start_date(date_begin,date_end)"/>
|
<field name="date_begin" on_change="onchange_start_date(date_begin,date_end)"/>
|
||||||
<field name="date_end"/>
|
<field name="date_end"/>
|
||||||
<field name="visibility"/>
|
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<notebook>
|
<notebook>
|
||||||
<page string="Registrations">
|
<page string="Registrations">
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<field name="register_min"/>
|
<field name="seats_min"/>
|
||||||
<field name="register_max"/>
|
<field name="seats_max"/>
|
||||||
<label for="register_current" string="Current Registrations" groups="base.group_user"/>
|
<label for="seats_reserved" string="Current Registrations" groups="base.group_user"/>
|
||||||
<div groups="base.group_user">
|
<div groups="base.group_user">
|
||||||
<field name="register_prospect" class="oe_inline"/> (confirmed: <field name="register_current" class="oe_inline"/>)
|
<field name="seats_unconfirmed" class="oe_inline"/> (confirmed: <field name="seats_reserved" class="oe_inline"/>)
|
||||||
</div>
|
</div>
|
||||||
<field name="register_attended"/>
|
<field name="seats_used"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<field name="registration_ids" colspan="4" nolabel="1" groups="event.group_event_manager,event.group_event_user">
|
<field name="registration_ids" colspan="4" nolabel="1" groups="event.group_event_manager,event.group_event_user" context="{'event_id': active_id}">
|
||||||
<tree string="Registration" editable="top">
|
<tree string="Registration" editable="top">
|
||||||
<field name="name" />
|
<field name="name" />
|
||||||
<field name="email" />
|
<field name="email" />
|
||||||
|
@ -159,14 +158,14 @@
|
||||||
<field name="name">event.event.tree</field>
|
<field name="name">event.event.tree</field>
|
||||||
<field name="model">event.event</field>
|
<field name="model">event.event</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="Events" fonts="bold:message_unread==True" colors="red:(register_min and register_min>register_current) or (register_max and register_max<register_current);grey:state=='cancel'">
|
<tree string="Events" fonts="bold:message_unread==True" colors="red:(seats_min and seats_min>seats_reserved) or (seats_max and seats_max<seats_reserved);grey:state=='cancel'">
|
||||||
<field name="name" string="Name"/>
|
<field name="name" string="Name"/>
|
||||||
<field name="type" string="Event Category"/>
|
<field name="type" string="Event Category"/>
|
||||||
<field name="date_begin"/>
|
<field name="date_begin"/>
|
||||||
<field name="date_end"/>
|
<field name="date_end"/>
|
||||||
<field name="register_current"/>
|
<field name="seats_reserved"/>
|
||||||
<field name="register_min"/>
|
<field name="seats_min"/>
|
||||||
<field name="register_max" invisible="1"/>
|
<field name="seats_max" invisible="1"/>
|
||||||
<field name="user_id"/>
|
<field name="user_id"/>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
<field name="message_unread" invisible="1"/>
|
<field name="message_unread" invisible="1"/>
|
||||||
|
@ -182,15 +181,15 @@
|
||||||
<field name="model">event.event</field>
|
<field name="model">event.event</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<kanban>
|
<kanban>
|
||||||
<field name="register_max"/>
|
|
||||||
<field name="type"/>
|
<field name="type"/>
|
||||||
<field name="user_id"/>
|
<field name="user_id"/>
|
||||||
<field name="register_current"/>
|
|
||||||
<field name="is_subscribed"/>
|
<field name="is_subscribed"/>
|
||||||
<field name="country_id"/>
|
<field name="country_id"/>
|
||||||
<field name="date_begin"/>
|
<field name="date_begin"/>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
<field name="register_avail"/>
|
<field name="seats_max"/>
|
||||||
|
<field name="seats_reserved"/>
|
||||||
|
<field name="seats_available"/>
|
||||||
<templates>
|
<templates>
|
||||||
<t t-name="kanban-box">
|
<t t-name="kanban-box">
|
||||||
<div class="oe_module_vignette">
|
<div class="oe_module_vignette">
|
||||||
|
@ -207,19 +206,19 @@
|
||||||
<p>
|
<p>
|
||||||
<t t-if="record.country_id.raw_value">@<field name="country_id"/><br/></t>
|
<t t-if="record.country_id.raw_value">@<field name="country_id"/><br/></t>
|
||||||
<t t-if="record.user_id.raw_value">Organized by <field name="user_id"/><br/></t>
|
<t t-if="record.user_id.raw_value">Organized by <field name="user_id"/><br/></t>
|
||||||
<t t-if="record.register_avail.raw_value lte 10 and record.register_avail.raw_value gt 0"><i>Only</i></t>
|
<t t-if="record.seats_available.raw_value lte 10 and record.seats_available.raw_value gt 0"><i>Only</i></t>
|
||||||
<t t-if="record.register_avail.raw_value == 9999"><i>No ticket available.</i></t>
|
<t t-if="!record.seats_max.raw_value"><i>No ticket available.</i></t>
|
||||||
<t t-if="record.register_avail.raw_value != 9999">
|
<t t-if="record.seats_max.raw_value">
|
||||||
<i><b><t t-if="record.register_avail.raw_value != 9999"><field name="register_avail"/></t></b></i>
|
<i t-if="record.seats_available.raw_value">
|
||||||
<i>
|
<b><field name="seats_available"/></b>
|
||||||
<t t-if="record.register_avail.raw_value > 1">tickets </t>
|
<t t-if="record.seats_available.raw_value > 1">tickets </t>
|
||||||
<t t-if="record.register_avail.raw_value lte 1">ticket </t>
|
<t t-if="record.seats_available.raw_value lte 1">ticket </t>
|
||||||
available.
|
available.
|
||||||
</i>
|
</i>
|
||||||
</t>
|
</t>
|
||||||
</p>
|
</p>
|
||||||
<div groups="base.group_user,base.group_portal">
|
<div groups="base.group_user,base.group_portal">
|
||||||
<t t-if="record.register_avail.raw_value gt 0 and record.register_avail.raw_value lt 9999">
|
<t t-if="record.seats_available.raw_value gt 0 and record.seats_max.raw_value">
|
||||||
<t t-if="!record.is_subscribed.raw_value">
|
<t t-if="!record.is_subscribed.raw_value">
|
||||||
<input t-att-id="record.id.raw_value" type="text" name="subscribe" class="no_of_seats" value="1" onchange="document.getElementById('btn_sub' +this.id).setAttribute('data-context',JSON.stringify({'ticket':this.value}))"/>
|
<input t-att-id="record.id.raw_value" type="text" name="subscribe" class="no_of_seats" value="1" onchange="document.getElementById('btn_sub' +this.id).setAttribute('data-context',JSON.stringify({'ticket':this.value}))"/>
|
||||||
<button t-att-id="'btn_sub'+record.id.raw_value" type="object" name="subscribe_to_event" class="oe_subscribe_button">
|
<button t-att-id="'btn_sub'+record.id.raw_value" type="object" name="subscribe_to_event" class="oe_subscribe_button">
|
||||||
|
|
|
@ -36,7 +36,7 @@ class report_event_registration(osv.osv):
|
||||||
'event_id': fields.many2one('event.event', 'Event', required=True),
|
'event_id': fields.many2one('event.event', 'Event', required=True),
|
||||||
'draft_state': fields.integer(' # No of Draft Registrations', size=20),
|
'draft_state': fields.integer(' # No of Draft Registrations', size=20),
|
||||||
'confirm_state': fields.integer(' # No of Confirmed Registrations', size=20),
|
'confirm_state': fields.integer(' # No of Confirmed Registrations', size=20),
|
||||||
'register_max': fields.integer('Maximum Registrations'),
|
'seats_max': fields.integer('Maximum Avalaible Seats/Registrations', oldname='register_max'),
|
||||||
'nbevent': fields.integer('Number Of Events'),
|
'nbevent': fields.integer('Number Of Events'),
|
||||||
'event_type': fields.many2one('event.type', 'Event Type'),
|
'event_type': fields.many2one('event.type', 'Event Type'),
|
||||||
'registration_state': fields.selection([('draft', 'Draft'), ('confirm', 'Confirmed'), ('done', 'Attended'), ('cancel', 'Cancelled')], 'Registration State', readonly=True, required=True),
|
'registration_state': fields.selection([('draft', 'Draft'), ('confirm', 'Confirmed'), ('done', 'Attended'), ('cancel', 'Cancelled')], 'Registration State', readonly=True, required=True),
|
||||||
|
@ -70,7 +70,7 @@ class report_event_registration(osv.osv):
|
||||||
CASE WHEN r.state IN ('draft') THEN r.nb_register ELSE 0 END AS draft_state,
|
CASE WHEN r.state IN ('draft') THEN r.nb_register ELSE 0 END AS draft_state,
|
||||||
CASE WHEN r.state IN ('open','done') THEN r.nb_register ELSE 0 END AS confirm_state,
|
CASE WHEN r.state IN ('open','done') THEN r.nb_register ELSE 0 END AS confirm_state,
|
||||||
e.type AS event_type,
|
e.type AS event_type,
|
||||||
e.register_max AS register_max,
|
e.seats_max AS seats_max,
|
||||||
e.state AS event_state,
|
e.state AS event_state,
|
||||||
r.state AS registration_state
|
r.state AS registration_state
|
||||||
FROM
|
FROM
|
||||||
|
@ -91,7 +91,7 @@ class report_event_registration(osv.osv):
|
||||||
e.company_id,
|
e.company_id,
|
||||||
year,
|
year,
|
||||||
month,
|
month,
|
||||||
e.register_max,
|
e.seats_max,
|
||||||
name_registration
|
name_registration
|
||||||
)
|
)
|
||||||
""")
|
""")
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<field name="registration_state" invisible="1"/>
|
<field name="registration_state" invisible="1"/>
|
||||||
<field name="name_registration" invisible="1"/>
|
<field name="name_registration" invisible="1"/>
|
||||||
<field name="user_id_registration" invisible="1"/>
|
<field name="user_id_registration" invisible="1"/>
|
||||||
<field name="register_max" invisible="context.get('max_reg_event_visible', True)"/>
|
<field name="seats_max" invisible="context.get('max_reg_event_visible', True)"/>
|
||||||
<field name="company_id" invisible="1"/>
|
<field name="company_id" invisible="1"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
<field name="event_id"/>
|
<field name="event_id"/>
|
||||||
<field name="draft_state" operator="+"/>
|
<field name="draft_state" operator="+"/>
|
||||||
<field name="confirm_state" operator="+"/>
|
<field name="confirm_state" operator="+"/>
|
||||||
<field name="register_max" operator="+"/>
|
<field name="seats_max" operator="+"/>
|
||||||
</graph>
|
</graph>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
name: event
|
name: event
|
||||||
date_begin: 2012-01-01 19:05:15
|
date_begin: 2012-01-01 19:05:15
|
||||||
date_end: 2012-01-01 20:05:15
|
date_end: 2012-01-01 20:05:15
|
||||||
register_max: 10
|
seats_max: 10
|
||||||
-
|
-
|
||||||
I create a registration for the event
|
I create a registration for the event
|
||||||
-
|
-
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
I check if the number of draft registrations in the event view is correct
|
I check if the number of draft registrations in the event view is correct
|
||||||
-
|
-
|
||||||
!assert {model: event.event, id: event_event ,string: 'the number of draft registration is not correct'}:
|
!assert {model: event.event, id: event_event ,string: 'the number of draft registration is not correct'}:
|
||||||
- register_prospect == 15.00
|
- seats_unconfirmed == 15.00
|
||||||
-
|
-
|
||||||
I confirm the registration1
|
I confirm the registration1
|
||||||
-
|
-
|
||||||
|
@ -49,7 +49,7 @@
|
||||||
I check if the number of confirmed registration is correct
|
I check if the number of confirmed registration is correct
|
||||||
-
|
-
|
||||||
!assert {model: event.event,id: event_event,string: 'the number of confirmed registration is not correct'}:
|
!assert {model: event.event,id: event_event,string: 'the number of confirmed registration is not correct'}:
|
||||||
- register_current == 10.00
|
- seats_reserved == 10.00
|
||||||
-
|
-
|
||||||
I close the registration
|
I close the registration
|
||||||
-
|
-
|
||||||
|
@ -64,7 +64,7 @@
|
||||||
I check if attended registration is correct
|
I check if attended registration is correct
|
||||||
-
|
-
|
||||||
!assert {model: event.event,id: event_event,string: 'the number of registration that attended the event is not correct'}:
|
!assert {model: event.event,id: event_event,string: 'the number of registration that attended the event is not correct'}:
|
||||||
- register_attended == 10.00
|
- seats_used == 10.00
|
||||||
-
|
-
|
||||||
I cancel the second registration
|
I cancel the second registration
|
||||||
-
|
-
|
||||||
|
|
|
@ -64,7 +64,7 @@
|
||||||
<field name="product_id" ref="event_0_product"/>
|
<field name="product_id" ref="event_0_product"/>
|
||||||
<field name="deadline" eval="(DateTime.today() + timedelta(90)).strftime('%Y-%m-%d')"/>
|
<field name="deadline" eval="(DateTime.today() + timedelta(90)).strftime('%Y-%m-%d')"/>
|
||||||
<field name="price">1000.0</field>
|
<field name="price">1000.0</field>
|
||||||
<field name="register_max">50</field>
|
<field name="seats_max">50</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="event_0_ticket_2" model="event.event.ticket">
|
<record id="event_0_ticket_2" model="event.event.ticket">
|
||||||
|
@ -73,7 +73,7 @@
|
||||||
<field name="product_id" ref="event_0_product"/>
|
<field name="product_id" ref="event_0_product"/>
|
||||||
<field name="deadline" eval="(DateTime.today() + timedelta(60)).strftime('%Y-%m-%d')"/>
|
<field name="deadline" eval="(DateTime.today() + timedelta(60)).strftime('%Y-%m-%d')"/>
|
||||||
<field name="price">1500.0</field>
|
<field name="price">1500.0</field>
|
||||||
<field name="register_max">10</field>
|
<field name="seats_max">10</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@
|
||||||
<field name="product_id" ref="event_1_product"/>
|
<field name="product_id" ref="event_1_product"/>
|
||||||
<field name="deadline" eval="(DateTime.today() + timedelta(90)).strftime('%Y-%m-%d')"/>
|
<field name="deadline" eval="(DateTime.today() + timedelta(90)).strftime('%Y-%m-%d')"/>
|
||||||
<field name="price">1000.0</field>
|
<field name="price">1000.0</field>
|
||||||
<field name="register_max">60</field>
|
<field name="seats_max">60</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@
|
||||||
<field name="product_id" ref="event_2_product"/>
|
<field name="product_id" ref="event_2_product"/>
|
||||||
<field name="deadline" eval="(DateTime.today() + timedelta(90)).strftime('%Y-%m-%d')"/>
|
<field name="deadline" eval="(DateTime.today() + timedelta(90)).strftime('%Y-%m-%d')"/>
|
||||||
<field name="price">1000.0</field>
|
<field name="price">1000.0</field>
|
||||||
<field name="register_max">50</field>
|
<field name="seats_max">50</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="event_2_ticket_2" model="event.event.ticket">
|
<record id="event_2_ticket_2" model="event.event.ticket">
|
||||||
|
@ -102,7 +102,7 @@
|
||||||
<field name="product_id" ref="event_2_product"/>
|
<field name="product_id" ref="event_2_product"/>
|
||||||
<field name="deadline" eval="(DateTime.today() + timedelta(60)).strftime('%Y-%m-%d')"/>
|
<field name="deadline" eval="(DateTime.today() + timedelta(60)).strftime('%Y-%m-%d')"/>
|
||||||
<field name="price">1500.0</field>
|
<field name="price">1500.0</field>
|
||||||
<field name="register_max">5</field>
|
<field name="seats_max">5</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="event_3_ticket_1" model="event.event.ticket">
|
<record id="event_3_ticket_1" model="event.event.ticket">
|
||||||
|
@ -111,7 +111,7 @@
|
||||||
<field name="product_id" ref="event_3_product"/>
|
<field name="product_id" ref="event_3_product"/>
|
||||||
<field name="deadline" eval="(DateTime.today() + timedelta(90)).strftime('%Y-%m-%d')"/>
|
<field name="deadline" eval="(DateTime.today() + timedelta(90)).strftime('%Y-%m-%d')"/>
|
||||||
<field name="price">1000.0</field>
|
<field name="price">1000.0</field>
|
||||||
<field name="register_max">20</field>
|
<field name="seats_max">20</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="event_3_ticket_2" model="event.event.ticket">
|
<record id="event_3_ticket_2" model="event.event.ticket">
|
||||||
|
@ -120,7 +120,7 @@
|
||||||
<field name="product_id" ref="event_3_product"/>
|
<field name="product_id" ref="event_3_product"/>
|
||||||
<field name="deadline" eval="(DateTime.today() + timedelta(60)).strftime('%Y-%m-%d')"/>
|
<field name="deadline" eval="(DateTime.today() + timedelta(60)).strftime('%Y-%m-%d')"/>
|
||||||
<field name="price">1500.0</field>
|
<field name="price">1500.0</field>
|
||||||
<field name="register_max">5</field>
|
<field name="seats_max">5</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
|
|
|
@ -91,8 +91,6 @@ class sale_order_line(osv.osv):
|
||||||
}
|
}
|
||||||
|
|
||||||
if order_line.event_ticket_id:
|
if order_line.event_ticket_id:
|
||||||
if order_line.event_ticket_id.register_avail != 9999 and dic['nb_register'] > order_line.event_ticket_id.register_avail:
|
|
||||||
raise osv.except_osv(_('Error!'), _('There are not enough tickets available (%s) for %s' % (order_line.event_ticket_id.register_avail, order_line.event_ticket_id.name)))
|
|
||||||
message = _("The registration has been created for event <i>%s</i> with the ticket <i>%s</i> from the Sale Order %s. ") % (order_line.event_id.name, order_line.event_ticket_id.name, order_line.order_id.name)
|
message = _("The registration has been created for event <i>%s</i> with the ticket <i>%s</i> from the Sale Order %s. ") % (order_line.event_id.name, order_line.event_ticket_id.name, order_line.order_id.name)
|
||||||
else:
|
else:
|
||||||
message = _("The registration has been created for event <i>%s</i> from the Sale Order %s. ") % (order_line.event_id.name, order_line.order_id.name)
|
message = _("The registration has been created for event <i>%s</i> from the Sale Order %s. ") % (order_line.event_id.name, order_line.order_id.name)
|
||||||
|
@ -110,78 +108,53 @@ class sale_order_line(osv.osv):
|
||||||
class event_event(osv.osv):
|
class event_event(osv.osv):
|
||||||
_inherit = 'event.event'
|
_inherit = 'event.event'
|
||||||
|
|
||||||
def _get_register_max(self, cr, uid, ids, field_name, arg, context=None):
|
def _get_seats_max(self, cr, uid, ids, field_name, arg, context=None):
|
||||||
result = dict.fromkeys(ids, 0)
|
result = dict.fromkeys(ids, 0)
|
||||||
for rec in self.browse(cr, uid, ids, context=context):
|
for rec in self.browse(cr, uid, ids, context=context):
|
||||||
result[rec.id] = sum([ep.register_max for ep in rec.event_ticket_ids])
|
result[rec.id] = sum([ticket.seats_max for ticket in rec.event_ticket_ids])
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _get_tickets(self, cr, uid, context={}):
|
def _get_tickets(self, cr, uid, context={}):
|
||||||
imd = self.pool.get('ir.model.data')
|
|
||||||
try:
|
try:
|
||||||
product = imd.get_object(cr, uid, 'event_sale', 'product_product_event')
|
product = self.pool.get('ir.model.data').get_object(cr, uid, 'event_sale', 'product_product_event')
|
||||||
|
return [{
|
||||||
|
'name': _('Subscription'),
|
||||||
|
'product_id': product.id,
|
||||||
|
'price': 0,
|
||||||
|
}]
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return []
|
pass
|
||||||
return [{
|
return []
|
||||||
'name': _('Subscription'),
|
|
||||||
'product_id': product.id,
|
|
||||||
'price': 0,
|
|
||||||
}]
|
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'event_ticket_ids': fields.one2many('event.event.ticket', "event_id", "Event Ticket"),
|
'event_ticket_ids': fields.one2many('event.event.ticket', "event_id", "Event Ticket"),
|
||||||
'register_max': fields.function(_get_register_max,
|
'seats_max': fields.function(_get_seats_max,
|
||||||
string='Maximum Registrations',
|
string='Maximum Avalaible Seats',
|
||||||
help="The maximum registration level is equal to the sum of the maximum registration of event ticket." +
|
help="The maximum registration level is equal to the sum of the maximum registration of event ticket." +
|
||||||
"If you have too much registrations you are not able to confirm your event. (0 to ignore this rule )",
|
"If you have too much registrations you are not able to confirm your event. (0 to ignore this rule )",
|
||||||
type='integer')
|
type='integer',
|
||||||
|
readonly=True,
|
||||||
|
store=True)
|
||||||
}
|
}
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'event_ticket_ids': _get_tickets
|
'event_ticket_ids': _get_tickets
|
||||||
}
|
}
|
||||||
|
|
||||||
def check_registration_limits(self, cr, uid, ids, context=None):
|
|
||||||
for event in self.browse(cr, uid, ids, context=context):
|
|
||||||
if event.event_ticket_ids:
|
|
||||||
for ticket in event.event_ticket_ids:
|
|
||||||
ticket.check_registration_limits_before(0)
|
|
||||||
return super(event_event, self).check_registration_limits(cr, uid, ids, context=context)
|
|
||||||
|
|
||||||
|
|
||||||
class event_ticket(osv.osv):
|
class event_ticket(osv.osv):
|
||||||
_name = 'event.event.ticket'
|
_name = 'event.event.ticket'
|
||||||
|
|
||||||
def _get_register(self, cr, uid, ids, fields, args, context=None):
|
def _get_seats(self, cr, uid, ids, fields, args, context=None):
|
||||||
"""Get Confirm or uncofirm register value.
|
"""Get reserved, available, reserved but unconfirmed and used seats for each event tickets.
|
||||||
@param ids: List of Event Ticket registration type's id
|
@return: Dictionary of function field values.
|
||||||
@param fields: List of function fields(register_current and register_prospect).
|
|
||||||
@param context: A standard dictionary for contextual values
|
|
||||||
@return: Dictionary of function fields value.
|
|
||||||
"""
|
"""
|
||||||
res = {}
|
res = dict([(i, {}) for i in ids])
|
||||||
for event in self.browse(cr, uid, ids, context=context):
|
for ticket in self.browse(cr, uid, ids, context=context):
|
||||||
res[event.id] = {}
|
res[ticket.id]['seats_reserved'] = sum(reg.nb_register for reg in ticket.registration_ids if reg.state == "open")
|
||||||
reg_open = reg_done = reg_draft =0
|
res[ticket.id]['seats_used'] = sum(reg.nb_register for reg in ticket.registration_ids if reg.state == "done")
|
||||||
for registration in event.registration_ids:
|
res[ticket.id]['seats_unconfirmed'] = sum(reg.nb_register for reg in ticket.registration_ids if reg.state == "draft")
|
||||||
if registration.state == 'open':
|
res[ticket.id]['seats_available'] = ticket.seats_max - \
|
||||||
reg_open += registration.nb_register
|
(res[ticket.id]['seats_reserved'] + res[ticket.id]['seats_used']) \
|
||||||
elif registration.state == 'done':
|
if ticket.seats_max > 0 else None
|
||||||
reg_done += registration.nb_register
|
|
||||||
elif registration.state == 'draft':
|
|
||||||
reg_draft += registration.nb_register
|
|
||||||
for field in fields:
|
|
||||||
number = 0
|
|
||||||
if field == 'register_current':
|
|
||||||
number = reg_open
|
|
||||||
elif field == 'register_attended':
|
|
||||||
number = reg_done
|
|
||||||
elif field == 'register_prospect':
|
|
||||||
number = reg_draft
|
|
||||||
elif field == 'register_avail':
|
|
||||||
#the number of ticket is unlimited if the event.register_max field is not set.
|
|
||||||
#In that cas we arbitrary set it to 9999, it is used in the kanban view to special case the display of the 'subscribe' button
|
|
||||||
number = event.register_max - reg_open if event.register_max != 0 else 9999
|
|
||||||
res[event.id][field] = number
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
|
@ -191,11 +164,11 @@ class event_ticket(osv.osv):
|
||||||
'registration_ids': fields.one2many('event.registration', 'event_ticket_id', 'Registrations'),
|
'registration_ids': fields.one2many('event.registration', 'event_ticket_id', 'Registrations'),
|
||||||
'deadline': fields.date("Sales End"),
|
'deadline': fields.date("Sales End"),
|
||||||
'price': fields.float('Price'),
|
'price': fields.float('Price'),
|
||||||
'register_max': fields.integer('Maximum Registrations'),
|
'seats_max': fields.integer('Maximum Avalaible Seats', oldname='register_max', help="You can for each event define a maximum registration level. If you have too much registrations you are not able to confirm your event. (put 0 to ignore this rule )"),
|
||||||
'register_current': fields.function(_get_register, string='Current Registrations', type='integer', multi='register_numbers'),
|
'seats_reserved': fields.function(_get_seats, string='Reserved Seats', type='integer', multi='seats_reserved'),
|
||||||
'register_avail': fields.function(_get_register, string='Available Registrations', type='integer', multi='register_numbers'),
|
'seats_available': fields.function(_get_seats, string='Available Seats', type='integer', multi='seats_reserved'),
|
||||||
'register_prospect': fields.function(_get_register, string='Unconfirmed Registrations', type='integer', multi='register_numbers'),
|
'seats_unconfirmed': fields.function(_get_seats, string='Unconfirmed Seat Reservations', type='integer', multi='seats_reserved'),
|
||||||
'register_attended': fields.function(_get_register, string='# of Participations', type='integer', multi='register_numbers'),
|
'seats_used': fields.function(_get_seats, string='Number of Participations', type='integer', multi='seats_reserved'),
|
||||||
}
|
}
|
||||||
|
|
||||||
def _default_product_id(self, cr, uid, context={}):
|
def _default_product_id(self, cr, uid, context={}):
|
||||||
|
@ -210,16 +183,16 @@ class event_ticket(osv.osv):
|
||||||
'product_id': _default_product_id
|
'product_id': _default_product_id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _check_seats_limit(self, cr, uid, ids, context=None):
|
||||||
def check_registration_limits_before(self, cr, uid, ids, number, context=None):
|
|
||||||
for ticket in self.browse(cr, uid, ids, context=context):
|
for ticket in self.browse(cr, uid, ids, context=context):
|
||||||
if ticket.register_max:
|
if ticket.seats_max and ticket.seats_available < 0:
|
||||||
if not ticket.register_avail:
|
return False
|
||||||
raise osv.except_osv(_('Warning!'),_('No Tickets Available for "%s"' % ticket.name))
|
|
||||||
elif number + ticket.register_current > ticket.register_max:
|
|
||||||
raise osv.except_osv(_('Warning!'), _('There only %d tickets available for "%s"' % (ticket.register_avail, ticket.name)))
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
_constraints = [
|
||||||
|
(_check_seats_limit, 'No more available tickets.', ['registration_ids','seats_max']),
|
||||||
|
]
|
||||||
|
|
||||||
def onchange_product_id(self, cr, uid, ids, product_id=False, context=None):
|
def onchange_product_id(self, cr, uid, ids, product_id=False, context=None):
|
||||||
return {'value': {'price': self.pool.get("product.product").browse(cr, uid, product_id).list_price or 0}}
|
return {'value': {'price': self.pool.get("product.product").browse(cr, uid, product_id).list_price or 0}}
|
||||||
|
|
||||||
|
@ -231,10 +204,13 @@ class event_registration(osv.osv):
|
||||||
'event_ticket_id': fields.many2one('event.event.ticket', 'Event Ticket'),
|
'event_ticket_id': fields.many2one('event.event.ticket', 'Event Ticket'),
|
||||||
}
|
}
|
||||||
|
|
||||||
def registration_open(self, cr, uid, ids, context=None):
|
def _check_ticket_seats_limit(self, cr, uid, ids, context=None):
|
||||||
""" Open Registration
|
|
||||||
"""
|
|
||||||
for registration in self.browse(cr, uid, ids, context=context):
|
for registration in self.browse(cr, uid, ids, context=context):
|
||||||
if registration.event_ticket_id:
|
if registration.event_ticket_id.seats_max and \
|
||||||
registration.event_ticket_id.check_registration_limits_before(1)
|
registration.event_ticket_id.seats_available < (registration.state == 'draft' and registration.nb_register or 0):
|
||||||
return super(event_registration, self).registration_open(cr, uid, ids, context=context)
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
_constraints = [
|
||||||
|
(_check_ticket_seats_limit, 'No more available tickets.', ['event_ticket_id','nb_register','state']),
|
||||||
|
]
|
|
@ -24,7 +24,7 @@
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//field[@name='product_id']" position="after">
|
<xpath expr="//field[@name='product_id']" position="after">
|
||||||
<field name="event_id" domain="['|', ('type','=', False),('type', '=', event_type_id)]" attrs="{'invisible': [('event_ok', '=', False)],'required': [('event_ok', '!=', False)]}"/>
|
<field name="event_id" domain="['|', ('type','=', False),('type', '=', event_type_id)]" attrs="{'invisible': [('event_ok', '=', False)],'required': [('event_ok', '!=', False)]}"/>
|
||||||
<field name="event_ticket_id" domain="[('event_id', '=', event_id), ('register_avail', '>', 0)]" attrs="{'invisible': [('event_id', '=', False)]}"
|
<field name="event_ticket_id" domain="[('event_id', '=', event_id), ('seats_available', '>', 0)]" attrs="{'invisible': [('event_id', '=', False)]}"
|
||||||
on_change="onchange_event_ticket_id(event_ticket_id, context)"/>
|
on_change="onchange_event_ticket_id(event_ticket_id, context)"/>
|
||||||
<field name="event_type_id" invisible="1"/>
|
<field name="event_type_id" invisible="1"/>
|
||||||
<field name="event_ok" invisible="1"/>
|
<field name="event_ok" invisible="1"/>
|
||||||
|
@ -51,13 +51,16 @@
|
||||||
<field name="product_id" on_change='onchange_product_id(product_id)'/>
|
<field name="product_id" on_change='onchange_product_id(product_id)'/>
|
||||||
<field name="deadline"/>
|
<field name="deadline"/>
|
||||||
<field name="price"/>
|
<field name="price"/>
|
||||||
<field name="register_max"/>
|
<field name="seats_max"/>
|
||||||
<field name="register_current"/>
|
<field name="seats_reserved"/>
|
||||||
<field name="register_prospect"/>
|
<field name="seats_unconfirmed"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</page>
|
</page>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
<field name="nb_register" position="after">
|
||||||
|
<field name="event_ticket_id" domain="[('event_id', '=', context.get('event_id'))]"/>
|
||||||
|
</field>
|
||||||
</data>
|
</data>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
|
@ -410,6 +410,8 @@ class Contact(orm.AbstractModel):
|
||||||
'phone': field_browse.phone,
|
'phone': field_browse.phone,
|
||||||
'mobile': field_browse.mobile,
|
'mobile': field_browse.mobile,
|
||||||
'fax': field_browse.fax,
|
'fax': field_browse.fax,
|
||||||
|
'city': field_browse.city,
|
||||||
|
'country_id': field_browse.country_id and field_browse.country_id.name_get()[0][1],
|
||||||
'email': field_browse.email,
|
'email': field_browse.email,
|
||||||
'fields': opf,
|
'fields': opf,
|
||||||
'options': options
|
'options': options
|
||||||
|
|
|
@ -89,10 +89,6 @@
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.css_non_editable_mode_hidden {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cke_editable .css_editable_mode_hidden {
|
.cke_editable .css_editable_mode_hidden {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,9 +73,6 @@
|
||||||
.css_editable_hidden
|
.css_editable_hidden
|
||||||
display: none !important
|
display: none !important
|
||||||
|
|
||||||
.css_non_editable_mode_hidden
|
|
||||||
display: none
|
|
||||||
|
|
||||||
.cke_editable .css_editable_mode_hidden
|
.cke_editable .css_editable_mode_hidden
|
||||||
display: none
|
display: none
|
||||||
|
|
||||||
|
|
|
@ -103,6 +103,11 @@ header a.navbar-brand img {
|
||||||
max-height: 50px;
|
max-height: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ----- EDITOR ----- */
|
||||||
|
.css_non_editable_mode_hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
/* ----- BOOTSTRAP FIX ----- */
|
/* ----- BOOTSTRAP FIX ----- */
|
||||||
.container .container {
|
.container .container {
|
||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
|
|
|
@ -68,6 +68,11 @@ header
|
||||||
img
|
img
|
||||||
max-height: 50px
|
max-height: 50px
|
||||||
|
|
||||||
|
/* ----- EDITOR ----- */
|
||||||
|
|
||||||
|
.css_non_editable_mode_hidden
|
||||||
|
display: none
|
||||||
|
|
||||||
/* ----- BOOTSTRAP FIX ----- */
|
/* ----- BOOTSTRAP FIX ----- */
|
||||||
|
|
||||||
.container
|
.container
|
||||||
|
|
|
@ -753,17 +753,17 @@ Sitemap: <t t-esc="url_root"/>sitemap.xml
|
||||||
|
|
||||||
<template id="contact">
|
<template id="contact">
|
||||||
<address t-ignore="true" class="mb0">
|
<address t-ignore="true" class="mb0">
|
||||||
<div t-attf-class="'name' not in fields and 'css_non_editable_mode_hidden'"><span t-esc="name"/></div>
|
<div t-att-class="'name' not in fields and 'css_non_editable_mode_hidden'"><span t-esc="name"/></div>
|
||||||
<div class='css_editable_mode_hidden'>
|
<div t-if="address and 'address' in fields" class='css_editable_mode_hidden'>
|
||||||
<div t-if="address and 'address' in fields">
|
<i class='fa fa-map-marker'/> <span t-raw="address.replace('\n', options.get('no_tag_br') and ', ' or '<br/> &nbsp; &nbsp; ')"/>
|
||||||
<i class='fa fa-map-marker'/>
|
|
||||||
<span t-raw="address.replace('\n', options.get('no_tag_br') and ', ' or '<br/> &nbsp; &nbsp; ')"/>
|
|
||||||
</div>
|
|
||||||
<div t-if="phone and 'phone' in fields"><i class='fa fa-phone'/> <span t-esc="phone"/></div>
|
|
||||||
<div t-if="mobile and 'mobile' in fields"><i class='fa fa-mobile-phone'/> <span t-esc="mobile"/></div>
|
|
||||||
<div t-if="fax and 'fax' in fields"><i class='fa fa-file-text-o'/> <span t-esc="fax"/></div>
|
|
||||||
<div t-if="email and 'email' in fields"><i class='fa fa-envelope'/> <span t-esc="email"/></div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div t-if="city and 'city' in fields" class='css_editable_mode_hidden'>
|
||||||
|
<i class='fa fa-map-marker'/> <span t-raw="city"/>, <span t-raw="country_id"/>
|
||||||
|
</div>
|
||||||
|
<div t-if="phone and 'phone' in fields" class='css_editable_mode_hidden'><i class='fa fa-phone'/> <span t-esc="phone"/></div>
|
||||||
|
<div t-if="mobile and 'mobile' in fields" class='css_editable_mode_hidden'><i class='fa fa-mobile-phone'/> <span t-esc="mobile"/></div>
|
||||||
|
<div t-if="fax and 'fax' in fields" class='css_editable_mode_hidden'><i class='fa fa-file-text-o'/> <span t-esc="fax"/></div>
|
||||||
|
<div t-if="email and 'email' in fields" class='css_editable_mode_hidden'><i class='fa fa-envelope'/> <span t-esc="email"/></div>
|
||||||
</address>
|
</address>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -227,8 +227,6 @@ class website_event(http.Controller):
|
||||||
values['order_id'] = order.id
|
values['order_id'] = order.id
|
||||||
values['name'] = "%s: %s" % (ticket.event_id.name, ticket.name)
|
values['name'] = "%s: %s" % (ticket.event_id.name, ticket.name)
|
||||||
|
|
||||||
ticket.check_registration_limits_before(quantity)
|
|
||||||
|
|
||||||
# change and record value
|
# change and record value
|
||||||
pricelist_id = order.pricelist_id and order.pricelist_id.id or False
|
pricelist_id = order.pricelist_id and order.pricelist_id.id or False
|
||||||
_values = order_line_obj.product_id_change(
|
_values = order_line_obj.product_id_change(
|
||||||
|
|
|
@ -110,6 +110,8 @@ class event(osv.osv):
|
||||||
'website_url': fields.function(_website_url, string="Website url", type="char"),
|
'website_url': fields.function(_website_url, string="Website url", type="char"),
|
||||||
'show_menu': fields.function(_get_show_menu, fnct_inv=_set_show_menu, type='boolean', string='Dedicated Menu'),
|
'show_menu': fields.function(_get_show_menu, fnct_inv=_set_show_menu, type='boolean', string='Dedicated Menu'),
|
||||||
'menu_id': fields.many2one('website.menu', 'Event Menu'),
|
'menu_id': fields.many2one('website.menu', 'Event Menu'),
|
||||||
|
'country_id': fields.related('address_id', 'country_id',
|
||||||
|
type='many2one', relation='res.country', string='Country', readonly=False, states={'done': [('readonly', True)]}, store=True),
|
||||||
}
|
}
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'show_menu': False,
|
'show_menu': False,
|
||||||
|
|
|
@ -59,14 +59,14 @@
|
||||||
<ul class="media-list">
|
<ul class="media-list">
|
||||||
<li t-foreach="event_ids" t-as="event" class="media">
|
<li t-foreach="event_ids" t-as="event" class="media">
|
||||||
<div class="media-body">
|
<div class="media-body">
|
||||||
<t t-if="event.event_ticket_ids">
|
<t t-if="event.state in ['draft', 'confirm'] and event.event_ticket_ids">
|
||||||
<span t-if="not event.register_avail" class="label label-danger pull-right">Sold Out</span>
|
<span t-if="not event.seats_available" class="label label-danger pull-right">Sold Out</span>
|
||||||
<span t-if="event.register_avail and event.register_avail <= ((event.register_max or 0) / 4)" class="label pull-right label-info">
|
<span t-if="event.seats_available and event.seats_available <= ((event.seats_max or 0) / 4)" class="label pull-right label-info">
|
||||||
Only <t t-esc="event.register_avail"/> Remaining
|
Only <t t-esc="event.seats_available"/> Remaining
|
||||||
</span>
|
</span>
|
||||||
</t>
|
</t>
|
||||||
<h4 class="media-heading">
|
<h4 class="media-heading">
|
||||||
<a t-href="/event/#{ slug(event) }/#{(not event.menu_id) and 'register/' or ''}"><span t-field="event.name"> </span></a>
|
<a t-att-class="event.state == 'done' and 'text-success'" t-href="/event/#{ slug(event) }/#{(not event.menu_id) and 'register/' or ''}"><span t-field="event.name"> </span></a>
|
||||||
<small t-if="not event.website_published" class="label label-danger">not published</small>
|
<small t-if="not event.website_published" class="label label-danger">not published</small>
|
||||||
</h4>
|
</h4>
|
||||||
<div>
|
<div>
|
||||||
|
@ -77,9 +77,10 @@
|
||||||
<div>
|
<div>
|
||||||
<i class="fa fa-clock-o"></i> <span t-field="event.date_begin"> </span> <i>to</i> <span t-field="event.date_end"> </span>
|
<i class="fa fa-clock-o"></i> <span t-field="event.date_begin"> </span> <i>to</i> <span t-field="event.date_end"> </span>
|
||||||
</div>
|
</div>
|
||||||
<div t-if="event.country_id">
|
<div t-field="event.address_id" t-field-options='{
|
||||||
<i class="fa fa-map-marker"></i> <span t-field="event.city"/>, <span t-field="event.country_id"/>
|
"widget": "contact",
|
||||||
</div>
|
"fields": ["city"]
|
||||||
|
}'/>
|
||||||
<div class="text-muted">
|
<div class="text-muted">
|
||||||
<i class="fa fa-tag"></i> <span t-field="event.type"/>
|
<i class="fa fa-tag"></i> <span t-field="event.type"/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -244,11 +245,11 @@
|
||||||
<i class="fa fa-clock-o"></i> <span t-field="event.date_begin"/> to
|
<i class="fa fa-clock-o"></i> <span t-field="event.date_begin"/> to
|
||||||
<span t-field="event.date_end"/>
|
<span t-field="event.date_end"/>
|
||||||
</h4>
|
</h4>
|
||||||
<h4 t-if="event.city and event.country_id" class="text-center text-muted">
|
<h4 class="text-center text-muted"
|
||||||
<i class="fa fa-map-marker"/>
|
t-field="event.address_id" t-field-options='{
|
||||||
<span t-field="event.city"/>,
|
"widget": "contact",
|
||||||
<span t-field="event.country_id"/>
|
"fields": ["city"]
|
||||||
</h4>
|
}'/>
|
||||||
<div class="row mt32 mb32">
|
<div class="row mt32 mb32">
|
||||||
<t t-raw="0"/>
|
<t t-raw="0"/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -302,20 +303,20 @@
|
||||||
</t>
|
</t>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<span t-if="ticket.register_max and ((ticket.register_current or 0)*100 / ticket.register_max)>75" class="text-muted">
|
<span t-if="ticket.seats_max and ((ticket.seats_reserved or 0)*100 / ticket.seats_max)>75" class="text-muted">
|
||||||
<t t-esc="ticket.register_max - ticket.register_current"/> <span>left</span>
|
<t t-esc="ticket.seats_max - ticket.seats_reserved"/> <span>left</span>
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select t-if="ticket.register_avail" t-attf-name="ticket-#{ ticket.id }" class="form-control">
|
<select t-if="ticket.seats_available" t-attf-name="ticket-#{ ticket.id }" class="form-control">
|
||||||
<t t-foreach="range(0, ticket.register_avail > 9 and 10 or ticket.register_avail+1 )" t-as="nb"><option t-esc="nb"/></t>
|
<t t-foreach="range(0, ticket.seats_available > 9 and 10 or ticket.seats_available+1 )" t-as="nb"><option t-esc="nb"/></t>
|
||||||
</select>
|
</select>
|
||||||
<span t-if="not ticket.register_avail">Sold Out</span>
|
<span t-if="not ticket.seats_available">Sold Out</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<button type="submit" class="btn btn-primary btn-lg pull-right" t-if="event.register_avail">Order Now</button>
|
<button type="submit" class="btn btn-primary btn-lg pull-right" t-if="event.seats_available">Order Now</button>
|
||||||
<div class="clearfix"/>
|
<div class="clearfix"/>
|
||||||
<hr/>
|
<hr/>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -174,12 +174,5 @@ class event_sponsors(osv.osv):
|
||||||
}
|
}
|
||||||
|
|
||||||
def has_access_to_partner(self, cr, uid, ids, context=None):
|
def has_access_to_partner(self, cr, uid, ids, context=None):
|
||||||
try:
|
return self.pool.get("res.partner").search(cr, uid, [("id", "in", ids)], count=True, context=context)
|
||||||
partner = self.pool.get("res.partner")
|
|
||||||
partner.check_access_rights(cr, uid, 'read')
|
|
||||||
partner_id = self.browse(cr, uid, ids[0], context=context).partner_id.id
|
|
||||||
partner.check_access_rule(cr, uid, [partner_id], 'read', context=context)
|
|
||||||
return True
|
|
||||||
except:
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue