[IMP] improve code

bzr revid: voraamitr@gmail.com-20140307113617-5lfnkqlcnavr8f57
This commit is contained in:
Amit Vora (OpenERP) 2014-03-07 17:06:17 +05:30
parent ae1d637c82
commit 81db3c3a19
3 changed files with 13 additions and 2 deletions

View File

@ -791,6 +791,17 @@ class calendar_event(osv.Model):
self.write(cr, uid, ids, data, context=context)
return True
def default_get(self, cr, uid, fields, context=None):
res = super(calendar_event, self).default_get(cr, uid, fields, context=context)
if context.get('active_model') == 'res.partner':
if context.get('user_id'):
res.update({'partner_ids' : [self.pool['res.users'].browse(cr, uid, context.get('user_id'), context=context).partner_id.id]})
if context.get('active_model') == 'crm.lead':
if context.get('partner_id'):
res.update({'partner_ids' : [context.get('partner_id')]})
return res
def _tz_get(self, cr, uid, context=None):
return [(x.lower(), x) for x in pytz.all_timezones]

View File

@ -395,7 +395,7 @@
context="{'default_opportunity_id': active_id, 'search_default_opportunity_id': active_id, 'default_partner_id': partner_id, 'default_duration': 1.0}" />
<button string="Schedule Meeting" type="action"
name="%(calendar.action_calendar_event)d"
context="{'search_default_attendee_id': active_id, 'default_attendee_id' : active_id}"/>
context="{'partner_id': partner_id}"/>
</div>
<div class="oe_title">
<label for="name" class="oe_edit_only"/>

View File

@ -97,7 +97,7 @@
<button class="oe_inline" type="action"
string="Schedule Meetings"
name="%(calendar.action_calendar_event)d"
context="{'search_default_partner_ids': active_id, 'default_partner_ids' : [active_id]}"/>
context="{'user_id': user_id}"/>
<button class="oe_inline" type="action" string="Calls"
name="%(crm.crm_case_categ_phone_incoming0)d"
context="{'search_default_partner_id': active_id, 'default_duration': 1.0}" />