[FIX] calendar/crm: Add active_id (if in model partner_id) in defaults values from partner_ids when we creates a new meeting.
Bug was that when you click on meeting button from a res_partner form (Customers in menu), the button overwrites the context to use the active partner as a default in the calendar meeting. By consequence, the context overwritte the default partner who are the creator. Now the context could be removed from action and that is in get_default for partner_ids (from model calendar_event) that we add the creator AND the active_id if from a model res_partner.
This commit is contained in:
parent
b0b9153cf7
commit
6655a020c3
|
@ -855,6 +855,15 @@ class calendar_event(osv.Model):
|
|||
'alarm_ids': fields.many2many('calendar.alarm', string='Reminders', ondelete="restrict"),
|
||||
|
||||
}
|
||||
|
||||
def _get_default_partners(self, cr, uid, ctx=None):
|
||||
ret = [self.pool['res.users'].browse(cr, uid, uid, context=ctx).partner_id.id]
|
||||
active_id = ctx.get('active_id')
|
||||
if ctx.get('active_model') == 'res.partner' and active_id:
|
||||
if active_id not in ret:
|
||||
ret.append(active_id)
|
||||
return ret
|
||||
|
||||
_defaults = {
|
||||
'end_type': 'count',
|
||||
'count': 1,
|
||||
|
@ -866,7 +875,7 @@ class calendar_event(osv.Model):
|
|||
'interval': 1,
|
||||
'active': 1,
|
||||
'user_id': lambda self, cr, uid, ctx: uid,
|
||||
'partner_ids': lambda self, cr, uid, ctx: [self.pool['res.users'].browse(cr, uid, [uid], context=ctx)[0].partner_id.id]
|
||||
'partner_ids': _get_default_partners,
|
||||
}
|
||||
|
||||
def _check_closing_date(self, cr, uid, ids, context=None):
|
||||
|
|
|
@ -97,7 +97,7 @@
|
|||
<button class="oe_inline" type="action"
|
||||
string="Meetings"
|
||||
name="%(calendar.action_calendar_event)d"
|
||||
context="{'search_default_partner_ids': active_id, 'default_partner_ids' : [active_id]}"/>
|
||||
context="{'search_default_partner_ids': active_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}" />
|
||||
|
|
Loading…
Reference in New Issue