[IMP] Merging different ways of posting a message:

message_append_note
  message_append_dict
  message_append
  --> merged all to message_post

bzr revid: fp@tinyerp.com-20120817100302-bqsqv23ogrchslew
This commit is contained in:
Fabien Pinckaers 2012-08-17 12:03:02 +02:00
parent cb944d66ea
commit b62858e83e
42 changed files with 197 additions and 408 deletions

View File

@ -430,7 +430,7 @@ class account_bank_statement(osv.osv):
'name': st_number,
'balance_end_real': st.balance_end
}, context=context)
self.message_append_note(cr, uid, [st.id], body=_('Statement %s is confirmed, journal items are created.') % (st_number,), context=context)
self.message_post(cr, uid, [st.id], body=_('Statement %s is confirmed, journal items are created.') % (st_number,), context=context)
return self.write(cr, uid, ids, {'state':'confirm'}, context=context)
def button_cancel(self, cr, uid, ids, context=None):

View File

@ -1045,7 +1045,7 @@ class account_invoice(osv.osv):
if obj_inv.type in ('out_invoice', 'out_refund'):
ctx = self.get_log_context(cr, uid, context=ctx)
message = _("Invoice '%s' is validated.") % name
self.message_append_note(cr, uid, [inv_id], body=message, context=context)
self.message_post(cr, uid, [inv_id], body=message, context=context)
return True
def action_cancel(self, cr, uid, ids, *args):
@ -1275,7 +1275,7 @@ class account_invoice(osv.osv):
# TODO: use currency's formatting function
msg = _("Invoice '%s' is paid partially: %s%s of %s%s (%s%s remaining).") % \
(name, pay_amount, code, invoice.amount_total, code, total, code)
self.message_append_note(cr, uid, [inv_id], body=msg, context=context)
self.message_post(cr, uid, [inv_id], body=msg, context=context)
self.pool.get('account.move.line').reconcile_partial(cr, uid, line_ids, 'manual', context)
# Update the stored value (fields.function), so we write to trigger recompute
@ -1297,15 +1297,15 @@ class account_invoice(osv.osv):
def create_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
self.message_append_note(cr, uid, [obj.id],body=_("%s <b>created</b>.") % (self._get_document_type(obj.type)), context=context)
self.message_post(cr, uid, [obj.id],body=_("%s <b>created</b>.") % (self._get_document_type(obj.type)), context=context)
def confirm_paid_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
self.message_append_note(cr, uid, [obj.id], body=_("%s <b>paid</b>.") % (self._get_document_type(obj.type)), context=context)
self.message_post(cr, uid, [obj.id], body=_("%s <b>paid</b>.") % (self._get_document_type(obj.type)), context=context)
def invoice_cancel_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
self.message_append_note(cr, uid, [obj.id], body=_("%s <b>cancelled</b>.") % (self._get_document_type(obj.type)), context=context)
self.message_post(cr, uid, [obj.id], body=_("%s <b>cancelled</b>.") % (self._get_document_type(obj.type)), context=context)
account_invoice()

View File

@ -1292,17 +1292,17 @@ class account_voucher(osv.osv):
def create_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
message = "%s <b>created</b>." % self._document_type[obj.type or False]
self.message_append_note(cr, uid, [obj.id], body=message, context=context)
self.message_post(cr, uid, [obj.id], body=message, context=context)
def post_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
message = "%s '%s' is <b>posted</b>." % (self._document_type[obj.type or False], obj.move_id.name)
self.message_append_note(cr, uid, [obj.id], body=message, context=context)
self.message_post(cr, uid, [obj.id], body=message, context=context)
def reconcile_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
message = "%s <b>reconciled</b>." % self._document_type[obj.type or False]
self.message_append_note(cr, uid, [obj.id], body=message, context=context)
self.message_post(cr, uid, [obj.id], body=message, context=context)
account_voucher()

View File

@ -297,7 +297,7 @@ class account_analytic_account(osv.osv):
def create_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
self.message_append_note(cr, uid, [obj.id], body=_("Contract for <em>%s</em> has been <b>created</b>.") % (obj.partner_id.name), context=context)
self.message_post(cr, uid, [obj.id], body=_("Contract for <em>%s</em> has been <b>created</b>.") % (obj.partner_id.name), context=context)
account_analytic_account()

View File

@ -79,6 +79,6 @@ class task(osv.osv):
task_id = super(task, self).create(cr, uid, vals, context=context)
task_browse = self.browse(cr, uid, task_id, context=context)
if task_browse.project_id.analytic_account_id:
self.pool.get('account.analytic.account').message_append_note(cr, uid, [task_browse.project_id.analytic_account_id.id], body=_("Task <em>%s</em> has been <b>created</b>.") % (task_browse.name), context=context)
self.pool.get('account.analytic.account').message_post(cr, uid, [task_browse.project_id.analytic_account_id.id], body=_("Task <em>%s</em> has been <b>created</b>.") % (task_browse.name), context=context)
return task_id
task()

View File

@ -78,9 +78,9 @@ class crm_meeting(base_state, osv.Model):
return 'Meeting'
def case_open_send_note(self, cr, uid, ids, context=None):
return self.message_append_note(cr, uid, ids, body=_("Meeting has been <b>confirmed</b>."), context=context)
return self.message_post(cr, uid, ids, body=_("Meeting has been <b>confirmed</b>."), context=context)
def case_close_send_note(self, cr, uid, ids, context=None):
return self.message_append_note(cr, uid, ids, body=_("Meeting has been <b>done</b>."), context=context)
return self.message_post(cr, uid, ids, body=_("Meeting has been <b>done</b>."), context=context)

View File

