[IMP] event_moodle: overall improvement, cleaned the code, removed unused files, ...

bzr revid: qdp-launchpad@openerp.com-20120227151735-w683kz6502cx5usu
This commit is contained in:
Quentin (OpenERP) 2012-02-27 16:17:35 +01:00
parent d7b5855512
commit c54a2e5184
8 changed files with 187 additions and 370 deletions

View File

@ -263,7 +263,7 @@ class event_registration(osv.osv):
self.message_append(cr, uid, ids,_('State set to...'),body_text= _('Open'))
return res
def case_close(self, cr, uid, ids, context=None):
def button_reg_close(self, cr, uid, ids, context=None):
""" Close Registration
"""
if context is None:
@ -273,25 +273,10 @@ class event_registration(osv.osv):
self.message_append(cr, uid, ids,_('State set to...'),body_text= _('Done'))
return res
# event uses add_note wizard from crm, which expects case_* methods
def case_open(self, cr, uid, ids, context):
return self.registration_open(cr, uid, ids, context)
# event uses add_note wizard from crm, which expects case_* methods
def case_cancel(self, cr, uid, ids, context=None):
""" Cancel Registration
"""
def button_reg_cancel(self, cr, uid, ids, context=None, *args):
self.message_append(cr, uid, ids,_('State set to...'),body_text= _('Cancel'))
return self.write(cr, uid, ids, {'state': 'cancel'})
def button_reg_close(self, cr, uid, ids, context=None):
"""This Function Close Event Registration.
"""
return self.case_close(cr, uid, ids)
def button_reg_cancel(self, cr, uid, ids, context=None, *args):
return self.case_cancel(cr, uid, ids)
def mail_user(self, cr, uid, ids, confirm=False, context=None):
"""
Send email to user with email_template when registration is done

View File

@ -2,7 +2,7 @@
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
# Copyright (C) 2004-2012 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
@ -26,267 +26,259 @@ import time
import random
from random import sample
class event_moodle(osv.osv):
_name = 'event.moodle'
_name = 'event.moodle.config.wiz'
_columns = {
'moodle_username' : fields.char('Moodle username', 128,help="You can also connect with your username that you define when you create a tokken"),
'moodle_password' : fields.char('Moodle password', 128),
'moodle_token' : fields.char('Moodle token', 128,help="Put your token that you created in your moodle serveur"),
'serveur_moodle': fields.char('Moodle server', 128, required=True,help="URL where you have your moodle server without http:// for exemple:127.0.0.1 or localhost"),
'moodle_username' : fields.char('Moodle Username', 128, help="You can also connect with your username that you define when you create a token"),
'moodle_password' : fields.char('Moodle Password', 128),
'moodle_token' : fields.char('Moodle Token', 128, help="Put your token that you created in your moodle server"),
'server_moodle': fields.char('Moodle Server', 128, required=True,help="URL where you have your moodle server. For exemple: 'http://127.0.0.1' or 'http://localhost'"),
'url': fields.char('URL to Moodle Server', size=256, help="The url that will be used for the connection with moodle in xml-rpc"),
}
url=''
def configure_moodle(self,cr,uid,ids,context=None):
"""
Use to configure moodle
"""
self.write(cr,uid,ids,{'id':1})
#save information that you need to create the url
_order = 'create_date desc'
_defaults = {
'server_moodle': 'http://127.0.0.1',
}
def configure_moodle(self, cr, uid, ids, context=None):
url = self.make_url(cr, uid, ids, context=context)
self.write(cr, uid, ids, {'url': url})
return {'type': 'ir.actions.act_window_close'}
#use to quit the wizard
def encode_password(self,cr,uid,ids,password,context=None):
for i in range(len(password)):
x = password[i]
if (ord(x)<48 or ord(x)>57)and(ord(x)<64 or ord(x)>90)and(ord(x)<96 or ord(x)>122):
unicode_car =(hex(ord(x)))
hex_car = '%'+str(unicode_car[2:])
password = password.replace(x,hex_car)
return password
def make_url(self,cr,uid,ids,context=None):
def find(self, cr, uid, context=None):
"""
Find the config wizard containing the configuration and raise and error if none is available.
"""
moodle_config_wiz_ids = self.search(cr, uid, [], context=context)
if not moodle_config_wiz_ids:
raise osv.except_osv(('Error!'),("Configure your moodle connexion before"))
return moodle_config_wiz_ids[0]
def make_url(self, cr, uid, ids, context=None):
"""
create the good url with the information of the configuration
@return url for moodle connexion
"""
reg_ids = self.pool.get('event.moodle').search(cr, uid, [], context=context)
if reg_ids == []:
raise osv.except_osv(('Error!'),("Configure moodle connexion before"))
#change this code and take directly the good ids
def _encode_password(password):
for i in range(len(password)):
x = password[i]
if (ord(x)<48 or ord(x)>57)and(ord(x)<64 or ord(x)>90)and(ord(x)<96 or ord(x)>122):
unicode_car =(hex(ord(x)))
hex_car = '%'+str(unicode_car[2:])
password = password.replace(x,hex_car)
return password
url=""
config_moodle = self.browse(cr, uid, [reg_ids[-1]], context=context)
if config_moodle[0].moodle_username and config_moodle[0].moodle_password:
url='http://'+config_moodle[0].serveur_moodle+'/moodle/webservice/xmlrpc/simpleserver.php?wsusername='+config_moodle[0].moodle_username+'&wspassword='+self.encode_password(cr,uid,ids,config_moodle[0].moodle_password,context=context)
config_moodle = self.browse(cr, uid, ids[0], context=context)
if config_moodle.moodle_username and config_moodle.moodle_password:
#connexion with password and username
#to do warning on special char
if config_moodle[0].moodle_token:
url='http://'+config_moodle[0].serveur_moodle+'/moodle/webservice/xmlrpc/server.php?wstoken='+config_moodle[0].moodle_token
password = self.encode_password(config_moodle.moodle_password)
url = config_moodle.server_moodle + '/moodle/webservice/xmlrpc/simpleserver.php?wsusername=' + config_moodle.moodle_username + '&wspassword=' + password
if config_moodle.moodle_token:
#connexion with token
self.url = url
url = config_moodle.server_moodle + '/moodle/webservice/xmlrpc/server.php?wstoken=' + config_moodle.moodle_token
return url
#create a good url for xmlrpc connect
def create_moodle_user(self,cr,uid,ids,dic_user):
def create_moodle_user(self, cr, uid, id, dic_user, context=None):
"""
create a moodle user
@param dic_user : is a list of dictonnaries with the moodle information
@return a liste of dictonaries with the create user id
"""
self.make_url(cr,uid,ids,context=None)
sock = xmlrpclib.ServerProxy(self.url)
#connect to moodle
url = self.browse(cr, uid, id, context=context).url
sock = xmlrpclib.ServerProxy(url)
#add user in moodle and return list of id and username
return sock.core_user_create_users(dic_user)
#add user un moodle and return list of id and username
def create_moodle_courses(self,cr,uid,ids,courses):
def create_moodle_courses(self, cr, uid, id, courses, context=None):
"""
create a mmodle course
@param courses : is a list of dictionaries with the moodle course information
@return a list of dictionaries with the create course id
"""
self.make_url(cr,uid,ids,context=None)
sock = xmlrpclib.ServerProxy(self.url)
#connect to moodle
url = self.browse(cr, uid, id, context=context).url
sock = xmlrpclib.ServerProxy(url)
return sock.core_course_create_courses(courses)
#add course un moodle
def moodle_enrolled(self,cr,uid,ids,enrolled):
def moodle_enrolled(self, cr, uid, id, enrolled, context=None):
"""
this method is used to match a course with users
@param enrolled : list of dictonaries with the course id and the user id
"""
self.make_url(cr,uid,ids,context=None)
sock = xmlrpclib.ServerProxy(self.url)
#connect to moodle
url = self.browse(cr, uid, id, context=context).url
sock = xmlrpclib.ServerProxy(url)
#add enrolled in moodle
sock.enrol_manual_enrol_users(enrolled)
#add enrolled un moodle
def create_password(self):
"""
create a random password
"""
rand = string.ascii_letters + string.digits
length=8
while length > len(rand):
rand *= 2
length = 8
passwd = ''.join(sample(rand, length))
passwd = passwd+'+'
passwd = passwd + '+'
return passwd
# create a random password
def check_email(self,email):
"""
check is email is true
check if email is correct
"""
if email:
if (email.count('@')!=1 and email.count('.')<1):
raise osv.except_osv(_('Error!'),_("Your email '%s' is wrong") % (email))
if (email.count('@') != 1 and email.count('.') < 1):
raise osv.except_osv(_('Error!'),_("Your email '%s' is wrong") % (email))
def make_username(self,username,response_courses):
def make_username(self, username, response_courses):
"""
create a moodle username with a random number for the uniqueness
@return the moodle username
"""
if username:
username=username.replace(" ","_")
#remove space in the name
name_user = username+"%d" % (response_courses,)+ "%d" % (random.randint(1,999999),)
#give an user name
#remove space in the name
username = username.replace(" ","_")
#give an user name
name_user = username + "%d" % (response_courses,) + "%d" % (random.randint(1,999999),)
else:
name_user = "moodle_"+"%d" % (response_courses,)+ "%d" % (random.randint(1,999999),)
name_user = "moodle_" + "%d" % (response_courses,) + "%d" % (random.randint(1,999999),)
return name_user
event_moodle()
class event_event(osv.osv):
_inherit = "event.event"
_columns={
'moodle_id' :fields.integer('Moodle id'),
'moodle_id': fields.integer('Moodle ID', help='The identifier of this event in Moodle'),
}
def button_confirm(self, cr, uid, ids, context=None):
"""
create moodle courses ,users and match them when an event is confirmed
if the event_registration is not confirmed then it doesn t nothing
"""
moodle_pool = self.pool.get('event.moodle.config.wiz')
moodle_config_wiz_id = moodle_pool.find(cr, uid, context=context)
list_users=[]
userid = []
event = self.browse(cr, uid, ids, context=context)
name_event = event[0].name
date = event[0].date_begin
date=time.strptime(date,'%Y-%m-%d %H:%M:%S')
date = int (time.mktime(date))
#moodle use time() to store the date
dic_courses= [{'fullname' :name_event,'shortname' :'','startdate':date,'summary':event[0].note,'categoryid':1}]
#create a dict course
moodle_pool = self.pool.get('event.moodle')
response_courses =moodle_pool.create_moodle_courses(cr,uid,ids,dic_courses)
self.write(cr,uid,ids,{'moodle_id':response_courses[0]['id']})
#create a course in moodle and keep the id
for registration in event[0].registration_ids:
name_user=moodle_pool.make_username(registration.name,response_courses[0]['id'])
moodle_pool.check_email(registration.email)
passwd=moodle_pool.create_password()
if registration.state=='open':
#confirm if the registrator is confirmed
if registration.moodle_users_id == 0:
dic_users={
'username' : name_user,
'password' : passwd,
'city' : registration.city,
'firstname' : registration.name ,
'lastname': '',
'email': registration.email
}
#create a dictionary for an user
list_users.append(dic_users)
#add the dictionary in a list
else:
userid = []
userid.append(registration.moodle_users_id)
response_user = moodle_pool.create_moodle_user(cr,uid,ids,list_users)
#create users in moodle
enrolled =[]
for event in self.browse(cr, uid, ids, context=context):
#moodle use time() to store the date
date = time.strptime(event.date_begin, '%Y-%m-%d %H:%M:%S')
date = int (time.mktime(date))
#create the dict of values to create the course in Moodle
dic_courses= [{
'fullname': event.name,
'shortname': '',
'startdate': date,
'summary': event.note,
'categoryid':1, #the category hardcoded is 'Miscelleanous'
}]
#create a course in moodle and keep the id
response_courses = moodle_pool.create_moodle_courses(cr, uid, moodle_config_wiz_id, dic_courses, context=context)
self.write(cr, uid, event.id, {'moodle_id': response_courses[0]['id']})
for list in userid:
self.pool.get('event.registration').write(cr,uid,[registration.id],{'moodle_users_id':list,'moodle_user_password':passwd,'moodle_users':name_user})
#write in database the password and the username and the id
enrolled=[{
'roleid' :'5',
'userid' :list,
'courseid' :response_courses[0]['id']
}]
moodle_pool.moodle_enrolled(cr,uid,ids,enrolled)
#link a course with users
moodle_uids = []
for registration in event.registration_ids:
if registration.state == 'open':
#enroll the registration in Moodle as it is confirmed
if not registration.moodle_uid:
#create a dictionary for an user
name_user = moodle_pool.make_username(registration.name, response_courses[0]['id'])
moodle_pool.check_email(registration.email)
passwd = moodle_pool.create_password()
dic_users={
'username' : name_user,
'password' : passwd,
'city' : registration.city,
'firstname' : registration.name ,
'lastname': '',
'email': registration.email
}
#create the user in moodle
response_user = moodle_pool.create_moodle_user(cr, uid, moodle_config_wiz_id, dic_users, context=context)
for user in response_user:
self.pool.get('event.registration').write(cr,uid,[registration.id],{'moodle_uid': user['id'], 'moodle_user_password': passwd, 'moodle_username': name_user})
moodle_uids.append(user['id'])
else:
moodle_uids.append(registration.moodle_uid)
for dic in response_user:
self.pool.get('event.registration').write(cr,uid,[registration.id],{'moodle_users_id':dic['id'],'moodle_user_password':passwd,'moodle_users':name_user})
#write in database the password and the username and the id
enrolled=[{
'roleid' :'5',
'userid' :dic['id'],
'courseid' :response_courses[0]['id']
}]
moodle_pool.moodle_enrolled(cr,uid,ids,enrolled)
#link a course with users
#link the course with users
enrolled = []
for moodle_user in moodle_uids:
enrolled.append({
'roleid' :'5', #mark as 'Student'
'userid' : moodle_user,
'courseid' :response_courses[0]['id']
})
moodle_pool.moodle_enrolled(cr, uid, moodle_config_wiz_id, enrolled, context=context)
return super(event_event, self).button_confirm(cr, uid, ids, context)
event_event()
class event_registration(osv.osv):
_inherit = "event.registration"
_columns={
'moodle_user_password': fields.char('password for moodle user', 128),
'moodle_users': fields.char('moodle username', 128),
'moodle_users_id': fields.integer('moodle uid'),
'moodle_check_user':fields.char('Check Moodle Username',128,help='Try to find an existing moodle username')
'moodle_user_password': fields.char('Password for Moodle User', 128),
'moodle_username': fields.char('Moodle Username', 128),
'moodle_uid': fields.integer('Moodle User ID'),
}
_defaults={
'moodle_check_user':''
}
def case_open(self, cr, uid, ids, context=None):
def registration_open(self, cr, uid, ids, context=None):
"""
create a user and match to a course if the event is already confirmed
"""
register = self.browse(cr, uid, ids, context=context)
if register[0].event_id.state =='confirm':
moodle_pool = self.pool.get('event.moodle')
if register[0].moodle_users_id ==0:
moodle_pool = self.pool.get('event.moodle')
name_user = moodle_pool.make_username(register[0].name,register[0].event_id.moodle_id)
passwd=moodle_pool.create_password()
dic_users=[{
'username' : name_user,
'password' : passwd,
'city' : register[0].city,
'firstname' : register[0].name,
'lastname': '',#no need and difficult to now the difference between firstname and lastname
'email': register[0].email
}]
#create a dictionary for an use
response_user = moodle_pool.create_moodle_user(cr,uid,ids,dic_users)
self.pool.get('event.registration').write(cr,uid,ids,{'moodle_users_id':response_user[0]['id'],'moodle_user_password':passwd,'moodle_users':name_user})
#write in database the password and the username
moodle_pool = self.pool.get('event.moodle.config.wiz')
moodle_config_wiz_id = moodle_pool.find(cr, uid, context=context)
for register in self.browse(cr, uid, ids, context=context):
if register.event_id.state == 'confirm' and register.event_id.moodle_id:
if not register.moodle_uid:
#create the user in moodle
name_user = moodle_pool.make_username(register.name, register.event_id.moodle_id)
passwd = moodle_pool.create_password()
dic_users = [{
'username': name_user,
'password': passwd,
'city': register.city,
'firstname': register.name,
'lastname': '', #we could make a split of the register.name on ' ' but it would be inaccurate, so it seems better to let it empty as it's not really useful
'email': register.email,
}]
response_user = moodle_pool.create_moodle_user(cr, uid, ids, dic_users, context=context)
#write in database the password and the username
moodle_user_id = response_user[0]['id']
self.pool.get('event.registration').write(cr, uid, ids, {'moodle_uid': moodle_user_id, 'moodle_user_password': passwd, 'moodle_username': name_user})
else:
moodle_user_id = register_moodle_uid
enrolled=[{
'roleid' :'5',
'userid' :response_user[0]['id'],#use the response of the create user
'courseid' :register[0].event_id.moodle_id
'roleid': '5', #mark as student
'userid': moodle_user_id,
'courseid': register.event_id.moodle_id
}]
else:
enrolled=[{
'roleid' :'5',
'userid' :register[0].moodle_users_id,
'courseid' :register[0].event_id.moodle_id
}]
moodle_pool.moodle_enrolled(cr,uid,ids,enrolled)
return super(event_registration, self).case_open(cr, uid, ids, context)
moodle_pool.moodle_enrolled(cr, uid, moodle_config_wiz_id, enrolled, context=context)
return super(event_registration, self).registration_open(cr, uid, ids, context=context)
def onchange_moodle_name(self,cr,uid,ids,moodle_check_user,context=None):
def onchange_moodle_name(self, cr, uid, ids, moodle_username, context=None):
"""
@param moodle_check_user: the moodle id
search the moodle id if exist you fill in the field
This onchange receive as parameter a username moddle and will fill the moodle_uid and password fields if existing records with this username are found
@param moodle_username: the existing moodle username
"""
req_sql="select name,email,phone,city,street,moodle_users,moodle_users_id from event_registration"
cr.execute(req_sql)
sql_res = cr.dictfetchall()
res = {}
for username in sql_res:
if username['moodle_users'] == moodle_check_user:
res = {'value' :{'moodle_users_id': username['moodle_users_id'],'name':username['name'],'email':username['email'],'phone':username['phone'],'city':username['city'],'street':username['street']}}
return res
else:
res = {'value' :{'moodle_users_id': 0}}
reg_ids = self.search(cr, uid, [('moodle_username', '=', moodle_username)], order='create_date desc', context=context)
if reg_ids:
reg = self.browse(cr, uid, reg_ids[0], context=context)
res = {'value' :{
'moodle_uid': reg.moodle_uid,
'name': reg.name,
'email':reg.email,
'phone':reg.phone,
'city': reg.city,
'street': reg.street}}
return res
event_registration()

View File

@ -10,21 +10,14 @@
<xpath expr="/form/notebook/page[@string='Emails']" position="after">
<page string="Moodle">
<field name="moodle_user_password" readonly='1' colspan="2"/>
<field name="moodle_users" readonly='1' colspan="2"/>
<field name="moodle_uid" readonly="1"/>
</page>
</xpath>
<field name="email" position="replace"/>
<field name="phone" position="after" >
<field name="email" position="replace">
<field name="email" required="1" />
</field>
<field name="name" position="after" >
<field name="moodle_check_user" on_change="onchange_moodle_name(moodle_check_user)"/>
<field name="moodle_users_id" invisible="1"/>
</field>
<field name="name" position="replace"/>
<field name="phone" position="before" >
<field name="name" position="replace">
<field name="moodle_username" colspan="2" on_change="onchange_moodle_name(moodle_user_password)"/>
<field name="name" required="1" />
</field>
</field>
@ -35,9 +28,9 @@
<field name="type">form</field>
<field name="inherit_id" ref="event.view_event_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='registration_ids']/tree/field[@name='name']" position="after">
<field name="moodle_check_user" on_change="onchange_moodle_name(moodle_check_user)"/>
<field name="moodle_users_id" invisible="1"/>
<xpath expr="//field[@name='registration_ids']/tree/field[@name='name']" position="replace">
<field name="moodle_username" colspan="2" on_change="onchange_moodle_name(moodle_user_password)"/>
<field name="name" required="1" />
</xpath>
</field>
</record>

View File

@ -1,100 +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/>.
#
##############################################################################
from osv import fields, osv
import xmlrpclib
class event_moodle(osv.osv):
""" Event Type """
_name = 'event.moodle'
_inherit = 'event.registration'
_columns = {
'moodle_ok' : fields.boolean('moodle_ok'),
'moodle_username' : fields.char('Moodle username', 128),
'moodle_password' : fields.char('Moodle password', 128),
'moodle_token' : fields.char('Moodle token', 128),
'serveur_moodle': fields.char('Moodle token', 128),
}
def Get_url():
"""
attr:
serveur_moodle
token
password
username
"""
hostname="127.0.0.1"
password="Administrateur1%2b"
username="admin"
#if token
token='3ecfb383330044a884b1ee86e0872b47'
url='http://'+hostname+'/moodle/webservice/xmlrpc/server.php?wstoken='+token
#if user connect
url='http://'+hostname+'/moodle/webservice/xmlrpc/simpleserver.php?wsusername='+username+'&wspassword='+password
return url
def create_moodle_user():
#user is a list of dictionaries with every required datas for moodle
users=[{
'username' : 'efegt(gtrhf',
'password' : 'Azertyui1+',
'firstname' : 'res',
'lastname': 'ezr',
'email': 'gegtr@ggtr.com'
}]
#connect to moodle
sock = xmlrpclib.ServerProxy(self.Get_url())
#add user un moodle
return sock.core_user_create_users(users)
#return list of id and username
def create_moodle_courses():
courses=[{
'fullname' :'',
'shortname' :'',
'categoryid':''
}]
#connect to moodle
sock = xmlrpclib.ServerProxy(self.Get_url())
#add course un moodle
sock.core_course_create_courses(courses)
def moodleenrolled():
enrolled=[{
'roleid' :'',
'userid' :'',
'courseid' :''
}]
#connect to moodle
sock = xmlrpclib.ServerProxy(self.Get_url())
#add enrolled un moodle
sock.enrol_manual_enrol_users(enrolled)
event_moodle()

View File

@ -1,19 +0,0 @@
<?xml version="1.0"?>
<openerp>
<data>
<menuitem name="Marketingdcdc" icon="terp-crm" id="base.test" sequence="23"/>
<record model="ir.ui.view" id="moodle_configuration">
<field name="name">moodle</field>
<field name="model">event.event</field>
<field name="type">form</field>
<field name="inherit_id" ref="event.view_event_form" />
<field name="arch" type="xml">
<xpath expr="/form/notebook/page[@string='Extra Info']" position="after">
<page string="Moodle">
</page>
</xpath>
</field>
</record>
</data>
</openerp>

View File

@ -1,18 +0,0 @@
from osv import fields,osv
class moodle_config_memory(osv.osv_memory):
_name = 'moodle.config.memory'
_columns = {
'hostname': fields.char('Name',64),
'token': fields.char('test',64),
'user_moodle': fields.char('teste',64),
'pass_moodle': fields.char('ssss',64),
}
def get_connect_moodle_info(self, cr, uid, context=None):
if not context:
return False
else:
return context.get('hostname')

View File

@ -1,18 +0,0 @@
from osv import fields,osv
class moodle_config_memory(osv.osv_memory):
_name = 'moodle.config.memory'
_columns = {
'hostname': fields.char('Name',64),
'token': fields.char('test',64),
'user_moodle': fields.char('teste',64),
'pass_moodle': fields.char('ssss',64),
}
def get_connect_moodle_info(self, cr, uid, context=None):
if not context:
return False
else:
return context.get('hostname')

View File

@ -3,20 +3,22 @@
<data>
<record model="ir.ui.view" id="create_moodle_config_view">
<field name="name">moodle.config.wizard.form</field>
<field name="model">event.moodle</field>
<field name="model">event.moodle.config.wiz</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Configure Moodle">
<group>
<separator string="serveur" colspan="4"/>
<field name="serveur_moodle"/>
<newline/>
<separator string="Connexion with a token" colspan="4"/>
<field name="moodle_token"/>
<newline/>
<separator string="Connexion with password and username" colspan="4"/>
<field name="moodle_username"/>
<field name="moodle_password"/>
<separator string="server" colspan="4"/>
<field name="server_moodle"/>
<newline/>
<separator string="Connexion with a token" colspan="4"/>
<label string="The easiest way to connect OpenERP with a moodle server is to create a 'token' in Moodle. It will be used to authenticate OpenERP as a trustable application." colspan="4"/>
<field name="moodle_token"/>
<newline/>
<separator string="Connexion with password and username" colspan="4"/>
<label string="Another approach is to create a user for OpenERP in Moodle. If you do so, make sure that this user has enough access rights" colspan="4"/>
<field name="moodle_username"/>
<field name="moodle_password"/>
</group>
<newline/>
<button type="special" special="cancel"
@ -29,7 +31,7 @@
<record model="ir.actions.act_window" id="configure_moodle">
<field name="name">Configure Moodle</field>
<field name="res_model">event.moodle</field>
<field name="res_model">event.moodle.config.wiz</field>
<field name="view_id" ref="create_moodle_config_view"/>
<field name="view_type">form</field>
<field name="view_mode">form</field>