[ADD]: Accept/Decline button on meeting form for individual attendee and make invitation tab invisible for them to restrict them to accept/decline others invitation.
bzr revid: aja@tinyerp.com-20130722130516-as96rrer4a9ohwld
This commit is contained in:
parent
fe018642ed
commit
53521121dd
|
@ -44,6 +44,22 @@ class crm_meeting(base_state, osv.Model):
|
|||
_description = "Meeting"
|
||||
_order = "id desc"
|
||||
_inherit = ["calendar.event", "mail.thread", "ir.needaction_mixin"]
|
||||
|
||||
def _check_status(self, cr, uid, ids, context=None):
|
||||
attendee_pool = self.pool.get('calendar.attendee')
|
||||
user = self.pool.get('res.users').read(cr,uid,uid,['partner_id'],context)
|
||||
for attendee in self.browse(cr,uid,ids,context)[0].attendee_ids:
|
||||
if user['partner_id'][0] == attendee_pool.read(cr,uid,attendee.id,['partner_id'],context)['partner_id'][0]:
|
||||
return attendee
|
||||
return False
|
||||
|
||||
def _check_attendee(self, cr, uid, ids, name, arg, context=None):
|
||||
res = {}
|
||||
res[ids[0]] = False
|
||||
if self._check_status(cr, uid, ids, context):
|
||||
res[ids[0]] = True
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
# base_state required fields
|
||||
'create_date': fields.datetime('Creation Date', readonly=True),
|
||||
|
@ -61,6 +77,8 @@ class crm_meeting(base_state, osv.Model):
|
|||
'event_id', 'type_id', 'Tags'),
|
||||
'attendee_ids': fields.many2many('calendar.attendee', 'meeting_attendee_rel',\
|
||||
'event_id', 'attendee_id', 'Invited People', states={'done': [('readonly', True)]}),
|
||||
'is_attendee': fields.function(_check_attendee, string='Attendee', \
|
||||
type="boolean"),
|
||||
}
|
||||
_defaults = {
|
||||
'state': 'open',
|
||||
|
@ -121,6 +139,24 @@ class crm_meeting(base_state, osv.Model):
|
|||
thread_id = get_real_ids(thread_id)
|
||||
return super(crm_meeting, self).message_post(cr, uid, thread_id, body=body, subject=subject, type=type, subtype=subtype, parent_id=parent_id, attachments=attachments, context=context, **kwargs)
|
||||
|
||||
def do_decline(self, cr, uid, ids, context=None, *args):
|
||||
attendee_pool = self.pool.get('calendar.attendee')
|
||||
attendee = self._check_status(cr, uid, ids, context)
|
||||
if attendee:
|
||||
if attendee.state != 'declined':
|
||||
self.message_post(cr, uid, ids, body=_(("%s has Declined Invitation") % (attendee.cn)), context=context)
|
||||
attendee_pool.write(cr, uid, attendee.id, {'state': 'declined'}, context)
|
||||
return True
|
||||
|
||||
def do_accept(self, cr, uid, ids, context=None, *args):
|
||||
attendee_pool = self.pool.get('calendar.attendee')
|
||||
attendee = self._check_status(cr, uid, ids, context)
|
||||
if attendee:
|
||||
if attendee.state != 'accepted':
|
||||
self.message_post(cr, uid, ids, body=_(("%s has Accepted Invitation") % (attendee.cn)), context=context)
|
||||
attendee_pool.write(cr, uid, attendee.id, {'state': 'accepted'}, context)
|
||||
return True
|
||||
|
||||
class mail_message(osv.osv):
|
||||
_inherit = "mail.message"
|
||||
|
||||
|
|
|
@ -32,8 +32,15 @@
|
|||
<field name="model">crm.meeting</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Meetings" version="7.0">
|
||||
<field name="state" invisible="True"/>
|
||||
<header>
|
||||
<button name="do_accept" type="object"
|
||||
string="Accept" attrs="{'invisible':[('is_attendee','=',False)]}"/>
|
||||
<button name="do_decline" type="object"
|
||||
string="Decline" attrs="{'invisible':[('is_attendee','=',False)]}"/>
|
||||
<field name="state" invisible="True"/>
|
||||
</header>
|
||||
<sheet>
|
||||
<field name="is_attendee" invisible="1"/>
|
||||
<div class="oe_title">
|
||||
<div class="oe_edit_only">
|
||||
<label for="name"/>
|
||||
|
@ -133,16 +140,16 @@
|
|||
</group>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Invitations">
|
||||
<page string="Invitations" attrs="{'invisible':[('is_attendee','=',True)]}">
|
||||
<field name="attendee_ids" widget="one2many" mode="tree">
|
||||
<tree string="Invitation details" editable="top">
|
||||
<tree string="Invitation details" editable="top" >
|
||||
<field name="partner_id" on_change="onchange_partner_id(partner_id)"/>
|
||||
<field name="email" string="Mail To"/>
|
||||
<field name="state"/>
|
||||
<button name="do_tentative"
|
||||
states="needs-action,declined,accepted"
|
||||
string="Uncertain" type="object"
|
||||
icon="terp-crm"/>
|
||||
icon="terp-crm" />
|
||||
<button name="do_accept" string="Accept"
|
||||
states="needs-action,tentative,declined"
|
||||
type="object" icon="gtk-apply"/>
|
||||
|
@ -183,7 +190,7 @@
|
|||
</sheet>
|
||||
<div class="oe_chatter">
|
||||
<field name="message_follower_ids" widget="mail_followers"/>
|
||||
<field name="message_ids" widget="mail_thread"/>
|
||||
<field name="message_ids" widget="mail_thread" />
|
||||
</div>
|
||||
</form>
|
||||
</field>
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
</record>
|
||||
<record id="meeting_invitation_personal" model="ir.rule">
|
||||
<field name="name">Show Only Personal Invitation</field>
|
||||
<field ref="model_calendar_attendee" name="model_id"/>
|
||||
<field ref="model_crm_meeting" name="model_id"/>
|
||||
<field eval="1" name="personal"/>
|
||||
<field name="domain_force">[('user_id','=',user.id)]</field>
|
||||
<field name="domain_force">[('attendee_ids.partner_id','=',user.partner_id.id)]</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
Loading…
Reference in New Issue