【问题标题】:context_today() is not defined in XML OpenERP 6在 XML OpenERP 6 中没有定义 context_today()
【发布时间】:2015-12-16 08:16:14
【问题描述】:

我正在使用 OpenERP-6.0 和 Ubuntu-12.04。

以下代码在 7.0 中运行良好,但在 6.0 中出现错误

这是我的代码:

<record model="ir.actions.act_window" id="action_sale_graph">
        <field name="name">Sale Order Graph</field>
        <field name="res_model">sale.order</field>
        <field name="view_type">form</field>
        <field name="view_mode">graph,tree</field>
        <field name="domain">[('state', '=', 'In-Process'),('sale_date','&lt;=',time.strftime('%d/%m/%Y')),('sale_date','&gt;=', ((context_today() -  relativedelta(months=2)).strftime('%d/%m/%Y')))]</field>
        <field name="context">{'group_by':['sale_date']}</field>
        <field name="view_id" ref="sale_graph_view"/>
</record>

我面临以下错误:

 File "/home/arbeis/oddo/ydev/oe/openerp/addons/web/controllers/main.py", line 695, in clean_action
 action['domain'] = eval( action['domain'], eval_ctx ) or []
 File "<string>", line 1, in <module>
NameError: name 'context_today' is not defined

【问题讨论】:

    标签: python xml openerp


    【解决方案1】:

    尝试以下操作:

    试试 datetime.date.today()

    (datetime.date.today()  -  relativedelta(months=2))
    

    【讨论】:

    • 我尝试使用 datetime.date.today 工作,但我无法在仪表板上按月分组....在 openerp 7.0 中,我的代码按月分组,但在 openerp 6.0 上使用 datetime.date。今天的数据按日期显示...可以帮助我,谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-01-09
    • 2014-06-26
    • 1970-01-01
    • 2013-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多