[FIX] Fixed date formatting in several messages. It now adds the user timezone to add coherence.
bzr revid: tde@openerp.com-20120418123150-dtw13rhrrhqibo1e
This commit is contained in:
parent
48a29b04eb
commit
1aa720a73d
|
@ -22,6 +22,7 @@
|
|||
from base_calendar import base_calendar
|
||||
from crm import crm_base, crm_case
|
||||
from osv import fields, osv
|
||||
import tools
|
||||
from tools.translate import _
|
||||
import logging
|
||||
|
||||
|
@ -99,7 +100,11 @@ class crm_meeting(crm_base, osv.osv):
|
|||
# update context: if come from phonecall, default state values can make the message_append_note crash
|
||||
context.pop('default_state', False)
|
||||
for meeting in self.browse(cr, uid, ids, context=context):
|
||||
message = _("A meeting has been <b>scheduled</b> on <em>%s</em>.") % (meeting.date)
|
||||
# convert datetime field to a datetime, using server format, then
|
||||
# convert it to the user TZ and re-render it with %Z to add the timezone
|
||||
meeting_datetime = fields.DT.datetime.strptime(meeting.date, tools.DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
meeting_date_str = fields.datetime.context_timestamp(cr, uid, meeting_datetime, context=context).strftime(tools.DATETIME_FORMATS_MAP['%+'] + " (%Z)")
|
||||
message = _("A meeting has been <b>scheduled</b> on <em>%s</em>.") % (meeting_date_str)
|
||||
if meeting.opportunity_id: # meeting can be create from phonecalls or opportunities, therefore checking for the parent
|
||||
lead = meeting.opportunity_id
|
||||
parent_message = _("Meeting linked to the opportunity <em>%s</em> has been <b>created</b> and <b>cscheduled</b> on <em>%s</em>.") % (lead.name, meeting.date)
|
||||
|
|
|
@ -323,7 +323,11 @@ class crm_phonecall(crm_base, osv.osv):
|
|||
phonecall.message_subscribe([phonecall.user_id.id], context=context)
|
||||
if phonecall.opportunity_id:
|
||||
lead = phonecall.opportunity_id
|
||||
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)
|
||||
# convert datetime field to a datetime, using server format, then
|
||||
# convert it to the user TZ and re-render it with %Z to add the timezone
|
||||
phonecall_datetime = fields.DT.datetime.strptime(phonecall.date, tools.DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
phonecall_date_str = fields.datetime.context_timestamp(cr, uid, phonecall_datetime, context=context).strftime(tools.DATETIME_FORMATS_MAP['%+'] + " (%Z)")
|
||||
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)
|
||||
|
|
|
@ -1073,7 +1073,11 @@ class mrp_production(osv.osv):
|
|||
|
||||
def action_confirm_send_note(self, cr, uid, ids, context=None):
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
message = _("Manufacturing order has been <b>confirmed</b> and is <b>scheduled</b> for the <em>%s</em>.") % (obj.date_planned)
|
||||
# convert datetime field to a datetime, using server format, then
|
||||
# convert it to the user TZ and re-render it with %Z to add the timezone
|
||||
obj_datetime = fields.DT.datetime.strptime(obj.date_planned, tools.DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
obj_date_str = fields.datetime.context_timestamp(cr, uid, obj_datetime, context=context).strftime(tools.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)
|
||||
return True
|
||||
|
||||
|
|
|
@ -672,8 +672,11 @@ class purchase_order(osv.osv):
|
|||
def shipment_send_note(self, cr, uid, ids, picking_id, context=None):
|
||||
for order in self.browse(cr, uid, ids, context=context):
|
||||
for picking in (pck for pck in order.picking_ids if pck.id == picking_id):
|
||||
pck_date = datetime.strptime(picking.min_date, '%Y-%m-%d %H:%M:%S').strftime('%m/%d/%Y')
|
||||
self.message_append_note(cr, uid, [order.id], body=_("Shipment <em>%s</em> <b>scheduled</b> for %s.") % (picking.name, pck_date), context=context)
|
||||
# convert datetime field to a datetime, using server format, then
|
||||
# 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, tools.DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
picking_date_str = fields.datetime.context_timestamp(cr, uid, meeting_datetime, context=context).strftime(tools.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)
|
||||
|
||||
def invoice_send_note(self, cr, uid, ids, invoice_id, context=None):
|
||||
for order in self.browse(cr, uid, ids, context=context):
|
||||
|
|
|
@ -940,8 +940,11 @@ class sale_order(osv.osv):
|
|||
def delivery_send_note(self, cr, uid, ids, picking_id, context=None):
|
||||
for order in self.browse(cr, uid, ids, context=context):
|
||||
for picking in (pck for pck in order.picking_ids if pck.id == picking_id):
|
||||
pck_date = datetime.strptime(picking.min_date, '%Y-%m-%d %H:%M:%S').strftime('%m/%d/%Y')
|
||||
self.message_append_note(cr, uid, [order.id], body=_("Delivery Order <em>%s</em> <b>scheduled</b> for %s.") % (picking.name, pck_date), context=context)
|
||||
# convert datetime field to a datetime, using server format, then
|
||||
# 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, tools.DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
picking_date_str = fields.datetime.context_timestamp(cr, uid, meeting_datetime, context=context).strftime(tools.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)
|
||||
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue