【问题标题】:How to set date with time in sxw using python for openerp report?如何使用 python 为 openerp 报告在 sxw 中设置日期和时间?
【发布时间】:2014-07-18 19:35:51
【问题描述】:

我在 openerp 生成报告。那就是,我创建了 sxw 并将其转换为 rml,然后将 rml 转换为 pdf。现在工作正常。我的疑问是,当尝试获取日期和时间字段值时,它只获取日期。 pdf 报告中没有时间。

python 中的字段名称:'sample_receipt_date':datetime(....)

在 sxw 中:[[formatLang(o.sample_receipt_date,date=True)]]

转换pdf后:dd/mm/yy

但我想要这种格式为 dd/mm/yy/min/sec 的 pdf。

什么是sxw文档中的python编码?

【问题讨论】:

    标签: date time


    【解决方案1】:

    [[ time.ctime() ]] 应该在 RML 中工作,否则,请查看 https://doc.openerp.com/6.1/vi/developer/05_reports/ 或完整的 RML for Idiots 手册

    【讨论】:

    • 我想从这个字段 'sample_receipt_date':fields.datetime('Sample Recept Date') 中获取日期和时间值。能具体告诉我吗?
    • 此函数以这种格式给出当前时间(Fri May 30 04:06:18 2014 )。我想从我的字段 'sample_receipt_date':fields.datetime('Sample Recept Date') 中获取日期和时间值。我想要这种格式 (05/03/2014 07:11)
    • 试试 strftime() 方法。 tutorialspoint.com/python/time_strftime.htm
    • [[formatLang(o.sample_receipt_date_report)),date=True]] 文档中的这一行(sxw)。我正在转换这个文件 rml.那个时间需要日期。时间还没到。 [[time.strftime(formatLang(o.sample_receipt_date_report)),date=True]] 这不起作用
    • 查看我发给您的 RML for Idiot 手册的第 31 页。它没有理由不工作。使用对象的内容创建一个脚本和一个变量,然后打印该变量的值。
    【解决方案2】:

    试试这个:

    replace (date=True) By (date_time=True)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多