[IMP] improve code

bzr revid: avo@tinyerp.com-20140328063012-mxvgudl5b3219j2i
This commit is contained in:
Amit Vora 2014-03-28 12:00:12 +05:30
parent d88835ed66
commit d892a5b38e
4 changed files with 12 additions and 9 deletions

View File

@ -79,7 +79,9 @@ class crm_lead(format_address, osv.osv):
'crm.mt_lead_lost': lambda self, cr, uid, obj, ctx=None: obj.probability == 0 and obj.stage_id and obj.stage_id.fold and obj.stage_id.sequence > 1, 'crm.mt_lead_lost': lambda self, cr, uid, obj, ctx=None: obj.probability == 0 and obj.stage_id and obj.stage_id.fold and obj.stage_id.sequence > 1,
}, },
} }
def schedule_meeting(self, cr, uid, id, context=None):
return self.pool.get('res.partner').schedule_meeting(cr, uid, id, context=context)
def get_empty_list_help(self, cr, uid, help, context=None): def get_empty_list_help(self, cr, uid, help, context=None):
if context.get('default_type') == 'lead': if context.get('default_type') == 'lead':
context['empty_list_help_model'] = 'crm.case.section' context['empty_list_help_model'] = 'crm.case.section'

View File

@ -392,9 +392,8 @@
<button class="oe_inline" type="action" string="Calls" <button class="oe_inline" type="action" string="Calls"
name="%(crm.crm_case_categ_phone_incoming0)d" name="%(crm.crm_case_categ_phone_incoming0)d"
context="{'default_opportunity_id': active_id, 'search_default_opportunity_id': active_id, 'default_partner_id': partner_id, 'default_duration': 1.0}"/> context="{'default_opportunity_id': active_id, 'search_default_opportunity_id': active_id, 'default_partner_id': partner_id, 'default_duration': 1.0}"/>
<button string="Schedule a Meeting" type="action" <button class="oe_inline" string="Schedule a Meeting" type="object"
name="%(calendar.action_calendar_event)d" name="schedule_meeting" context="{'partner_id': partner_id}"/>
context="{'default_partner_ids': partner_id and [partner_id]}"/>
</div> </div>
<div class="oe_title"> <div class="oe_title">
<label for="name" class="oe_edit_only"/> <label for="name" class="oe_edit_only"/>

View File

@ -28,12 +28,14 @@ class res_partner(osv.osv):
def schedule_meeting(self, cr, uid, id, context=None): def schedule_meeting(self, cr, uid, id, context=None):
if context is None: if context is None:
context = {} context = {}
user_id = context.get('user_id') partner_ids = []
if user_id: partner_id = context.get('partner_id')
partner_id = self.pool.get('res.users').browse(cr, uid, user_id).partner_id.id if partner_id:
partner_ids.append(partner_id)
partner_ids.append(self.pool.get('res.users').browse(cr, uid, uid).partner_id.id)
res = self.pool.get('ir.actions.act_window').for_xml_id(cr, uid, 'calendar', 'action_calendar_event', context) res = self.pool.get('ir.actions.act_window').for_xml_id(cr, uid, 'calendar', 'action_calendar_event', context)
res['context'] = { res['context'] = {
'default_partner_ids': user_id and [partner_id], 'default_partner_ids': partner_ids,
} }
return res return res

View File

@ -95,7 +95,7 @@
name="%(crm.crm_case_category_act_oppor11)d" name="%(crm.crm_case_category_act_oppor11)d"
context="{'search_default_partner_id': active_id}"/> context="{'search_default_partner_id': active_id}"/>
<button class="oe_inline" string="Schedule a Meeting" type="object" <button class="oe_inline" string="Schedule a Meeting" type="object"
name="schedule_meeting" context="{'user_id': user_id}"/> name="schedule_meeting" context="{'partner_id': active_id}"/>
<button class="oe_inline" type="action" string="Calls" <button class="oe_inline" type="action" string="Calls"
name="%(crm.crm_case_categ_phone_incoming0)d" name="%(crm.crm_case_categ_phone_incoming0)d"
context="{'search_default_partner_id': active_id, 'default_duration': 1.0}"/> context="{'search_default_partner_id': active_id, 'default_duration': 1.0}"/>