@ -395,31 +395,31 @@ class base_stage(object):
def case_open_send_note(self, cr, uid, ids, context=None):
for id in ids:
msg = _('%s has been <b>opened</b>.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context))
self.message_append_note(cr, uid, [id], body=msg, context=context)
self.message_post(cr, uid, [id], body=msg, context=context)
return True
def case_close_send_note(self, cr, uid, ids, context=None):
for id in ids:
msg = _('%s has been <b>closed</b>.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context))
self.message_append_note(cr, uid, [id], body=msg, context=context)
self.message_post(cr, uid, [id], body=msg, context=context)
return True
def case_cancel_send_note(self, cr, uid, ids, context=None):
for id in ids:
msg = _('%s has been <b>canceled</b>.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context))
self.message_append_note(cr, uid, [id], body=msg, context=context)
self.message_post(cr, uid, [id], body=msg, context=context)
return True
def case_pending_send_note(self, cr, uid, ids, context=None):
for id in ids:
msg = _('%s is now <b>pending</b>.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context))
self.message_append_note(cr, uid, [id], body=msg, context=context)
self.message_post(cr, uid, [id], body=msg, context=context)
return True
def case_reset_send_note(self, cr, uid, ids, context=None):
for id in ids:
msg = _('%s has been <b>renewed</b>.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context))
self.message_append_note(cr, uid, [id], body=msg, context=context)
self.message_post(cr, uid, [id], body=msg, context=context)
return True
def case_escalate_send_note(self, cr, uid, ids, new_section=None, context=None):
@ -428,5 +428,5 @@ class base_stage(object):
msg = '%s has been <b>escalated</b> to <b>%s</b>.' % (self.case_get_note_msg_prefix(cr, uid, id, context=context), new_section.name)
else:
msg = '%s has been <b>escalated</b>.' % (self.case_get_note_msg_prefix(cr, uid, id, context=context))
self.message_append_note(cr, uid, [id], 'System Notification', msg, context=context)
self.message_post(cr, uid, [id], 'System Notification', msg, context=context)
return True

View File

@ -185,7 +185,7 @@ class base_state(object):
def case_open_send_note(self, cr, uid, ids, context=None):
for id in ids:
msg = _('%s has been <b>opened</b>.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context))
self.message_append_note(cr, uid, [id], body=msg, context=context)
self.message_post(cr, uid, [id], body=msg, context=context)
return True
def case_escalate_send_note(self, cr, uid, ids, new_section=None, context=None):
@ -194,29 +194,29 @@ class base_state(object):
msg = '%s has been <b>escalated</b> to <b>%s</b>.' % (self.case_get_note_msg_prefix(cr, uid, id, context=context), new_section.name)
else:
msg = '%s has been <b>escalated</b>.' % (self.case_get_note_msg_prefix(cr, uid, id, context=context))
self.message_append_note(cr, uid, [id], 'System Notification', msg, context=context)
self.message_post(cr, uid, [id], 'System Notification', msg, context=context)
return True
def case_close_send_note(self, cr, uid, ids, context=None):
for id in ids:
msg = _('%s has been <b>closed</b>.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context))
self.message_append_note(cr, uid, [id], body=msg, context=context)
self.message_post(cr, uid, [id], body=msg, context=context)
return True
def case_cancel_send_note(self, cr, uid, ids, context=None):
for id in ids:
msg = _('%s has been <b>canceled</b>.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context))
self.message_append_note(cr, uid, [id], body=msg, context=context)
self.message_post(cr, uid, [id], body=msg, context=context)
return True
def case_pending_send_note(self, cr, uid, ids, context=None):
for id in ids:
msg = _('%s is now <b>pending</b>.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context))
self.message_append_note(cr, uid, [id], body=msg, context=context)
self.message_post(cr, uid, [id], body=msg, context=context)
return True
def case_reset_send_note(self, cr, uid, ids, context=None):
for id in ids:
msg = _('%s has been <b>renewed</b>.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context))
self.message_append_note(cr, uid, [id], body=msg, context=context)
self.message_post(cr, uid, [id], body=msg, context=context)
return True

View File

@ -106,7 +106,7 @@ class base_action_rule(osv.osv):
# Put state change by rule in communication history
if hasattr(obj, 'state') and hasattr(obj, 'message_append') and action.act_state:
model_obj.message_append(cr, uid, [obj], _(action.act_state))
model_obj.message_post(cr, uid, [obj], _(action.act_state))
model_obj.write(cr, uid, [obj.id], write, context)
super(base_action_rule, self).do_action(cr, uid, action, model_obj, obj, context=context)

View File

@ -488,7 +488,7 @@ class crm_lead(base_stage, osv.osv):
subject = subject[0] + ", ".join(subject[1:])
details = "\n\n".join(details)
return self.message_append_note(cr, uid, [opportunity_id], subject=subject, body=details)
return self.message_post(cr, uid, [opportunity_id], subject=subject, body=details)
def _merge_opportunity_history(self, cr, uid, opportunity_id, opportunities, context=None):
message = self.pool.get('mail.message')
@ -860,7 +860,7 @@ class crm_lead(base_stage, osv.osv):
def stage_set_send_note(self, cr, uid, ids, stage_id, context=None):
""" Override of the (void) default notification method. """
stage_name = self.pool.get('crm.case.stage').name_get(cr, uid, [stage_id], context=context)[0][1]
return self.message_append_note(cr, uid, ids, body= _("Stage changed to <b>%s</b>.") % (stage_name), context=context)
return self.message_post(cr, uid, ids, body= _("Stage changed to <b>%s</b>.") % (stage_name), context=context)
def case_get_note_msg_prefix(self, cr, uid, lead, context=None):
if isinstance(lead, (int, long)):
@ -870,33 +870,33 @@ class crm_lead(base_stage, osv.osv):
def create_send_note(self, cr, uid, ids, context=None):
for id in ids:
message = _("%s has been <b>created</b>.")% (self.case_get_note_msg_prefix(cr, uid, id, context=context))
self.message_append_note(cr, uid, [id], body=message, context=context)
self.message_post(cr, uid, [id], body=message, context=context)
return True
def case_mark_lost_send_note(self, cr, uid, ids, context=None):
message = _("Opportunity has been <b>lost</b>.")
return self.message_append_note(cr, uid, ids, body=message, context=context)
return self.message_post(cr, uid, ids, body=message, context=context)
def case_mark_won_send_note(self, cr, uid, ids, context=None):
message = _("Opportunity has been <b>won</b>.")
return self.message_append_note(cr, uid, ids, body=message, context=context)
return self.message_post(cr, uid, ids, body=message, context=context)
def schedule_phonecall_send_note(self, cr, uid, ids, phonecall_id, action, context=None):
phonecall = self.pool.get('crm.phonecall').browse(cr, uid, [phonecall_id], context=context)[0]
if action == 'log': prefix = 'Logged'
else: prefix = 'Scheduled'
message = _("<b>%s a call</b> for the <em>%s</em>.") % (prefix, phonecall.date)
return self.message_append_note(cr, uid, ids, body=message, context=context)
return self.message_post(cr, uid, ids, body=message, context=context)
def _lead_set_partner_send_note(self, cr, uid, ids, context=None):
for lead in self.browse(cr, uid, ids, context=context):
message = _("%s <b>partner</b> is now set to <em>%s</em>." % (self.case_get_note_msg_prefix(cr, uid, lead, context=context), lead.partner_id.name))
lead.message_append_note(body=message)
lead.message_post(body=message)
return True
def convert_opportunity_send_note(self, cr, uid, lead, context=None):
message = _("Lead has been <b>converted to an opportunity</b>.")
lead.message_append_note(body=message)
lead.message_post(body=message)
return True
crm_lead()

View File

@ -44,7 +44,7 @@ class crm_meeting(osv.Model):
def create_send_note(self, cr, uid, ids, context=None):
if context is None:
context = {}
# update context: if come from phonecall, default state values can make the message_append_note crash
# update context: if come from phonecall, default state values can make the message_post crash
context.pop('default_state', False)
for meeting in self.browse(cr, uid, ids, context=context):
# in the message, transpose meeting.date to the timezone of the current user
@ -53,14 +53,14 @@ class crm_meeting(osv.Model):
if meeting.opportunity_id: # meeting can be create from phonecalls or opportunities, therefore checking for the parent
lead = meeting.opportunity_id
message = _("Meeting linked to the opportunity <em>%s</em> has been <b>created</b> and <b>scheduled</b> on <em>%s</em>.") % (lead.name, meeting_date_tz)
lead.message_append_note(_('System Notification'), message)
lead.message_post(_('System Notification'), message)
elif meeting.phonecall_id:
phonecall = meeting.phonecall_id
message = _("Meeting linked to the phonecall <em>%s</em> has been <b>created</b> and <b>scheduled</b> on <em>%s</em>.") % (phonecall.name, meeting_date_tz)
phonecall.message_append_note(body=message)
phonecall.message_post(body=message)
else:
message = _("A meeting has been <b>scheduled</b> on <em>%s</em>.") % (meeting_date_tz)
meeting.message_append_note(body=message)
meeting.message_post(body=message)
return True
class calendar_attendee(osv.osv):

View File

@ -266,7 +266,7 @@ class crm_phonecall(base_state, osv.osv):
def case_reset_send_note(self, cr, uid, ids, context=None):
message = _('Phonecall has been <b>reset and set as open</b>.')
return self.message_append_note(cr, uid, ids, body=message, context=context)
return self.message_post(cr, uid, ids, body=message, context=context)
def case_open_send_note(self, cr, uid, ids, context=None):
lead_obj = self.pool.get('crm.lead')
@ -280,11 +280,11 @@ class crm_phonecall(base_state, osv.osv):
message = _("Phonecall linked to the opportunity <em>%s</em> has been <b>created</b> and <b>scheduled</b> on <em>%s</em>.") % (lead.name, phonecall_date_str)
else:
message = _("Phonecall has been <b>created and opened</b>.")
phonecall.message_append_note(body=message)
phonecall.message_post(body=message)
return True
def _call_set_partner_send_note(self, cr, uid, ids, context=None):
return self.message_append_note(cr, uid, ids, body=_("Partner has been <b>created</b>."), context=context)
return self.message_post(cr, uid, ids, body=_("Partner has been <b>created</b>."), context=context)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -55,7 +55,7 @@
After communicated with customer, I put some notes with contract details.
-
!python {model: crm.lead}: |
self.message_append_note(cr, uid, [ref('crm_case_4')], subject='Test note', body='ces détails envoyés par le client sur le FAX pour la qualité')
self.message_post(cr, uid, [ref('crm_case_4')], subject='Test note', body='ces détails envoyés par le client sur le FAX pour la qualité')
-
I win this opportunity
-

View File

@ -238,16 +238,16 @@ class crm_claim(base_stage, osv.osv):
def create_send_note(self, cr, uid, ids, context=None):
msg = _('Claim has been <b>created</b>.')
return self.message_append_note(cr, uid, ids, body=msg, context=context)
return self.message_post(cr, uid, ids, body=msg, context=context)
def case_refuse_send_note(self, cr, uid, ids, context=None):
msg = _('Claim has been <b>refused</b>.')
return self.message_append_note(cr, uid, ids, body=msg, context=context)
return self.message_post(cr, uid, ids, body=msg, context=context)
def stage_set_send_note(self, cr, uid, ids, stage_id, context=None):
""" Override of the (void) default notification method. """
stage_name = self.pool.get('crm.claim.stage').name_get(cr, uid, [stage_id], context=context)[0][1]
return self.message_append_note(cr, uid, ids, body= _("Stage changed to <b>%s</b>.") % (stage_name), context=context)
return self.message_post(cr, uid, ids, body= _("Stage changed to <b>%s</b>.") % (stage_name), context=context)
class res_partner(osv.osv):

View File

@ -148,7 +148,7 @@ class crm_helpdesk(base_state, osv.osv):
def create_send_note(self, cr, uid, ids, context=None):
msg = _('Case has been <b>created</b>.')
self.message_append_note(cr, uid, ids, body=msg, context=context)
self.message_post(cr, uid, ids, body=msg, context=context)
return True

View File

@ -268,27 +268,27 @@ class event_event(osv.osv):
def create_send_note(self, cr, uid, ids, context=None):
message = _("Event has been <b>created</b>.")
self.message_append_note(cr, uid, ids, body=message, context=context)
self.message_post(cr, uid, ids, body=message, context=context)
return True
def button_cancel_send_note(self, cr, uid, ids, context=None):
message = _("Event has been <b>cancelled</b>.")
self.message_append_note(cr, uid, ids, body=message, context=context)
self.message_post(cr, uid, ids, body=message, context=context)
return True
def button_draft_send_note(self, cr, uid, ids, context=None):
message = _("Event has been set to <b>draft</b>.")
self.message_append_note(cr, uid, ids, body=message, context=context)
self.message_post(cr, uid, ids, body=message, context=context)
return True
def button_done_send_note(self, cr, uid, ids, context=None):
message = _("Event has been <b>done</b>.")
self.message_append_note(cr, uid, ids, body=message, context=context)
self.message_post(cr, uid, ids, body=message, context=context)
return True
def button_confirm_send_note(self, cr, uid, ids, context=None):
message = _("Event has been <b>confirmed</b>.")
self.message_append_note(cr, uid, ids, body=message, context=context)
self.message_post(cr, uid, ids, body=message, context=context)
return True
event_event()
@ -334,7 +334,7 @@ class event_registration(osv.osv):
return self.write(cr, uid, ids, {'state': 'draft'}, context=context)
def confirm_registration(self, cr, uid, ids, context=None):
self.message_append_note(cr, uid, ids, body=_('State set to open'))
self.message_post(cr, uid, ids, body=_('State set to open'))
return self.write(cr, uid, ids, {'state': 'open'}, context=context)
def create(self, cr, uid, vals, context=None):
@ -364,13 +364,13 @@ class event_registration(osv.osv):
if today >= registration.event_id.date_begin:
values = {'state': 'done', 'date_closed': today}
self.write(cr, uid, ids, values)
self.message_append_note(cr, uid, ids, body=_('State set to Done'))
self.message_post(cr, uid, ids, body=_('State set to Done'))
else:
raise osv.except_osv(_('Error!'),_("You must wait for the starting day of the event to do this action.") )
return True
def button_reg_cancel(self, cr, uid, ids, context=None, *args):
self.message_append_note(cr, uid, ids,body = _('State set to Cancel'))
self.message_post(cr, uid, ids,body = _('State set to Cancel'))
return self.write(cr, uid, ids, {'state': 'cancel'})
def mail_user(self, cr, uid, ids, context=None):
@ -440,12 +440,12 @@ class event_registration(osv.osv):
def create_send_note(self, cr, uid, ids, context=None):
message = _("Registration has been <b>created</b>.")
self.message_append_note(cr, uid, ids, body=message, context=context)
self.message_post(cr, uid, ids, body=message, context=context)
return True
def do_draft_send_note(self, cr, uid, ids, context=None):
message = _("Registration has been set as <b>draft</b>.")
self.message_append_note(cr, uid, ids, body=message, context=context)
self.message_post(cr, uid, ids, body=message, context=context)
return True
event_registration()

View File

@ -88,5 +88,5 @@ class sale_order_line(osv.osv):
}
registration_id = registration_obj.create(cr, uid, dic, context=context)
message = _("The registration %s has been created from the Sale Order %s.") % (registration_id, order_line.order_id.name)
registration_obj.message_append_note(cr, uid, [registration_id], body=message, 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)

View File

@ -212,7 +212,7 @@ class hr_employee(osv.osv):
try:
(model, mail_group_id) = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'mail', 'group_all_employees')
employee = self.browse(cr, uid, employee_id, context=context)
self.pool.get('mail.group').message_append_note(cr, uid, [mail_group_id], body='Welcome to %s! Please help him make its first steps in OpenERP!' % (employee.name), context=context)
self.pool.get('mail.group').message_post(cr, uid, [mail_group_id], body='Welcome to %s! Please help him make its first steps in OpenERP!' % (employee.name), context=context)
except:
pass # group deleted: do not push a message
return employee_id

View File

@ -366,39 +366,38 @@ class hr_holidays(osv.osv):
def create_notificate(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
self.message_append_note(cr, uid, ids, _('System notification'),
self.message_post(cr, uid, ids,
_("The %s request has been <b>created</b> and is waiting confirmation.")
% ('leave' if obj.type == 'remove' else 'allocation',), type='notification', context=context)
% ('leave' if obj.type == 'remove' else 'allocation',), context=context)
return True
def holidays_confirm_notificate(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids):
self.message_append_note(cr, uid, [obj.id], _('System notification'),
_("The %s request has been <b>confirmed</b> and is waiting for validation by the manager.")
% ('leave' if obj.type == 'remove' else 'allocation',), type='notification')
self.message_post(cr, uid, [obj.id], _("The %s request has been <b>confirmed</b> and is waiting for validation by the manager.")
% ('leave' if obj.type == 'remove' else 'allocation',))
def holidays_validate_notificate(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids):
if obj.holiday_status_id.double_validation:
self.message_append_note(cr, uid, [obj.id], _('System notification'),
self.message_post(cr, uid, [obj.id],
_("The %s request has been <b>approved</b>. A second validation is necessary and is now pending.")
% ('leave' if obj.type == 'remove' else 'allocation',), type='notification', context=context)
% ('leave' if obj.type == 'remove' else 'allocation',), context=context)
else:
self.message_append_note(cr, uid, [obj.id], _('System notification'),
self.message_post(cr, uid, [obj.id],
_("The %s request has been <b>approved</b>. The validation process is now over.")
% ('leave' if obj.type == 'remove' else 'allocation',), type='notification', context=context)
% ('leave' if obj.type == 'remove' else 'allocation',), context=context)
def holidays_valid2_notificate(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids):
self.message_append_note(cr, uid, [obj.id], _('System notification'),
self.message_post(cr, uid, [obj.id],
_("The %s request has been <b>double validated</b>. The validation process is now over.")
% ('leave' if obj.type == 'remove' else 'allocation',), type='notification', context=context)
% ('leave' if obj.type == 'remove' else 'allocation',), context=context)
def holidays_refuse_notificate(self, cr, uid, ids, approval, context=None):
for obj in self.browse(cr, uid, ids):
self.message_append_note(cr, uid, [obj.id], _('System notification'),
self.message_post(cr, uid, [obj.id],
_("The %s request has been <b>refused</b>. The validation process is now over.")
% ('leave' if obj.type == 'remove' else 'allocation',), type='notification', context=context)
% ('leave' if obj.type == 'remove' else 'allocation',), context=context)
hr_holidays()

View File

@ -464,14 +464,14 @@ class hr_applicant(base_stage, osv.Model):
""" Override of the (void) default notification method. """
if not stage_id: return True
stage_name = self.pool.get('hr.recruitment.stage').name_get(cr, uid, [stage_id], context=context)[0][1]
return self.message_append_note(cr, uid, ids, body= _("Stage changed to <b>%s</b>.") % (stage_name), context=context)
return self.message_post(cr, uid, ids, body= _("Stage changed to <b>%s</b>.") % (stage_name), context=context)
def case_get_note_msg_prefix(self, cr, uid, id, context=None):
return 'Applicant'
def case_open_send_note(self, cr, uid, ids, context=None):
message = _("Applicant has been set <b>in progress</b>.")
return self.message_append_note(cr, uid, ids, body=message, context=context)
return self.message_post(cr, uid, ids, body=message, context=context)
def case_close_send_note(self, cr, uid, ids, context=None):
if context is None:
@ -479,23 +479,23 @@ class hr_applicant(base_stage, osv.Model):
for applicant in self.browse(cr, uid, ids, context=context):
if applicant.emp_id:
message = _("Applicant has been <b>hired</b> and created as an employee.")
self.message_append_note(cr, uid, [applicant.id], body=message, context=context)
self.message_post(cr, uid, [applicant.id], body=message, context=context)
else:
message = _("Applicant has been <b>hired</b>.")
self.message_append_note(cr, uid, [applicant.id], body=message, context=context)
self.message_post(cr, uid, [applicant.id], body=message, context=context)
return True
def case_cancel_send_note(self, cr, uid, ids, context=None):
msg = 'Applicant <b>refused</b>.'
return self.message_append_note(cr, uid, ids, body=msg, context=context)
return self.message_post(cr, uid, ids, body=msg, context=context)
def case_reset_send_note(self, cr, uid, ids, context=None):
message =_("Applicant has been set as <b>new</b>.")
return self.message_append_note(cr, uid, ids, body=message, context=context)
return self.message_post(cr, uid, ids, body=message, context=context)
def create_send_note(self, cr, uid, ids, context=None):
message = _("Applicant has been <b>created</b>.")
return self.message_append_note(cr, uid, ids, body=message, context=context)
return self.message_post(cr, uid, ids, body=message, context=context)
class hr_job(osv.osv):

View File

@ -95,25 +95,25 @@ class account_analytic_account(osv.osv):
def set_close(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state':'close'}, context=context)
message = _("Contract has been <b>closed</b>.")
self.message_append_note(cr, uid, ids, body=message, context=context)
self.message_post(cr, uid, ids, body=message, context=context)
return True
def set_cancel(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state':'cancelled'}, context=context)
message = _("Contract has been <b>cancelled</b>.")
self.message_append_note(cr, uid, ids, body=message, context=context)
self.message_post(cr, uid, ids, body=message, context=context)
return True
def set_open(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state':'open'}, context=context)
message = _("Contract has been <b>opened</b>.")
self.message_append_note(cr, uid, ids, body=message, context=context)
self.message_post(cr, uid, ids, body=message, context=context)
return True
def set_pending(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state':'pending'}, context=context)
message = _("Contract has been set as <b>pending</b>.")
self.message_append_note(cr, uid, ids, body=message, context=context)
self.message_post(cr, uid, ids, body=message, context=context)
return True
account_analytic_account()

View File

@ -67,21 +67,21 @@ class idea_idea(osv.osv):
def idea_cancel(self, cr, uid, ids, context={}):
self.write(cr, uid, ids, { 'state': 'cancel' })
self.message_append_note(cr, uid, ids, body=_('Idea canceled.'), context=context)
self.message_post(cr, uid, ids, body=_('Idea canceled.'), context=context)
return True
def idea_open(self, cr, uid, ids, context={}):
self.write(cr, uid, ids, { 'state': 'open'})
self.message_append_note(cr, uid, ids, body=_('Idea accepted.'), context=context)
self.message_post(cr, uid, ids, body=_('Idea accepted.'), context=context)
return True
def idea_close(self, cr, uid, ids, context={}):
self.message_append_note(cr, uid, ids, body=_('Idea done.'), context=context)
self.message_post(cr, uid, ids, body=_('Idea done.'), context=context)
self.write(cr, uid, ids, { 'state': 'close' })
return True
def idea_draft(self, cr, uid, ids, context={}):
self.message_append_note(cr, uid, ids, body=_('Idea reset to draft.'), context=context)
self.message_post(cr, uid, ids, body=_('Idea reset to draft.'), context=context)
self.write(cr, uid, ids, { 'state': 'draft' })
return True
idea_idea()

View File

@ -57,7 +57,7 @@ Use the thread viewer widget inside your form view by using the mail_thread widg
Send notifications
+++++++++++++++++++
When sending a notification is required in your workflow or business logic, use the ``message_append_note`` method. This method is a shortcut to the ``message_append`` method that takes all ``mail.message`` fields as arguments. This latter method calls ``message_create`` that
When sending a notification is required in your workflow or business logic, use the ``message_post`` method. This method is a shortcut to the ``message_append`` method that takes all ``mail.message`` fields as arguments. This latter method calls ``message_create`` that
- creates the message
- parses the body to find users you want to push the message to (finding and parsing ``@login`` in the message body)
@ -74,7 +74,7 @@ You should therefore not worry about subscriptions or anything else than sending
return res
def do_something_send_note(self, cr, uid, ids, context=None):
self.message_append_note(cr, uid, ids, _('My subject'),
self.message_post(cr, uid, ids, _('My subject'),
_("has received a <b>notification</b> and is happy for it."), context=context)
Notifications guidelines

View File

@ -154,197 +154,11 @@ class mail_thread(osv.Model):
# mail.message wrappers and tools
#------------------------------------------------------
# FP Note: should we support attachment ? Also, this method must be on
# the mail.message object, not on the thread.
def message_create(self, cr, uid, thread_id, vals, context=None):
""" OpenChatter: wrapper of mail.message create method
- creates the mail.message
- automatically subscribe the message writer
- push the message to followers
"""
context = context or {}
message_obj = self.pool.get('mail.message')
vals['model'] = self._name
vals['res_id'] = thread_id
msg_id = message_obj.create(cr, uid, vals, context=context)
return msg_id
def _needaction_domain_get(self, cr, uid, context={}):
if self._needaction:
return [('message_unread','=',True)]
return []
#------------------------------------------------------
# Generic message api
#------------------------------------------------------
# I propose to remove this. Everyone should use message_create instead.
def message_append(self, cr, uid, threads, subject, body_text=None, body_html=None,
type='email', email_date=None, parent_id=False,
content_subtype='plain', state=None,
partner_ids=None, email_from=False, email_to=False,
email_cc=None, reply_to=None,
headers=None, message_id=False, references=None,
attachments=None, context=None):
""" Creates a new mail.message through message_create. The new message
is attached to the current mail.thread, containing all the details
passed as parameters. All attachments will be attached to the
thread record as well as to the actual message.
This method calls message_create that will handle management of
subscription and notifications, and effectively create the message.
If ``email_from`` is not set or ``type`` not set as 'email',
a note message is created (comment or system notification),
without the usual envelope attributes (sender, recipients, etc.).
:param threads: list of thread ids, or list of browse_records
representing threads to which a new message should be attached
:param subject: subject of the message, or description of the event;
this is totally optional as subjects are not important except
for specific messages (blog post, job offers) or for emails
:param body_text: plaintext contents of the mail or log message
:param body_html: html contents of the mail or log message
:param type: type of message: 'email', 'comment', 'notification';
email by default
:param email_date: email date string if different from now, in
server timezone
:param parent_id: id of the parent message (threaded messaging model)
:param content_subtype: optional content_subtype of message: 'plain'
or 'html', corresponding to the main body contents (body_text or
body_html).
:param state: state of message
:param partner_ids: destination partners of the message, in addition
to the now fully optional email_to; this method is supposed to
received a list of ids is not None. The specific many2many
instruction will be generated by this method.
:param email_from: Email From / Sender address if any
:param email_to: Email-To / Recipient address
:param email_cc: Comma-Separated list of Carbon Copy Emails To
addresses if any
:param reply_to: reply_to header
:param headers: mail headers to store
:param message_id: optional email identifier
:param references: optional email references
:param dict attachments: map of attachment filenames to binary
contents, if any.
:param dict context: if a ``thread_model`` value is present in the
context, its value will be used to determine the model of the
thread to update (instead of the current model).
"""
if context is None:
context = {}
if attachments is None:
attachments = {}
if email_date:
edate = parsedate(email_date)
if edate is not None:
email_date = time.strftime('%Y-%m-%d %H:%M:%S', edate)
if all(isinstance(thread_id, (int, long)) for thread_id in threads):
model = context.get('thread_model') or self._name
model_pool = self.pool.get(model)
threads = model_pool.browse(cr, uid, threads, context=context)
ir_attachment = self.pool.get('ir.attachment')
new_msg_ids = []
for thread in threads:
to_attach = []
for attachment in attachments:
fname, fcontent = attachment
if isinstance(fcontent, unicode):
fcontent = fcontent.encode('utf-8')
data_attach = {
'name': fname,
'datas': base64.b64encode(str(fcontent)),
'datas_fname': fname,
'description': _('Mail attachment'),
}
to_attach.append(ir_attachment.create(cr, uid, data_attach, context=context))
# find related partner: partner_id column in thread object, or self is res.partner model
partner_id = ('partner_id' in thread._columns.keys()) and (thread.partner_id and thread.partner_id.id or False) or False
if not partner_id and thread._name == 'res.partner':
partner_id = thread.id
# destination partners
if partner_ids is None:
partner_ids = []
mail_partner_ids = [(6, 0, partner_ids)]
data = {
'subject': subject,
'body_text': body_text or thread._model._columns.get('description') and thread.description or '',
'body_html': body_html or '',
'parent_id': parent_id,
'date': email_date or fields.datetime.now(),
'type': type,
'content_subtype': content_subtype,
'state': state,
'message_id': message_id,
'partner_ids': mail_partner_ids,
'attachment_ids': [(6, 0, to_attach)],
'user_id': uid,
'model' : thread._name,
'res_id': thread.id,
'partner_id': partner_id,
}
if email_from or type == 'email':
for param in (email_to, email_cc):
if isinstance(param, list):
param = ", ".join(param)
data.update({
'email_to': email_to,
'email_from': email_from or \
thread._model._columns.get('user_id') and thread.user_id and thread.user_id.user_email,
'email_cc': email_cc,
'references': references,
'headers': headers,
'reply_to': reply_to,
})
new_msg_ids.append(self.message_create(cr, uid, thread.id, data, context=context))
return new_msg_ids
# to be removed completly
def message_append_dict(self, cr, uid, ids, msg_dict, context=None):
"""Creates a new mail.message attached to the given threads (``ids``),
with the contents of ``msg_dict``, by calling ``message_append``
with the mail details. All attachments in msg_dict will be
attached to the object record as well as to the actual
mail message.
:param dict msg_dict: a map containing the email details and
attachments. See ``message_process()`` and
``mail.message.parse()`` for details on
the dict structure.
:param dict context: if a ``thread_model`` value is present
in the context, its value will be used
to determine the model of the thread to
update (instead of the current model).
"""
return self.message_append(cr, uid, ids,
subject = msg_dict.get('subject'),
body_text = msg_dict.get('body_text'),
body_html= msg_dict.get('body_html'),
parent_id = msg_dict.get('parent_id', False),
type = msg_dict.get('type', 'email'),
content_subtype = msg_dict.get('content_subtype'),
state = msg_dict.get('state'),
partner_ids = msg_dict.get('partner_ids'),
email_from = msg_dict.get('from', msg_dict.get('email_from')),
email_to = msg_dict.get('to', msg_dict.get('email_to')),
email_cc = msg_dict.get('cc', msg_dict.get('email_cc')),
reply_to = msg_dict.get('reply', msg_dict.get('reply_to')),
email_date = msg_dict.get('date'),
message_id = msg_dict.get('message-id', msg_dict.get('message_id')),
references = msg_dict.get('references')\
or msg_dict.get('in-reply-to'),
attachments = msg_dict.get('attachments'),
headers = msg_dict.get('headers'),
context = context)
#------------------------------------------------------
# Message loading
#------------------------------------------------------
@ -665,7 +479,7 @@ class mail_thread(osv.Model):
model_pool.message_update(cr, user_id, [thread_id], msg, context=context)
else:
thread_id = model_pool.message_new(cr, user_id, msg, custom_values, context=context)
self.message_post(cr, uid, thread_id, context=context, **msg)
return True
def message_new(self, cr, uid, msg_dict, custom_values=None, context=None):
@ -704,7 +518,6 @@ class mail_thread(osv.Model):
if custom_values and isinstance(custom_values, dict):
data.update(custom_values)
res_id = model_pool.create(cr, uid, data, context=context)
self.message_append_dict(cr, uid, [res_id], msg_dict, context=context)
return res_id
def message_update(self, cr, uid, ids, msg_dict, update_vals=None, context=None):
@ -723,7 +536,7 @@ class mail_thread(osv.Model):
"""
if update_vals:
self.write(cr, uid, ids, update_vals, context=context)
return self.message_append_dict(cr, uid, ids, msg_dict, context=context)
return True
def message_thread_followers(self, cr, uid, ids, context=None):
""" Returns a list of email addresses of the people following
@ -834,13 +647,7 @@ class mail_thread(osv.Model):
if save_original:
msg_original = message.as_string() if isinstance(message, Message) \
else message
attachments.append((0, 0, {
'name':'email.eml',
'datas': base64.b64encode(msg_original),
'datas_fname': 'email.eml',
'res_model': 'mail.message',
'description': _('original email'),
}))
attachments.append(('email.eml', msg_original))
if not message_id:
# Very unusual situation, be we should be fault-tolerant here
@ -902,27 +709,14 @@ class mail_thread(osv.Model):
if 'In-Reply-To' in msg_fields:
pass
#msg['headers'] = {}
#msg['content_subtype'] = 'plain'
#for item in msg_txt.items():
# if item[0].startswith('X-'):
# msg['headers'].update({item[0]: item[1]})
if not msg_txt.is_multipart() or 'text/plain' in msg.get('content-type', ''):
encoding = msg_txt.get_content_charset()
body = msg_txt.get_payload(decode=True)
if 'text/html' in msg.get('content-type', ''):
msg['body'] = body
# msg['content_subtype'] = 'html'
# if body:
# body = tools.html2plaintext(body)
# msg['body_text'] = tools.ustr(body, encoding)
if msg_txt.is_multipart() or 'multipart/alternative' in msg.get('content-type', ''):
body = ""
if 'multipart/alternative' in msg.get('content-type', ''):
msg['content_subtype'] = 'alternative'
else:
msg['content_subtype'] = 'mixed'
for part in msg_txt.walk():
if part.get_content_maintype() == 'multipart':
continue
@ -932,39 +726,17 @@ class mail_thread(osv.Model):
if part.get_content_maintype()=='text':
content = part.get_payload(decode=True)
if filename:
attachments.append((0, 0, {
'name': filename,
'datas': base64.b64encode(msg_original),
'datas_fname': filename,
'res_model': 'mail.message',
'description': _('email attachment'),
}))
attachments.append(( filename, msg_original))
content = tools.ustr(content, encoding)
if part.get_content_subtype() == 'html':
msg['body'] = content
# msg['content_subtype'] = 'html' # html version prevails
# body = tools.ustr(tools.html2plaintext(content))
# body = body.replace('&#13;', '')
elif part.get_content_subtype() == 'plain':
msg['body'] = content
msg['body'] = content
elif part.get_content_maintype() in ('application', 'image'):
if filename:
attachments.append((0, 0, {
'name': filename,
'datas': part.get_payload(decode=True),
'datas_fname': filename,
'res_model': 'mail.message',
'description': _('email attachment'),
}))
attachments.append(( filename, part.get_payload(decode=True)))
else:
res = part.get_payload(decode=True)
msg['body'] += tools.ustr(res, encoding)
msg['attachments'] = attachments
# for backwards compatibility:
# msg['body'] = msg['body_text']
# msg['sub_type'] = msg['content_subtype'] or 'plain'
return msg
#------------------------------------------------------
@ -977,19 +749,38 @@ class mail_thread(osv.Model):
module instead of by the res.log mechanism. Please \
use the mail.thread OpenChatter API instead of the \
now deprecated res.log.")
self.message_append_note(cr, uid, [id], 'res.log', message, context=context)
self.message_post(cr, uid, [id], message, context=context)
def message_post(self, cr, uid, res_id, body,
mtype='notification', attachments=None, context=None, **kwargs):
context = context or {}
attachments = attachments or {}
if type(res_id) in (list, tuple):
res_is = res_id[0]
to_attach = []
for fname, fcontent in attachments:
if isinstance(fcontent, unicode):
fcontent = fcontent.encode('utf-8')
data_attach = {
'name': fname,
'datas': base64.b64encode(str(fcontent)),
'datas_fname': fname,
'description': _('email attachment'),
}
to_attach.append((0,0, data_attach))
value = kwargs
value.update( {
'res_model': self._name,
'res_id': res_id,
'body': body,
'type': mtype,
'attachment_ids': data_attach
})
return self.pool.get('mail.message').create(cr, uid, value, context=context)
def message_append_note(self, cr, uid, ids, subject=None, body=None, parent_id=False,
type='notification', content_subtype='html', context=None):
if content_subtype == 'html':
body_html = body
body_text = body
else:
body_html = body
body_text = body
return self.message_append(cr, uid, ids, subject, body_html, body_text,
type, parent_id=parent_id,
content_subtype=content_subtype, context=context)
#------------------------------------------------------
# Subscription mechanism

View File

@ -108,11 +108,10 @@ class res_users(osv.Model):
def _create_welcome_message(self, cr, uid, user, context=None):
company_name = user.company_id.name if user.company_id else _('the company')
subject = '''%s has joined %s.''' % (user.name, company_name)
body = '''Welcome to OpenERP !'''
body = '''%s has joined %s.''' % (user.name, company_name)
# TODO change 1 into user.id but catch errors
return self.pool.get('res.partner').message_append_note(cr, 1, [user.partner_id.id],
subject=subject, body=body, type='comment', content_subtype='html', context=context)
return self.pool.get('res.partner').message_post(cr, 1, [user.partner_id.id],
body=body, context=context)
def write(self, cr, uid, ids, vals, context=None):
# User alias is sync'ed with login

View File

@ -369,7 +369,7 @@ class mrp_bom(osv.osv):
prod_obj = self.pool.get('product.product')
for obj in self.browse(cr, uid, ids, context=context):
for prod in prod_obj.browse(cr, uid, [obj.product_id], context=context):
self.message_append_note(cr, uid, [obj.id], body=_("Bill of Material has been <b>created</b> for <em>%s</em> product.") % (prod.id.name_template), context=context)
self.message_post(cr, uid, [obj.id], body=_("Bill of Material has been <b>created</b> for <em>%s</em> product.") % (prod.id.name_template), context=context)
return True
mrp_bom()
@ -1047,27 +1047,27 @@ class mrp_production(osv.osv):
# ---------------------------------------------------
def create_send_note(self, cr, uid, ids, context=None):
self.message_append_note(cr, uid, ids, body=_("Manufacturing order has been <b>created</b>."), context=context)
self.message_post(cr, uid, ids, body=_("Manufacturing order has been <b>created</b>."), context=context)
return True
def action_cancel_send_note(self, cr, uid, ids, context=None):
message = _("Manufacturing order has been <b>canceled</b>.")
self.message_append_note(cr, uid, ids, body=message, context=context)
self.message_post(cr, uid, ids, body=message, context=context)
return True
def action_ready_send_note(self, cr, uid, ids, context=None):
message = _("Manufacturing order is <b>ready to produce</b>.")
self.message_append_note(cr, uid, ids, body=message, context=context)
self.message_post(cr, uid, ids, body=message, context=context)
return True
def action_in_production_send_note(self, cr, uid, ids, context=None):
message = _("Manufacturing order is <b>in production</b>.")
self.message_append_note(cr, uid, ids, body=message, context=context)
self.message_post(cr, uid, ids, body=message, context=context)
return True
def action_done_send_note(self, cr, uid, ids, context=None):
message = _("Manufacturing order has been <b>done</b>.")
self.message_append_note(cr, uid, ids, body=message, context=context)
self.message_post(cr, uid, ids, body=message, context=context)
return True
def action_confirm_send_note(self, cr, uid, ids, context=None):
@ -1077,7 +1077,7 @@ class mrp_production(osv.osv):
obj_datetime = fields.DT.datetime.strptime(obj.date_planned, DEFAULT_SERVER_DATETIME_FORMAT)
obj_date_str = fields.datetime.context_timestamp(cr, uid, obj_datetime, context=context).strftime(DATETIME_FORMATS_MAP['%+'] + " (%Z)")
message = _("Manufacturing order has been <b>confirmed</b> and is <b>scheduled</b> for the <em>%s</em>.") % (obj_date_str)
self.message_append_note(cr, uid, [obj.id], body=message, context=context)
self.message_post(cr, uid, [obj.id], body=message, context=context)
return True

View File

@ -43,7 +43,7 @@ class procurement_order(osv.osv):
cr.execute('update procurement_order set message=%s where id=%s', (_('No BoM defined for this product !'), procurement.id))
for (id, name) in self.name_get(cr, uid, procurement.id):
message = _("Procurement '%s' has an exception: 'No BoM defined for this product !'") % name
self.message_append_note(cr, uid, [procurement.id], body=message, context=context)
self.message_post(cr, uid, [procurement.id], body=message, context=context)
return False
return True

View File

@ -224,7 +224,7 @@ class mrp_production_workcenter_line(osv.osv):
for workorder in self.browse(cr, uid, ids):
for prod in prod_obj.browse(cr, uid, [workorder.production_id]):
message = _("Work order has been <b>created</b> for production order <em>%s</em>.") % (prod.id.name)
self.message_append_note(cr, uid, [workorder.id], body=message, context=context)
self.message_post(cr, uid, [workorder.id], body=message, context=context)
return True
def action_start_send_note(self, cr, uid, ids, context=None):
@ -232,7 +232,7 @@ class mrp_production_workcenter_line(osv.osv):
for workorder in self.browse(cr, uid, ids):
for prod in prod_obj.browse(cr, uid, [workorder.production_id]):
message = _("Work order has been <b>started</b> for production order <em>%s</em>.") % (prod.id.name)
self.message_append_note(cr, uid, [workorder.id], body=message, context=context)
self.message_post(cr, uid, [workorder.id], body=message, context=context)
return True
def action_done_send_note(self, cr, uid, ids, context=None):
@ -240,7 +240,7 @@ class mrp_production_workcenter_line(osv.osv):
for workorder in self.browse(cr, uid, ids):
for prod in prod_obj.browse(cr, uid, [workorder.production_id]):
message = _("Work order has been <b>done</b> for production order <em>%s</em>.") % (prod.id.name)
self.message_append_note(cr, uid, [workorder.id], body=message, context=context)
self.message_post(cr, uid, [workorder.id], body=message, context=context)
return True
def action_pending_send_note(self, cr, uid, ids, context=None):
@ -248,7 +248,7 @@ class mrp_production_workcenter_line(osv.osv):
for workorder in self.browse(cr, uid, ids):
for prod in prod_obj.browse(cr, uid, [workorder.production_id]):
message = _("Work order is <b>pending</b> for production order <em>%s</em>.") % (prod.id.name)
self.message_append_note(cr, uid, [workorder.id], body=message, context=context)
self.message_post(cr, uid, [workorder.id], body=message, context=context)
return True
def action_cancel_send_note(self, cr, uid, ids, context=None):
@ -256,7 +256,7 @@ class mrp_production_workcenter_line(osv.osv):
for workorder in self.browse(cr, uid, ids):
for prod in prod_obj.browse(cr, uid, [workorder.production_id]):
message = _("Work order has been <b>cancelled</b> for production order <em>%s</em>.") % (prod.id.name)
self.message_append_note(cr, uid, [workorder.id], body=message, context=context)
self.message_post(cr, uid, [workorder.id], body=message, context=context)
return True
mrp_production_workcenter_line()

View File

@ -571,40 +571,40 @@ class mrp_repair(osv.osv):
def create_send_note(self, cr, uid, ids, context=None):
for repair in self.browse(cr, uid, ids, context):
message = _("Repair Order for <em>%s</em> has been <b>created</b>." % (repair.product_id.name))
self.message_append_note(cr, uid, [repair.id], body=message, context=context)
self.message_post(cr, uid, [repair.id], body=message, context=context)
return True
def set_start_send_note(self, cr, uid, ids, context=None):
for repair in self.browse(cr, uid, ids, context):
message = _("Repair Order for <em>%s</em> has been <b>started</b>." % (repair.product_id.name))
self.message_append_note(cr, uid, [repair.id], body=message, context=context)
self.message_post(cr, uid, [repair.id], body=message, context=context)
return True
def set_toinvoiced_send_note(self, cr, uid, ids, context=None):
for repair in self.browse(cr, uid, ids, context):
message = _("Draft Invoice of %s %s <b>waiting for validation</b>.") % (repair.invoice_id.amount_total, repair.invoice_id.currency_id.symbol)
self.message_append_note(cr, uid, [repair.id], body=message, context=context)
self.message_post(cr, uid, [repair.id], body=message, context=context)
return True
def set_confirm_send_note(self, cr, uid, ids, context=None):
for repair in self.browse(cr, uid, ids, context):
message = _( "Repair Order for <em>%s</em> has been <b>accepted</b>." % (repair.product_id.name))
self.message_append_note(cr, uid, [repair.id], body=message, context=context)
self.message_post(cr, uid, [repair.id], body=message, context=context)
return True
def set_cancel_send_note(self, cr, uid, ids, context=None):
message = _("Repair has been <b>cancelled</b>.")
self.message_append_note(cr, uid, ids, body=message, context=context)
self.message_post(cr, uid, ids, body=message, context=context)
return True
def set_ready_send_note(self, cr, uid, ids, context=None):
message = _("Repair Order is now <b>ready</b> to repair.")
self.message_append_note(cr, uid, ids, body=message, context=context)
self.message_post(cr, uid, ids, body=message, context=context)
return True
def set_done_send_note(self, cr, uid, ids, context=None):
message = _("Repair Order is <b>closed</b>.")
self.message_append_note(cr, uid, ids, body=message, context=context)
self.message_post(cr, uid, ids, body=message, context=context)
return True
mrp_repair()

View File

@ -108,7 +108,7 @@ class plugin_handler(osv.osv_memory):
else:
if model == 'res.partner':
model_obj = self.pool.get('mail.thread')
model_obj.message_append_note(cr, uid, [res_id], body=msg)
model_obj.message_post(cr, uid, [res_id], body=msg)
notify = "Mail succefully pushed"
url = self._make_url(cr, uid, res_id, model)

View File

@ -289,14 +289,14 @@ class procurement_order(osv.osv):
return False
if not procurement.product_id.seller_ids:
message = _('No supplier defined for this product !')
self.message_append_note(cr, uid, [procurement.id], body=message)
self.message_post(cr, uid, [procurement.id], body=message)
cr.execute('update procurement_order set message=%s where id=%s', (message, procurement.id))
return False
partner = procurement.product_id.seller_id #Taken Main Supplier of Product of Procurement.
if not partner:
message = _('No default supplier defined for this product')
self.message_append_note(cr, uid, [procurement.id], body=message)
self.message_post(cr, uid, [procurement.id], body=message)
cr.execute('update procurement_order set message=%s where id=%s', (message, procurement.id))
return False
if user.company_id and user.company_id.partner_id:
@ -306,7 +306,7 @@ class procurement_order(osv.osv):
address_id = partner_obj.address_get(cr, uid, [partner.id], ['delivery'])['delivery']
if not address_id:
message = _('No address defined for the supplier')
self.message_append_note(cr, uid, [procurement.id], body=message)
self.message_post(cr, uid, [procurement.id], body=message)
cr.execute('update procurement_order set message=%s where id=%s', (message, procurement.id))
return False
return True

View File

@ -131,7 +131,7 @@ class procurement_order(osv.osv):
Exceptions:\n""") % (start_date, end_date, report_total, report_except, report_later)
summary += '\n'.join(report)
procurement_obj.message_append_note(cr, uid, ids, body=summary, context=context)
procurement_obj.message_post(cr, uid, ids, body=summary, context=context)
if use_new_cursor:
cr.commit()

View File

@ -565,7 +565,7 @@ class product_product(osv.osv):
return obj_id
def create_send_note(self, cr, uid, ids, context=None):
return self.message_append_note(cr, uid, ids, body=_("Product has been <b>created</b>."), context=context)
return self.message_post(cr, uid, ids, body=_("Product has been <b>created</b>."), context=context)
def unlink(self, cr, uid, ids, context=None):
unlink_ids = []

View File

@ -534,23 +534,23 @@ def Project():
return project_id
def create_send_note(self, cr, uid, ids, context=None):
return self.message_append_note(cr, uid, ids, body=_("Project has been <b>created</b>."), context=context)
return self.message_post(cr, uid, ids, body=_("Project has been <b>created</b>."), context=context)
def set_open_send_note(self, cr, uid, ids, context=None):
message = _("Project has been <b>opened</b>.")
return self.message_append_note(cr, uid, ids, body=message, context=context)
return self.message_post(cr, uid, ids, body=message, context=context)
def set_pending_send_note(self, cr, uid, ids, context=None):
message = _("Project is now <b>pending</b>.")
return self.message_append_note(cr, uid, ids, body=message, context=context)
return self.message_post(cr, uid, ids, body=message, context=context)
def set_cancel_send_note(self, cr, uid, ids, context=None):
message = _("Project has been <b>cancelled</b>.")
return self.message_append_note(cr, uid, ids, body=message, context=context)
return self.message_post(cr, uid, ids, body=message, context=context)
def set_close_send_note(self, cr, uid, ids, context=None):
message = _("Project has been <b>closed</b>.")
return self.message_append_note(cr, uid, ids, body=message, context=context)
return self.message_post(cr, uid, ids, body=message, context=context)
def write(self, cr, uid, ids, vals, context=None):
# if alias_model has been changed, update alias_model_id accordingly
@ -1204,19 +1204,19 @@ class task(base_stage, osv.osv):
def stage_set_send_note(self, cr, uid, ids, stage_id, context=None):
""" Override of the (void) default notification method. """
stage_name = self.pool.get('project.task.type').name_get(cr, uid, [stage_id], context=context)[0][1]
return self.message_append_note(cr, uid, ids, body= _("Stage changed to <b>%s</b>.") % (stage_name), context=context)
return self.message_post(cr, uid, ids, body= _("Stage changed to <b>%s</b>.") % (stage_name), context=context)
def create_send_note(self, cr, uid, ids, context=None):
return self.message_append_note(cr, uid, ids, body=_("Task has been <b>created</b>."), context=context)
return self.message_post(cr, uid, ids, body=_("Task has been <b>created</b>."), context=context)
def case_draft_send_note(self, cr, uid, ids, context=None):
msg = _('Task has been set as <b>draft</b>.')
return self.message_append_note(cr, uid, ids, body=msg, context=context)
return self.message_post(cr, uid, ids, body=msg, context=context)
def do_delegation_send_note(self, cr, uid, ids, context=None):
for task in self.browse(cr, uid, ids, context=context):
msg = _('Task has been <b>delegated</b> to <em>%s</em>.') % (task.user_id.name)
self.message_append_note(cr, uid, [task.id], body=msg, context=context)
self.message_post(cr, uid, [task.id], body=msg, context=context)
return True

View File

@ -501,7 +501,7 @@ class project_issue(base_stage, osv.osv):
def stage_set_send_note(self, cr, uid, ids, stage_id, context=None):
""" Override of the (void) default notification method. """
stage_name = self.pool.get('project.task.type').name_get(cr, uid, [stage_id], context=context)[0][1]
return self.message_append_note(cr, uid, ids, body= _("Stage changed to <b>%s</b>.") % (stage_name), context=context)
return self.message_post(cr, uid, ids, body= _("Stage changed to <b>%s</b>.") % (stage_name), context=context)
def case_get_note_msg_prefix(self, cr, uid, id, context=None):
""" Override of default prefix for notifications. """
@ -509,20 +509,20 @@ class project_issue(base_stage, osv.osv):
def convert_to_task_send_note(self, cr, uid, ids, context=None):
message = _("Project issue has been <b>converted</b> into task.")
return self.message_append_note(cr, uid, ids, body=message, context=context)
return self.message_post(cr, uid, ids, body=message, context=context)
def create_send_note(self, cr, uid, ids, context=None):
message = _("Project issue has been <b>created</b>.")
return self.message_append_note(cr, uid, ids, body=message, context=context)
return self.message_post(cr, uid, ids, body=message, context=context)
def case_escalate_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
if obj.project_id:
message = _("has been <b>escalated</b> to <em>'%s'</em>.") % (obj.project_id.name)
obj.message_append_note(body=message, context=context)
obj.message_post(body=message, context=context)
else:
message = _("has been <b>escalated</b>.")
obj.message_append_note(body=message, context=context)
obj.message_post(body=message, context=context)
return True
project_issue()

View File

@ -735,11 +735,11 @@ class purchase_order(osv.osv):
return [('state','=','draft')]
def create_send_note(self, cr, uid, ids, context=None):
return self.message_append_note(cr, uid, ids, body=_("Request for quotation <b>created</b>."), context=context)
return self.message_post(cr, uid, ids, body=_("Request for quotation <b>created</b>."), context=context)
def confirm_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
self.message_append_note(cr, uid, [obj.id], body=_("Quotation for <em>%s</em> <b>converted</b> to a Purchase Order of %s %s.") % (obj.partner_id.name, obj.amount_total, obj.pricelist_id.currency_id.symbol), context=context)
self.message_post(cr, uid, [obj.id], body=_("Quotation for <em>%s</em> <b>converted</b> to a Purchase Order of %s %s.") % (obj.partner_id.name, obj.amount_total, obj.pricelist_id.currency_id.symbol), context=context)
def shipment_send_note(self, cr, uid, ids, picking_id, context=None):
for order in self.browse(cr, uid, ids, context=context):
@ -748,25 +748,25 @@ class purchase_order(osv.osv):
# convert it to the user TZ and re-render it with %Z to add the timezone
picking_datetime = fields.DT.datetime.strptime(picking.min_date, DEFAULT_SERVER_DATETIME_FORMAT)
picking_date_str = fields.datetime.context_timestamp(cr, uid, picking_datetime, context=context).strftime(DATETIME_FORMATS_MAP['%+'] + " (%Z)")
self.message_append_note(cr, uid, [order.id], body=_("Shipment <em>%s</em> <b>scheduled</b> for %s.") % (picking.name, picking_date_str), context=context)
self.message_post(cr, uid, [order.id], body=_("Shipment <em>%s</em> <b>scheduled</b> for %s.") % (picking.name, picking_date_str), context=context)
def invoice_send_note(self, cr, uid, ids, invoice_id, context=None):
for order in self.browse(cr, uid, ids, context=context):
for invoice in (inv for inv in order.invoice_ids if inv.id == invoice_id):
self.message_append_note(cr, uid, [order.id], body=_("Draft Invoice of %s %s is <b>waiting for validation</b>.") % (invoice.amount_total, invoice.currency_id.symbol), context=context)
self.message_post(cr, uid, [order.id], body=_("Draft Invoice of %s %s is <b>waiting for validation</b>.") % (invoice.amount_total, invoice.currency_id.symbol), context=context)
def shipment_done_send_note(self, cr, uid, ids, context=None):
self.message_append_note(cr, uid, ids, body=_("""Shipment <b>received</b>."""), context=context)
self.message_post(cr, uid, ids, body=_("""Shipment <b>received</b>."""), context=context)
def invoice_done_send_note(self, cr, uid, ids, context=None):
self.message_append_note(cr, uid, ids, body=_("Invoice <b>paid</b>."), context=context)
self.message_post(cr, uid, ids, body=_("Invoice <b>paid</b>."), context=context)
def draft_send_note(self, cr, uid, ids, context=None):
return self.message_append_note(cr, uid, ids, body=_("Purchase Order has been set to <b>draft</b>."), context=context)
return self.message_post(cr, uid, ids, body=_("Purchase Order has been set to <b>draft</b>."), context=context)
def cancel_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
self.message_append_note(cr, uid, [obj.id], body=_("Purchase Order for <em>%s</em> <b>cancelled</b>.") % (obj.partner_id.name), context=context)
self.message_post(cr, uid, [obj.id], body=_("Purchase Order for <em>%s</em> <b>cancelled</b>.") % (obj.partner_id.name), context=context)
purchase_order()

View File

@ -91,16 +91,16 @@ class purchase_requisition(osv.osv):
return True
def in_progress_send_note(self, cr, uid, ids, context=None):
self.message_append_note(cr, uid, ids, body=_("Draft Requisition has been <b>sent to suppliers</b>."), context=context)
self.message_post(cr, uid, ids, body=_("Draft Requisition has been <b>sent to suppliers</b>."), context=context)
def reset_send_note(self, cr, uid, ids, context=None):
self.message_append_note(cr, uid, ids, body=_("Purchase Requisition has been set to <b>draft</b>."), context=context)
self.message_post(cr, uid, ids, body=_("Purchase Requisition has been set to <b>draft</b>."), context=context)
def done_to_send_note(self, cr, uid, ids, context=None):
self.message_append_note(cr, uid, ids, body=_("Purchase Requisition has been <b>done</b>."), context=context)
self.message_post(cr, uid, ids, body=_("Purchase Requisition has been <b>done</b>."), context=context)
def cancel_send_note(self, cr, uid, ids, context=None):
self.message_append_note(cr, uid, ids, body=_("Purchase Requisition has been <b>cancelled</b>."), context=context)
self.message_post(cr, uid, ids, body=_("Purchase Requisition has been <b>cancelled</b>."), context=context)
def _planned_date(self, requisition, delay=0.0):
company = requisition.company_id
@ -184,7 +184,7 @@ class purchase_requisition(osv.osv):
return res
def create_send_note(self, cr, uid, ids, context=None):
return self.message_append_note(cr, uid, ids, body=_("Purchase Requisition has been <b>created</b>."), context=context)
return self.message_post(cr, uid, ids, body=_("Purchase Requisition has been <b>created</b>."), context=context)
def create(self, cr, uid, vals, context=None):
requisition = super(purchase_requisition, self).create(cr, uid, vals, context=context)

View File

@ -1027,15 +1027,15 @@ class sale_order(osv.osv):
def create_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
self.message_append_note(cr, uid, [obj.id], body=_("Quotation for <em>%s</em> has been <b>created</b>.") % (obj.partner_id.name), context=context)
self.message_post(cr, uid, [obj.id], body=_("Quotation for <em>%s</em> has been <b>created</b>.") % (obj.partner_id.name), context=context)
def confirm_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
self.message_append_note(cr, uid, [obj.id], body=_("Quotation for <em>%s</em> <b>converted</b> to Sale Order of %s %s.") % (obj.partner_id.name, obj.amount_total, obj.pricelist_id.currency_id.symbol), context=context)
self.message_post(cr, uid, [obj.id], body=_("Quotation for <em>%s</em> <b>converted</b> to Sale Order of %s %s.") % (obj.partner_id.name, obj.amount_total, obj.pricelist_id.currency_id.symbol), context=context)
def cancel_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
self.message_append_note(cr, uid, [obj.id], body=_("Sale Order for <em>%s</em> <b>cancelled</b>.") % (obj.partner_id.name), context=context)
self.message_post(cr, uid, [obj.id], body=_("Sale Order for <em>%s</em> <b>cancelled</b>.") % (obj.partner_id.name), context=context)
def delivery_send_note(self, cr, uid, ids, picking_id, context=None):
for order in self.browse(cr, uid, ids, context=context):
@ -1044,21 +1044,21 @@ class sale_order(osv.osv):
# convert it to the user TZ and re-render it with %Z to add the timezone
picking_datetime = fields.DT.datetime.strptime(picking.min_date, DEFAULT_SERVER_DATETIME_FORMAT)
picking_date_str = fields.datetime.context_timestamp(cr, uid, picking_datetime, context=context).strftime(DATETIME_FORMATS_MAP['%+'] + " (%Z)")
self.message_append_note(cr, uid, [order.id], body=_("Delivery Order <em>%s</em> <b>scheduled</b> for %s.") % (picking.name, picking_date_str), context=context)
self.message_post(cr, uid, [order.id], body=_("Delivery Order <em>%s</em> <b>scheduled</b> for %s.") % (picking.name, picking_date_str), context=context)
def delivery_end_send_note(self, cr, uid, ids, context=None):
self.message_append_note(cr, uid, ids, body=_("Order <b>delivered</b>."), context=context)
self.message_post(cr, uid, ids, body=_("Order <b>delivered</b>."), context=context)
def invoice_paid_send_note(self, cr, uid, ids, context=None):
self.message_append_note(cr, uid, ids, body=_("Invoice <b>paid</b>."), context=context)
self.message_post(cr, uid, ids, body=_("Invoice <b>paid</b>."), context=context)
def invoice_send_note(self, cr, uid, ids, invoice_id, context=None):
for order in self.browse(cr, uid, ids, context=context):
for invoice in (inv for inv in order.invoice_ids if inv.id == invoice_id):
self.message_append_note(cr, uid, [order.id], body=_("Draft Invoice of %s %s <b>waiting for validation</b>.") % (invoice.amount_total, invoice.currency_id.symbol), context=context)
self.message_post(cr, uid, [order.id], body=_("Draft Invoice of %s %s <b>waiting for validation</b>.") % (invoice.amount_total, invoice.currency_id.symbol), context=context)
def action_cancel_draft_send_note(self, cr, uid, ids, context=None):
return self.message_append_note(cr, uid, ids, body='Sale order has been set in draft.', context=context)
return self.message_post(cr, uid, ids, body='Sale order has been set in draft.', context=context)
sale_order()

View File

@ -106,7 +106,7 @@ class crm_make_sale(osv.osv_memory):
case_obj.write(cr, uid, [case.id], {'ref': 'sale.order,%s' % new_id})
new_ids.append(new_id)
message = _("Opportunity has been <b>converted</b> to the quotation <em>%s</em>.") % (sale_order.name)
case.message_append_note(body=message)
case.message_post(body=message)
if make.close:
case_obj.case_close(cr, uid, data)
if not new_ids:

View File

@ -819,7 +819,7 @@ class share_wizard(osv.TransientModel):
elif tmp_idx == len(wizard_data.result_line_ids)-2:
body += ' and'
body += '.'
return self.pool.get(model_name).message_append_note(cr, uid, [res_id], _('System Notification'), body, context=context)
return self.pool.get(model_name).message_post(cr, uid, [res_id], _('System Notification'), body, context=context)
def send_invite_email(self, cr, uid, wizard_data, context=None):
message_obj = self.pool.get('mail.message')

View File

@ -1379,13 +1379,13 @@ class stock_picking(osv.osv):
def create_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
self.message_append_note(cr, uid, [obj.id], body=_("%s has been <b>created</b>.") % (self._get_document_type(obj.type)), context=context)
self.message_post(cr, uid, [obj.id], body=_("%s has been <b>created</b>.") % (self._get_document_type(obj.type)), context=context)
def scrap_send_note(self, cr, uid, ids, quantity, uom, name, context=None):
return self.message_append_note(cr, uid, ids, body= _("%s %s %s has been <b>moved to</b> scrap.") % (quantity, uom, name), context=context)
return self.message_post(cr, uid, ids, body= _("%s %s %s has been <b>moved to</b> scrap.") % (quantity, uom, name), context=context)
def back_order_send_note(self, cr, uid, ids, back_name, context=None):
return self.message_append_note(cr, uid, ids, body=_("Back order <em>%s</em> has been <b>created</b>.") % (back_name), context=context)
return self.message_post(cr, uid, ids, body=_("Back order <em>%s</em> has been <b>created</b>.") % (back_name), context=context)
def ship_done_send_note(self, cr, uid, ids, context=None):
type_dict = {
@ -1394,11 +1394,11 @@ class stock_picking(osv.osv):
'internal': 'moved',
}
for obj in self.browse(cr, uid, ids, context=context):
self.message_append_note(cr, uid, [obj.id], body=_("Products have been <b>%s</b>.") % (type_dict.get(obj.type, 'move done')), context=context)
self.message_post(cr, uid, [obj.id], body=_("Products have been <b>%s</b>.") % (type_dict.get(obj.type, 'move done')), context=context)
def ship_cancel_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
self.message_append_note(cr, uid, [obj.id], body=_("%s has been <b>cancelled</b>.") % (self._get_document_type(obj.type)), context=context)
self.message_post(cr, uid, [obj.id], body=_("%s has been <b>cancelled</b>.") % (self._get_document_type(obj.type)), context=context)
stock_picking()
@ -2541,7 +2541,7 @@ class stock_move(osv.osv):
product_obj = self.pool.get('product.product')
for new_move in self.browse(cr, uid, res, context=context):
message = _("Product has been consumed with '%s' quantity.") % (new_move.product_qty)
product_obj.message_append_note(cr, uid, [new_move.product_id.id], body=message, context=context)
product_obj.message_post(cr, uid, [new_move.product_id.id], body=message, context=context)
self.action_done(cr, uid, res, context=context)

View File

@ -113,7 +113,7 @@ class stock_change_product_qty(osv.osv_memory):
for data in self.browse(cr, uid, ids, context=context):
location_name = location_obj.browse(cr, uid, data.location_id.id, context=context).name
message = _("<b>Quantity has been changed</b> to <em>%s %s </em> for <em>%s</em> location.") % (data.new_quantity, data.product_id.uom_id.name, location_name)
prod_obj.message_append_note(cr, uid, [data.product_id.id], body=message, context=context)
prod_obj.message_post(cr, uid, [data.product_id.id], body=message, context=context)
stock_change_product_qty()