[FIX]crm_lead, crm_meeting: when creating a meeting from an opportunity, add a message in open chatter

bzr revid: csn@openerp.com-20130415141507-m5arvgjcaf587a09
This commit is contained in:
Cedric Snauwaert 2013-04-15 16:15:07 +02:00
parent 730eb11152
commit e38a28a2b7
2 changed files with 15 additions and 0 deletions

View File

@ -1045,6 +1045,14 @@ class crm_lead(base_stage, format_address, osv.osv):
message = _("%s a call for %s.%s") % (prefix, phonecall.date, suffix)
return self.message_post(cr, uid, ids, body=message, context=context)
def log_meeting(self, cr, uid, ids, meeting_subject, meeting_date, duration, context=None):
if not duration:
duration = 'unknow'
else:
duration = str(duration)+'h'
message = _("Meeting: '%s' has been scheduled at '%s' <br> Duration: %s" % (meeting_subject, meeting_date, duration))
return self.message_post(cr, uid, ids, body=message, context=context)
def onchange_state(self, cr, uid, ids, state_id, context=None):
if state_id:
country_id=self.pool.get('res.country.state').browse(cr, uid, state_id, context).country_id.id

View File

@ -34,6 +34,13 @@ class crm_meeting(osv.Model):
'opportunity_id': fields.many2one ('crm.lead', 'Opportunity', domain="[('type', '=', 'opportunity')]"),
}
def create(self, cr, uid, vals, context=None):
res = super(crm_meeting,self).create(cr, uid, vals, context=context)
obj = self.browse(cr, uid, res, context=context)
if obj.opportunity_id:
self.pool.get('crm.lead').log_meeting(cr, uid, obj.opportunity_id.id, obj.name, obj.date, obj.duration, context=context)
return res
class calendar_attendee(osv.osv):
""" Calendar Attendee """