[FIX] event_sale: `seats_available` needs to be recomputed according to the value of `seats_max` that changes when tickets are updated

bzr revid: odo@openerp.com-20140428094449-wuvjwl4ko10l4c92
This commit is contained in:
Olivier Dony 2014-04-28 11:44:49 +02:00
parent ee613ec6cd
commit 9706320c11
1 changed files with 15 additions and 1 deletions

View File

@ -19,6 +19,7 @@
#
##############################################################################
from openerp.addons.event.event import event_event as Event
from openerp.osv import fields, osv
from openerp.tools.translate import _
@ -137,6 +138,11 @@ class event_event(osv.osv):
pass
return []
def _get_ticket_events(self, cr, uid, ids, context=None):
# `self` is the event.event.ticket model here!
return list(set(ticket.event_id.id
for ticket in self.browse(cr, uid, ids, context)))
_columns = {
'event_ticket_ids': fields.one2many('event.event.ticket', "event_id", "Event Ticket"),
'seats_max': fields.function(_get_seats_max,
@ -144,7 +150,15 @@ class event_event(osv.osv):
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 )",
type='integer',
readonly=True)
readonly=True),
'seats_available': fields.function(Event._get_seats, oldname='register_avail', string='Available Seats',
type='integer', multi='seats_reserved',
store={
'event.registration': (Event._get_events_from_registrations, ['state'], 10),
'event.event': (lambda self, cr, uid, ids, c = {}: ids,
['seats_max', 'registration_ids'], 20),
'event.event.ticket': (_get_ticket_events, ['seats_max'], 10),
}),
}
_defaults = {
'event_ticket_ids': _get_tickets