[IMP] Event: Event confirm registration wizard convert to osv memory type wizard

bzr revid: mra@tinyerp.com-20100330121754-7l3qhu8kggs4yxqi
This commit is contained in:
mra (Open ERP) 2010-03-30 17:47:54 +05:30
parent 9e6c71e60a
commit 39a282b830
8 changed files with 112 additions and 104 deletions

View File

@ -42,12 +42,14 @@
'init_xml': ['event_data.xml'],
'update_xml': [
'event_wizard.xml',
'wizard/event_confirm_registration_view.xml',
'event_view.xml',
'event_sequence.xml',
'security/event_security.xml',
'security/ir.model.access.csv',
'wizard/event_registration_view.xml',
'wizard/event_registrations_partner.xml',
],
'demo_xml': ['event_demo.xml'],
'installable': True,

View File

@ -151,6 +151,31 @@ event()
class event_registration(osv.osv):
def check_confirm(self, cr, uid, ids, context):
mod_obj = self.pool.get('ir.model.data')
current_registration = self.browse(cr, uid, [ids[0]])[0]
total_confirmed = current_registration.event_id.register_current + current_registration.nb_register
if total_confirmed <= current_registration.event_id.register_max or current_registration.event_id.register_max == 0:
self.write(cr, uid, [ids[0]], {'state':'open'}, context=context)
self._history(cr, uid, [ids[0]], 'Open', history=True)
self.mail_user(cr, uid, [ids[0]])
return True
else:
model_data_ids = mod_obj.search(cr,uid,[('model','=','ir.ui.view'),('name','=','view_event_confirm_registration')], context=context)
resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
context.update({'reg_id': ids[0]})
return {
'name': _('Confirm Registration'),
'context': context,
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'event.confirm.registration',
'views': [(resource_id,'form')],
'type': 'ir.actions.act_window',
'target': 'new',
'nodestroy': True
}
def _history(self, cr, uid,ids,keyword, history=False, email=False, context={}):
for case in self.browse(cr, uid, ids):
if not case.case_id:
@ -244,14 +269,14 @@ class event_registration(osv.osv):
"invoice_id":fields.many2one("account.invoice","Invoice"),
'date_closed': fields.datetime('Closed', readonly=True),
'ref' : fields.reference('Reference', selection=crm._links_get, size=128),
'ref2' : fields.reference('Reference 2', selection=crm._links_get, size=128),
'ref2' : fields.reference('Reference 2', selection=crm._links_get, size=128),
'categ_id': fields.many2one('crm.case.categ','Category', domain="[('section_id','=',section_id)]"),
'canal_id': fields.many2one('res.partner.canal', 'Channel',help="The channels represent the different communication modes available with the customer." \
" With each commercial opportunity, you can indicate the canall which is this opportunity source."),
'som': fields.many2one('res.partner.som', 'State of Mind', help="The minds states allow to define a value scale which represents" \
"the partner mentality in relation to our services.The scale has" \
"to be created with a factor for each level from 0 (Very dissatisfied) to 10 (Extremely satisfied)."),
}
_defaults = {
'nb_register': lambda *a: 1,

View File

@ -203,7 +203,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" icon="gtk-print"/>
<button name="%(event_confirm_registration)d" string="Confirm Registration" states="draft" type="action" icon="gtk-apply"/>
<button name="check_confirm" string="Confirm Registration" states="draft" type="object" icon="gtk-apply"/>
<button name="button_reg_cancel" string="Cancel Registration" states="draft,open" type="object" icon="gtk-cancel"/>
</group>
</page>

View File

@ -2,31 +2,12 @@
<openerp>
<data>
<!-- <wizard
string="Registrations"
model="event.event"
name="wizard_event_registration"
id="wizard_event_registration"/> -->
<!-- <wizard
string="List Register Partners"
model="event.event"
name="event.event_reg_partners"
id="wizard_event_reg_partners"/> -->
<wizard string="Make Invoice"
<wizard string="Make Invoice"
model="event.registration"
name="event.reg_make_invoice"
id="event_reg_invoice"
menu="True"
/>
<wizard string="Confirm Registration"
model="event.registration"
name="event.confirm_registration"
id="event_confirm_registration"
menu="False"
/>
</data>
</openerp>

View File

@ -22,5 +22,5 @@
import event_registration
import make_invoice
import event_registrations_partner
import confirm_registration
import event_confirm_registration
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,80 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
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 or current_registration.event_id.register_max == 0:
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',})
registration_obj._history(cr, uid, [data['id']], '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')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
class event_confirm_registration(osv.osv_memory):
"""
Confirm Event Registration
"""
_name = "event.confirm.registration"
_description = "Event Registraion"
_columns = {
'msg': fields.text('Message', readonly=True),
}
_defaults={
'msg':lambda *a:'The event limit is reached. What do you want to do?'
}
def confirm(self, cr, uid, ids, context):
registration_obj = self.pool.get('event.registration')
reg_id = context.get('reg_id', False) or context.get('active_id', False)
if reg_id:
registration_obj.write(cr, uid, [reg_id], {'state':'open',})
registration_obj._history(cr, uid, [reg_id], 'Open', history=True)
registration_obj.mail_user(cr,uid,[reg_id])
return {}
event_confirm_registration()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_event_confirm_registration" model="ir.ui.view">
<field name="name">Registration Confirmation</field>
<field name="model">event.confirm.registration</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Registration Confirmation">
<field name="msg"/>
<separator string="" colspan="4"/>
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="_Cancel"/>
<button icon="gtk-ok" name="confirm" string="Confirm Anyway" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_event_confirm_registration" model="ir.actions.act_window">
<field name="name">Registrations</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">event.confirm.registration</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_event_confirm_registration"/>
<field name="context">{'record_id' : active_id}</field>
<field name="target">new</field>
</record>
</data>
</openerp>