[IMP] Improve the code

bzr revid: ggh@tinyerp.com-20130516134304-md4kapvo1yt6q4c0
This commit is contained in:
Farid Ghanchi (OpenERP) 2013-05-16 19:13:04 +05:30
parent c24ba91ef9
commit 7d276f0153
1 changed files with 7 additions and 13 deletions

View File

@ -86,9 +86,9 @@ class sale_order_line(osv.osv):
'event_id': order_line.event_id.id,
}
message = _("The registration has been <b>created</b> for event <i>%s</i> from the Sale Order %s. ") % (order_line.event_id.name, order_line.order_id.name)
context.update({'sale_event': True, 'message': message })
context.update({'mail_create_nolog': True, 'sale_event': True, 'message': message })
registration_id = registration_obj.create(cr, uid, dic, context=context)
registration_obj.create_send_note(cr, uid, registration_id, context=context)
registration_obj.message_post(cr, uid, registration_id, body=message, context=context)
return super(sale_order_line, self).button_confirm(cr, uid, ids, context=context)
sale_order_line()
@ -96,14 +96,8 @@ sale_order_line()
class event_registration(osv.osv):
_inherit = 'event.registration'
# ----------------------------------------
# OpenChatter methods and notifications
# ----------------------------------------
def create_send_note(self, cr, uid, ids, context=None):
if context.get("sale_event") and context.get("message"):
message = context.get("message")
self.message_post(cr, uid, ids, body=message, context=context)
else:
super(event_registration, self).create_send_note(cr, uid, ids, context=context)
return True
def message_post(self, cr, uid, thread_id, body='', subject=None, type='notification', subtype=None, parent_id=False, attachments=None, context=None, content_subtype='html', **kwargs):
""" Overrides mail_thread message_post so that we can set the message note when
a new registration create on the event sale.
"""
return super(event_registration, self).message_post(cr, uid, thread_id, body=body, subject=subject, type=type, subtype=subtype, parent_id=parent_id, attachments=attachments, context=context, content_subtype=content_subtype, **kwargs)