Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 函数字段,将日期字段显示为文本-OpenERP v7_Python_Xml_Openerp_Openerp 7 - Fatal编程技术网

Python 函数字段,将日期字段显示为文本-OpenERP v7

Python 函数字段,将日期字段显示为文本-OpenERP v7,python,xml,openerp,openerp-7,Python,Xml,Openerp,Openerp 7,到目前为止,我正在尝试获取一个日期字段数据,在OpenERPv7中转换为文本格式 我在stock模块上创建了一个函数,但当我在xml视图中声明此函数时,它返回Undefined标记,并且我不能再按日期对行进行分组 这是我的代码: def _date_(self, cr, uid, ids, fields, arg, context): x={} for record in self.browse(cr, uid, ids): if record.creat

到目前为止,我正在尝试获取一个日期字段数据,在OpenERPv7中转换为文本格式

我在
stock
模块上创建了一个函数,但当我在
xml
视图中声明此函数时,它返回
Undefined
标记,并且我不能再按日期对行进行分组

这是我的代码:

    def _date_(self, cr, uid, ids, fields, arg, context):
    x={}
    for record in self.browse(cr, uid, ids):
        if record.create_date :
            a = date.strptime(record.create_date, "%Y-%m-%d")
            b = a.strftime("%Y-%m-%d")
            x[record.id] = text(b(a))
        return x

    _columns = {
        'create_date': fields.date('Creation Date', readonly=True, select=True),
        'date_': fields.function(_date_, type='text', string='date copy', store=True),
stock\u view.xml上

<filter string="Creation" name="groupby_create_date" icon="terp-go-month" domain="[]" context="{'group_by':'date_'}"
“日期”:fields.function(日期,type='date',string='date copy',store=True)

x[record.id]=文本(b(a))

不转换文本类型中的日期


希望这有帮助

您好,谢谢,但我需要将日期转换为文本,并根据该文本对行进行分组,它应该可以用作原始筛选器,但在文本格式中,它仍然是“未定义的”…我应用了您的更改,但恐怕它不是真正的文本,或者我不知道。。。我需要这个,因为这个模块,这个模块有一个问题,每次我分组的日期或日期时间格式,它抛出一个错误,所以我真的需要转换成文本日期或日期时间。好的,你的答案是正确的,这实际上是一个概念问题,我应该修改原来的模块,或改变概念完全,非常感谢!