如何在odoo v8中将当前日期分配给日期字段? [英] How to assign current date to a date field in odoo v8?

查看:72
本文介绍了如何在odoo v8中将当前日期分配给日期字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过以下代码将当前日期分配给日期字段"start_date":

I wanted to assign the current date to a date field 'start_date' in the following code:

calendar_obj.create(cr,uid,
             {'name' : rec_res.act_ion,
              'user_id' : rec_res.asgnd_to.id,
              'start_date' : lambda *a:datetime.today().strftime('%m-%d-%Y'),
              'stop_date' : rec_res.due_date,
              'allday' : True,
              'partner_ids' : [(6,0, [rec_res.asgnd_to.partner_id.id])]
             },
context=context)

如何将当前日期值设置或分配给 start_date 字段?

How to set or assign the current date value to the start_date field ?

推荐答案

日期"字段包含today()方法,仅用于以下情况:

The Date field includes a today() method, just for cases like this:

'start_date': fields.Date.today(),

当然,您需要先导入fields:

from openerp import fields

这篇关于如何在odoo v8中将当前日期分配给日期字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