*typos corrected

*added a wizard that check whenever a registration is confirmed that there is enough available places and the warn the user if no, giving him the choice to continue or 
cancell the registration's confirmation.

bzr revid: qdp@tinyerp.com-20081002133703-vu7l6lqld6xkj094
This commit is contained in:
qdp 2008-10-02 15:37:03 +02:00
parent 48704ddb2c
commit 8c1994a571
5 changed files with 127 additions and 56 deletions

View File

@ -134,8 +134,8 @@ class event(osv.osv):
'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),
'mail_auto_registr':fields.boolean('Mail Auto Register',help='A mail is send when the registration is confirmed'),
'mail_auto_confirm':fields.boolean('Mail Auto Confirm',help='A mail is send when the event is confimed'),
'mail_auto_registr':fields.boolean('Mail Auto Register',help='A mail is sent when the registration is confirmed'),
'mail_auto_confirm':fields.boolean('Mail Auto Confirm',help='A mail is sent when the event is confimed'),
'mail_registr':fields.text('Mail Register',help='Template for the mail'),
'mail_confirm':fields.text('Mail Confirm',help='Template for the mail'),
'budget_id':fields.many2one('account.budget.post','Budget'),
@ -163,13 +163,6 @@ class event_registration(osv.osv):
obj.create(cr, uid, data, context)
return True
def button_reg_open(self, cr, uid, ids, *args):
self.write(cr, uid, ids, {'state':'open',})
cases = self.browse(cr, uid, ids)
self._history(cr, uid, cases, 'Open', history=True)
self.mail_user(cr,uid,ids)
return True
def button_reg_close(self, cr, uid, ids, *args):
self.write(cr, uid, ids, {'state':'done',})
cases = self.browse(cr, uid, ids)
@ -223,7 +216,7 @@ class event_registration(osv.osv):
"badge_name":fields.char('Badge Name',size=128),
"badge_partner":fields.char('Badge Partner',size=128),
"invoice_label":fields.char("Label Invoice",size=128,required=True),
"tobe_invoiced":fields.boolean("To be Invoice"),
"tobe_invoiced":fields.boolean("To be Invoiced"),
"invoice_id":fields.many2one("account.invoice","Invoice"),
}
_defaults = {

View File

@ -198,7 +198,7 @@
<form string="Registration">
<notebook>
<page string="General">
<field name="event_id" select="1" on_change="onchange_event(event_id, partner_invoice_id)" colspan="1"/>
<field name="event_id" select="1" on_change="onchange_event(event_id, partner_invoice_id)" colspan="1" domain="[('state','in',('draft','confirm'))]"/>
<field name="nb_register"/>
<newline/>
<field name="partner_id" required="1" select="1" on_change="onchange_partner_id(partner_id,event_id, email_from)" />
@ -220,7 +220,7 @@
<group col="8" colspan="4">
<field name="state" select="1" colspan="2"/>
<button name="button_reg_close" string="Registration Invoiced" states="open" type="object"/>
<button name="button_reg_open" string="Confirm Registration" states="draft" type="object"/>
<button name="%(event_confirm_registration)d" string="Confirm Registration" states="draft" type="action"/>
<button name="button_reg_cancel" string="Cancel Registration" states="draft,open" type="object"/>
</group>
</page>

View File

@ -1,52 +1,43 @@
<?xml version="1.0" ?>
<openerp>
<data>
<wizard string="Project"
model="event.event"
name="event.project"
id="event_wiz"
menu="False"/>
<data>
<wizard string="Project"
model="event.event"
name="event.project"
id="event_wiz"
menu="False"/>
<wizard
string="Tasks"
model="event.event"
name="wizard_event_tasks"
id="wizard_event_task"/>
<wizard
string="Tasks"
model="event.event"
name="wizard_event_tasks"
id="wizard_event_task"/>
<wizard
string="Registrations"
model="event.event"
name="wizard_event_registration"
id="wizard_event_registration"/>
<wizard
string="Registrations"
model="event.event"
name="wizard_event_registration"
id="wizard_event_registration"/>
<!--<wizard
string="New child event"
model="event.event"
name="wizard_event_new"
keyword="client_action_multi"
menu="False"
id="wizard_event_new"/>-->
<wizard
string="List Register Partners"
model="event.event"
name="event.event_reg_partners"
id="wizard_event_reg_partners"/>
<wizard
string="List Register Partners"
model="event.event"
name="event.event_reg_partners"
id="wizard_event_reg_partners"/>
<wizard string="Make Invoice"
model="event.registration"
name="event.reg_make_invoice"
id="event_reg_invoice"
menu="True"
/>
<wizard string="Make Invoice"
model="event.registration"
name="event.reg_make_invoice"
id="event_reg_invoice"
menu="True"
/>
<!--
<record model="ir.values" id="ir_open_new_event">
<field name="key2">tree_but_open</field>
<field name="model">event.event</field>
<field name="name">New child event</field>
<field name="value" eval="'ir.actions.wizard,%d'%wizard_event_new"/>
<field name="object" eval="True"/>
</record>
-->
</data>
<wizard string="Confirm Registration"
model="event.registration"
name="event.confirm_registration"
id="event_confirm_registration"
menu="False"
/>
</data>
</openerp>

View File

@ -3,6 +3,7 @@ import event_registration
import project_wizard
import make_invoice
import event_registrations_partner
import confirm_registration
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,86 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# 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 2
# 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.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
import wizard
import ir
import pooler
from osv.osv import except_osv
from osv import fields,osv
import netsvc
ARCH = '''<?xml version="1.0"?>
<form string="Registration Confirmation">
<label string="The event limit is reached. What do you want to do?" colspan="4"/>
</form>'''
ARCH_fields={}
def _confirm(self, cr, uid, data, context):
registration_obj = pooler.get_pool(cr.dbname).get('event.registration')
current_registration = registration_obj.browse(cr, uid, [data['id']])[0]
total_confirmed = current_registration.event_id.register_current + current_registration.nb_register
if total_confirmed <= current_registration.event_id.register_max:
return 'confirm'
return 'split'
def _check_confirm(self, cr, uid, data, context):
registration_obj = pooler.get_pool(cr.dbname).get('event.registration')
registration_obj.write(cr, uid, [data['id']], {'state':'open',})
reg = registration_obj.browse(cr, uid, [data['id']])
registration_obj._history(cr, uid, reg, 'Open', history=True)
registration_obj.mail_user(cr,uid,[data['id']])
return {}
class confirm_registration(wizard.interface):
states = {
'init' : {
'actions' : [],
'result' : {'type' : 'choice', 'next_state' : _confirm}
},
'split' : {
'actions' : [],
'result' : {'type' : 'form',
'arch' : ARCH,'fields':ARCH_fields,
'state' : [('end', 'Cancel'),('confirm', 'Confirm Anyway') ]}
},
'confirm' : {
'actions' : [],
'result' : {'type' : 'action', 'action': _check_confirm, 'state' : 'end'}
},
'end' : {
'actions' : [],
'result': {'type': 'state', 'state': 'end'},
},
}
confirm_registration('event.confirm_registration')