コード例 #1
0
ファイル: pos.py プロジェクト: mohshedid/odoo10_plus
def ctx_tz(record, field):
    res_lang = None
    ctx = record._context
    tz_name = pytz.timezone(ctx.get('tz') or record.env.user.tz)
    timestamp = Datetime.from_string(record[field])
    if ctx.get('lang'):
        res_lang = record.env['res.lang'].search([('code', '=', ctx['lang'])], limit=1)
    if res_lang:
        timestamp = pytz.utc.localize(timestamp, is_dst=False)
        return datetime.strftime(timestamp.astimezone(tz_name), res_lang.date_format + ' ' + res_lang.time_format)
    return Datetime.context_timestamp(record, timestamp)
コード例 #2
0
 def action_delayed_line(self):
     raise UserError(_(
         'This line is scheduled for: %s. \n However it is now planned to '
         'arrive late.') % Dt.to_string(Dt.context_timestamp(
             self, Dt.from_string(self.date_planned))))