[MERGE]: Merged lp:~openerp-dev/openobject-addons/trunk-event_improvements-atp-improve-kanban-for-registration-bde
bzr revid: atp@tinyerp.com-20120420134326-i8m23eos2atpg4su
This commit is contained in:
commit
8a3642861e
|
@ -103,12 +103,23 @@ class event_event(osv.osv):
|
|||
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") % (self.event.name))
|
||||
|
||||
def check_registration_limits_before(self, cr, uid, ids, no_of_registration, context=None):
|
||||
def check_available_seats(self, cr, uid, ids, context=None):
|
||||
if isinstance(ids, list):
|
||||
ids = ids[0]
|
||||
else:
|
||||
ids = ids
|
||||
total_confirmed = self.browse(cr, uid, ids, context=context).register_current
|
||||
register_max = self.browse(cr, uid, ids, context=context).register_max
|
||||
available_seats = register_max - total_confirmed
|
||||
return available_seats
|
||||
|
||||
def check_registration_limits_before(self, cr, uid, ids, no_of_registration, context=None):
|
||||
available_seats = self.check_available_seats(cr, uid, ids, context=context)
|
||||
if no_of_registration > available_seats:
|
||||
raise osv.except_osv(_('Warning!'),_("Only %d Seats are Available!") % (available_seats))
|
||||
if available_seats == 0:
|
||||
raise osv.except_osv(_('Warning!'),_("No Tickets Available!"))
|
||||
else:
|
||||
raise osv.except_osv(_('Warning!'),_("Only %d Seats are Available!") % (available_seats))
|
||||
|
||||
|
||||
def confirm_event(self, cr, uid, ids, context=None):
|
||||
|
@ -220,13 +231,23 @@ class event_event(osv.osv):
|
|||
}
|
||||
|
||||
def subscribe_to_event(self, cr, uid, ids, context=None):
|
||||
num_of_seats = int(context.get('ticket', 1))
|
||||
available_seats = self.check_available_seats(cr, uid, ids, context=context)
|
||||
if num_of_seats > available_seats:
|
||||
if available_seats == 0:
|
||||
raise osv.except_osv(_('Warning!'),_("No Tickets Available!"))
|
||||
else:
|
||||
raise osv.except_osv(_('Warning!'),_("Only %d Seats are Available!") % (available_seats))
|
||||
|
||||
register_pool = self.pool.get('event.registration')
|
||||
user_pool = self.pool.get('res.users')
|
||||
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])])
|
||||
#the subscription is done with UID = 1 because in case we share the kanban view, we want anyone to be able to subscribe
|
||||
if not curr_reg_ids:
|
||||
curr_reg_ids = [register_pool.create(cr, 1, {'event_id': ids[0] ,'email': user.user_email, 'name':user.name, 'user_id': user.id,})]
|
||||
curr_reg_ids = [register_pool.create(cr, 1, {'event_id': ids[0] ,'email': user.user_email, 'name':user.name, 'user_id': user.id, 'nb_register': num_of_seats})]
|
||||
else:
|
||||
register_pool.write(cr, uid, curr_reg_ids, {'nb_register': num_of_seats}, context=context)
|
||||
return register_pool.confirm_registration(cr, 1, curr_reg_ids, context=context)
|
||||
|
||||
def unsubscribe_to_event(self, cr, uid, ids, context=None):
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
<openerp>
|
||||
<data>
|
||||
|
||||
<menuitem name="Events" id="event_main_menu"/>
|
||||
<menuitem name="Events" id="event_main_menu"
|
||||
web_icon="images/icon.png"
|
||||
web_icon_hover="images/icon.png"/>
|
||||
<menuitem name="Events Organisation" id="base.menu_event_main" parent="event_main_menu" />
|
||||
|
||||
<!-- EVENTS -->
|
||||
|
@ -203,7 +205,8 @@
|
|||
</p>
|
||||
<t t-if="record.register_avail.raw_value != 0">
|
||||
<t t-if="!record.is_subscribed.raw_value">
|
||||
<button type="object" name="subscribe_to_event" class="subscribe_button oe_event_button_subscribe">
|
||||
<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="subscribe_button oe_event_button_subscribe">
|
||||
<span >Subscribe</span>
|
||||
</button>
|
||||
</t>
|
||||
|
|
|
@ -115,4 +115,8 @@ div.oe_fold_column{
|
|||
display: inline;
|
||||
background-color: #DC5F59;
|
||||
}
|
||||
.no_of_seats{
|
||||
width:25px;
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue