[REF]: base_calendar: Separated osv_memory wizard for invite attendee into wizard folder + Added search view for invitation
bzr revid: rpa@tinyerp.com-20100323122631-n1aar2o4w6jhiy15
This commit is contained in:
parent
c184f21599
commit
6aafa589c9
|
@ -41,7 +41,8 @@
|
|||
"demo_xml" : [],
|
||||
"update_xml" : [
|
||||
'security/ir.model.access.csv',
|
||||
'wizard/calendar_event_edit_all_view.xml',
|
||||
'wizard/calendar_event_edit_all_view.xml',
|
||||
'wizard/base_calendar_invite_attendee_view.xml',
|
||||
'base_calendar_view.xml'
|
||||
],
|
||||
"installable" : True,
|
||||
|
|
|
@ -91,7 +91,7 @@ def _links_get(self, cr, uid, context={}):
|
|||
"""
|
||||
obj = self.pool.get('res.request.link')
|
||||
ids = obj.search(cr, uid, [])
|
||||
res = obj.read(cr, uid, ids, ['object', 'name'], context)
|
||||
res = obj.read(cr, uid, ids, ['object', 'name'], context=context)
|
||||
return [(r['object'], r['name']) for r in res]
|
||||
|
||||
html_invitation = """
|
||||
|
@ -200,142 +200,6 @@ html_invitation = """
|
|||
</html>
|
||||
"""
|
||||
|
||||
class invite_attendee_wizard(osv.osv_memory):
|
||||
"""
|
||||
Invite attendee.
|
||||
"""
|
||||
|
||||
_name = "base_calendar.invite.attendee"
|
||||
_description = "Invite Attendees"
|
||||
|
||||
_columns = {
|
||||
'type': fields.selection([('internal', 'Internal User'), \
|
||||
('external', 'External Email'), \
|
||||
('partner', 'Partner Contacts')], 'Type', required=True),
|
||||
'user_ids': fields.many2many('res.users', 'invite_user_rel',
|
||||
'invite_id', 'user_id', 'Users'),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner'),
|
||||
'email': fields.char('Email', size=124),
|
||||
'contact_ids': fields.many2many('res.partner.address', 'invite_contact_rel',
|
||||
'invite_id', 'contact_id', 'Contacts'),
|
||||
'send_mail': fields.boolean('Send mail?', help='Check this if you want\
|
||||
to send an Email to Invited Person')
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'type': lambda *x: 'internal'
|
||||
}
|
||||
|
||||
def do_invite(self, cr, uid, ids, context={}):
|
||||
"""
|
||||
Invite attendee for meeting..
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param ids: List of base calendar invite attendee’s IDs.
|
||||
@param context: A standard dictionary for contextual values
|
||||
@return: Dictionary of {}.
|
||||
"""
|
||||
for datas in self.read(cr, uid, ids):
|
||||
|
||||
model = False
|
||||
model_field = False
|
||||
context_id = context and context.get('active_id', False) or False
|
||||
if not context or not context.get('model'):
|
||||
return {}
|
||||
else:
|
||||
model = context.get('model')
|
||||
model_field = context.get('attendee_field', False)
|
||||
|
||||
obj = self.pool.get(model)
|
||||
res_obj = obj.browse(cr, uid, context_id)
|
||||
type = datas.get('type')
|
||||
att_obj = self.pool.get('calendar.attendee')
|
||||
vals = []
|
||||
mail_to = []
|
||||
attendees = []
|
||||
ref = {}
|
||||
|
||||
if not model == 'calendar.attendee':
|
||||
if context_id:
|
||||
ref = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context_id))}
|
||||
else:
|
||||
return {}
|
||||
if type == 'internal':
|
||||
user_obj = self.pool.get('res.users')
|
||||
if not datas.get('user_ids'):
|
||||
raise osv.except_osv(_('Error!'), ("Please select any User"))
|
||||
for user_id in datas.get('user_ids'):
|
||||
user = user_obj.browse(cr, uid, user_id)
|
||||
res = {
|
||||
'user_id': user_id,
|
||||
'email': user.address_id.email
|
||||
}
|
||||
res.update(ref)
|
||||
vals.append(res)
|
||||
if user.address_id.email:
|
||||
mail_to.append(user.address_id.email)
|
||||
|
||||
elif type == 'external' and datas.get('email'):
|
||||
res = {'email': datas['email']}
|
||||
res.update(ref)
|
||||
vals.append(res)
|
||||
mail_to.append(datas['email'])
|
||||
|
||||
elif type == 'partner':
|
||||
add_obj = self.pool.get('res.partner.address')
|
||||
for contact in add_obj.browse(cr, uid, datas['contact_ids']):
|
||||
res = {
|
||||
'partner_address_id': contact.id,
|
||||
'email': contact.email
|
||||
}
|
||||
res.update(ref)
|
||||
vals.append(res)
|
||||
if contact.email:
|
||||
mail_to.append(contact.email)
|
||||
|
||||
att = att_obj.browse(cr, uid, context_id)
|
||||
|
||||
for att_val in vals:
|
||||
if model == 'calendar.attendee':
|
||||
if ref:
|
||||
att_val.update({
|
||||
'parent_ids': [(4, att.id)],
|
||||
'ref': att.ref._name + ',' +str(att.ref.id)
|
||||
})
|
||||
attendees.append(att_obj.create(cr, uid, att_val))
|
||||
if model_field:
|
||||
for attendee in attendees:
|
||||
obj.write(cr, uid, res_obj.id, {model_field: [(4, attendee)]})
|
||||
|
||||
if datas.get('send_mail'):
|
||||
if not mail_to:
|
||||
name = map(lambda x: x[1], filter(lambda x: type==x[0], \
|
||||
self._columns['type'].selection))
|
||||
raise osv.except_osv(_('Error!'), ("%s must have an email \
|
||||
Address to send mail") % (name[0]))
|
||||
att_obj._send_mail(cr, uid, attendees, mail_to, \
|
||||
email_from=tools.config.get('email_from', False))
|
||||
|
||||
return {}
|
||||
|
||||
|
||||
def onchange_partner_id(self, cr, uid, ids, partner_id, *args, **argv):
|
||||
"""
|
||||
Make entry on contact_ids on change of partner_id field.
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param ids: List of base calendar invite attendee’s IDs.
|
||||
@return: dictionary of value.
|
||||
"""
|
||||
if not partner_id:
|
||||
return {'value': {'contact_ids': []}}
|
||||
cr.execute('select id from res_partner_address \
|
||||
where partner_id=%s' % (partner_id))
|
||||
contacts = map(lambda x: x[0], cr.fetchall())
|
||||
return {'value': {'contact_ids': contacts}}
|
||||
|
||||
invite_attendee_wizard()
|
||||
|
||||
class calendar_attendee(osv.osv):
|
||||
"""
|
||||
Calendar Attendee Information
|
||||
|
@ -412,7 +276,7 @@ class calendar_attendee(osv.osv):
|
|||
result[id][name] = uid
|
||||
if name == 'language':
|
||||
user_obj = self.pool.get('res.users')
|
||||
lang = user_obj.read(cr, uid, uid, ['context_lang'])['context_lang']
|
||||
lang = user_obj.read(cr, uid, uid, ['context_lang'], context=context)['context_lang']
|
||||
result[id][name] = lang.replace('_', '-')
|
||||
return result
|
||||
|
||||
|
@ -426,7 +290,7 @@ class calendar_attendee(osv.osv):
|
|||
"""
|
||||
obj = self.pool.get('res.request.link')
|
||||
ids = obj.search(cr, uid, [])
|
||||
res = obj.read(cr, uid, ids, ['object', 'name'], context)
|
||||
res = obj.read(cr, uid, ids, ['object', 'name'], context=context)
|
||||
return [(r['object'], r['name']) for r in res]
|
||||
|
||||
def _lang_get(self, cr, uid, context={}):
|
||||
|
@ -439,7 +303,7 @@ class calendar_attendee(osv.osv):
|
|||
"""
|
||||
obj = self.pool.get('res.lang')
|
||||
ids = obj.search(cr, uid, [])
|
||||
res = obj.read(cr, uid, ids, ['code', 'name'], context)
|
||||
res = obj.read(cr, uid, ids, ['code', 'name'], context=context)
|
||||
res = [((r['code']).replace('_', '-'), r['name']) for r in res]
|
||||
return res
|
||||
|
||||
|
|
|
@ -2,61 +2,6 @@
|
|||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Attendee invite wizard-->
|
||||
|
||||
<record id="view_calendar_invite_attendee_wizard" model="ir.ui.view">
|
||||
<field name="name">Invite Attendees</field>
|
||||
<field name="model">base_calendar.invite.attendee</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Invite People">
|
||||
<field name="type" />
|
||||
<field name="send_mail" />
|
||||
<newline/>
|
||||
<group col="1" colspan="4"
|
||||
attrs="{'invisible': [('type', '!=', 'external')]}">
|
||||
<field name="email" colspan="4"
|
||||
attrs="{'required': [('type', '=', 'external')]}" />
|
||||
</group>
|
||||
<group col="1" colspan="4"
|
||||
attrs="{'invisible': [('type', '!=', 'internal')]}">
|
||||
<separator string="Users" colspan="4" />
|
||||
<field name="user_ids" select="1" colspan="4"
|
||||
nolabel="1" />
|
||||
<newline />
|
||||
</group>
|
||||
<group col="2" colspan="4"
|
||||
attrs="{'invisible': [('type', '!=', 'partner')]}">
|
||||
<field name="partner_id" colspan="2"
|
||||
on_change="onchange_partner_id(partner_id)"
|
||||
attrs="{'required': [('type', '=', 'partner')]}" />
|
||||
<newline />
|
||||
<separator string="Partner Contacts"
|
||||
colspan="4" />
|
||||
<field name="contact_ids" select="1" colspan="4"
|
||||
nolabel="1" domain="[('partner_id', '=', partner_id)]"
|
||||
attrs="{'readonly': [('type', '!=', 'partner')]}" />
|
||||
</group>
|
||||
<newline/>
|
||||
<separator string="" colspan="6" />
|
||||
<label string="" colspan="2" />
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="Cancel" />
|
||||
<button name="do_invite" string="Invite"
|
||||
type="object" icon="gtk-ok" />
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_view_calendar_invite_attendee_wizard" model="ir.actions.act_window">
|
||||
<field name="name">Invite Attendees</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">base_calendar.invite.attendee</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record id="base_calendar_attendee_form_view" model="ir.ui.view">
|
||||
<field name="name">calendar.attendee.form</field>
|
||||
<field name="model">calendar.attendee</field>
|
||||
|
@ -64,7 +9,7 @@
|
|||
<field name="arch" type="xml">
|
||||
<form string="Invitation details">
|
||||
<field name="email" string="Invitation To"/>
|
||||
<field name="sent_by_uid" string="Invitation From"/>
|
||||
<field name="sent_by_uid" string="Invitation From" />
|
||||
<notebook colspan="4">
|
||||
<page string="Invitation">
|
||||
<separator string="Invitation Detail" colspan="4" />
|
||||
|
@ -97,7 +42,7 @@
|
|||
</page>
|
||||
</notebook>
|
||||
<group col="6" colspan="4">
|
||||
<field name="state" select="2" />
|
||||
<field name="state" />
|
||||
<button name="do_tentative"
|
||||
states="needs-action,declined,accepted"
|
||||
string="Uncertain" type="object"
|
||||
|
@ -134,8 +79,28 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
<record id="base_calendar_attendee_search_view" model="ir.ui.view">
|
||||
<field name="name">calendar.attendee.search</field>
|
||||
<field name="model">calendar.attendee</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search Invitations">
|
||||
<filter icon="gtk-apply" string="Accepted"
|
||||
domain="[('state','=', 'accepted')]"
|
||||
separator="1" help="Accepted Invitations" />
|
||||
<filter icon="gtk-close" string="Declined"
|
||||
domain="[('state','=', 'declined')]"
|
||||
separator="1" help="Declined Invitations" />
|
||||
<separator orientation="vertical"/>
|
||||
<field name="email" select='1'/>
|
||||
<field name="sent_by_uid" select="1" widget="selection"/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="cutype" string="Invitation type" select="1"/>
|
||||
<field name="event_date" select="1"/>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="res_alarm_form_view" model="ir.ui.view">
|
||||
<field name="name">res.alarm.form</field>
|
||||
<field name="model">res.alarm</field>
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
##############################################################################
|
||||
|
||||
import calendar_event_edit_all
|
||||
import base_calendar_invite_attendee
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
Loading…
Reference in New Issue