[FIX] Event - Allow to specify the timezone from the event and use it in template mail.
bzr revid: jke@openerp.com-20140509121827-3ngkf93jhduobcoa
This commit is contained in:
parent
dee000be14
commit
67fb735b50
|
@ -9,7 +9,7 @@
|
|||
<field name="subject">Your registration at ${object.event_id.name}</field>
|
||||
<field name="body_html"><![CDATA[
|
||||
<p>Hello ${object.name},</p>
|
||||
<p>The event ${object.event_id.name} that you registered for is confirmed and will be held from ${object.event_id.date_begin} to ${object.event_id.date_end}.
|
||||
<p>The event ${object.event_id.name} that you registered for is confirmed and will be held from ${object.event_id.date_begin_located.strftime('%Y-%m-%d %H:%M:%S (%Z)')} to ${object.event_id.date_end_located.strftime('%Y-%m-%d %H:%M:%S (%Z)')}.
|
||||
For any further information please contact our event department.</p>
|
||||
<p>Thank you for your participation!</p>
|
||||
<p>Best regards</p>]]></field>
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import pytz
|
||||
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
|
||||
from datetime import datetime, timedelta
|
||||
from openerp.osv import fields, osv
|
||||
from openerp.tools.translate import _
|
||||
|
@ -150,6 +151,24 @@ class event_event(osv.osv):
|
|||
continue
|
||||
return res
|
||||
|
||||
def _compute_date_tz(self, cr, uid, ids, fld, arg, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
res = {}
|
||||
|
||||
print ids
|
||||
for event in self.browse(cr, uid, ids, context=context):
|
||||
res[event.id] = {}
|
||||
context['tz'] = event.date_tz or 'UTC'
|
||||
if fld == 'date_begin_located':
|
||||
res[event.id] = fields.datetime.context_timestamp(cr, uid, datetime.strptime(event.date_begin, DEFAULT_SERVER_DATETIME_FORMAT), context=context)
|
||||
elif fld == 'date_end_located':
|
||||
res[event.id] = fields.datetime.context_timestamp(cr, uid, datetime.strptime(event.date_end, DEFAULT_SERVER_DATETIME_FORMAT), context=context)
|
||||
return res
|
||||
|
||||
def _tz_get(self, cr, uid, context=None):
|
||||
return [(x, x) for x in pytz.all_timezones]
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Event Name', size=64, required=True, translate=True, readonly=False, states={'done': [('readonly', True)]}),
|
||||
'user_id': fields.many2one('res.users', 'Responsible User', readonly=False, states={'done': [('readonly', True)]}),
|
||||
|
@ -169,8 +188,11 @@ class event_event(osv.osv):
|
|||
store={'event.registration': (_get_events_from_registrations, ['state'], 10),
|
||||
'event.event': (lambda self, cr, uid, ids, c = {}: ids, ['seats_max', 'registration_ids'], 20)}),
|
||||
'registration_ids': fields.one2many('event.registration', 'event_id', 'Registrations', readonly=False, states={'done': [('readonly', True)]}),
|
||||
'date_tz': fields.selection(_tz_get, string='Timezone'),
|
||||
'date_begin': fields.datetime('Start Date', required=True, readonly=True, states={'draft': [('readonly', False)]}),
|
||||
'date_end': fields.datetime('End Date', required=True, readonly=True, states={'draft': [('readonly', False)]}),
|
||||
'date_begin_located': fields.function(_compute_date_tz, string='Start Date Located', type="datetime"),
|
||||
'date_end_located': fields.function(_compute_date_tz, string='End Date Located', type="datetime"),
|
||||
'state': fields.selection([
|
||||
('draft', 'Unconfirmed'),
|
||||
('cancel', 'Cancelled'),
|
||||
|
@ -197,7 +219,8 @@ class event_event(osv.osv):
|
|||
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'event.event', context=c),
|
||||
'user_id': lambda obj, cr, uid, context: uid,
|
||||
'organizer_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, uid, context=c).company_id.partner_id.id,
|
||||
'address_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, uid, context=c).company_id.partner_id.id
|
||||
'address_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, uid, context=c).company_id.partner_id.id,
|
||||
'date_tz': lambda self, cr, uid, ctx: ctx.get('tz', "UTC"),
|
||||
}
|
||||
|
||||
def _check_seats_limit(self, cr, uid, ids, context=None):
|
||||
|
|
|
@ -83,6 +83,7 @@
|
|||
<field name="type" on_change="onchange_event_type(type,context)" />
|
||||
<field name="date_begin" on_change="onchange_start_date(date_begin,date_end)"/>
|
||||
<field name="date_end"/>
|
||||
<field name="date_tz" />
|
||||
</group>
|
||||
</group>
|
||||
<notebook>
|
||||
|
|
Loading…
Reference in New Issue