我需要時間重新日期字段時,我改變我的師類型錯誤:<在0xaaa7064功能context_today>不是JSON序列化
這裏是我的Python代碼
tea_worker_ids = self.pool.get('bpl.worker').search(cr, uid, [('bpl_division_id', '=', division_id), ('default_work', '=', 'tea')])
for record in self.pool.get('bpl.worker').browse(cr, uid, tea_worker_ids):
tea_list_data.append({'worker_id': record.id, 'worker_emp_no': record.emp_no, 'is_selected':True,'date': (fields.date.context_today)})#
tea_v['selected_tea_workers'] = tea_list_data
這是錯誤
2013-05-13 06:22:28,810 15393 ERROR ABC werkzeug: Error on request:
Traceback (most recent call last):
File "/usr/share/pyshared/werkzeug/serving.py", line 159, in run_wsgi
execute(app)
File "/usr/share/pyshared/werkzeug/serving.py", line 146, in execute
application_iter = app(environ, start_response)
File "/usr/share/pyshared/simplejson/__init__.py", line 286, in dumps
return _default_encoder.encode(obj)
File "/usr/share/pyshared/simplejson/encoder.py", line 226, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/share/pyshared/simplejson/encoder.py", line 296, in iterencode
return _iterencode(o, 0)
File "/usr/share/pyshared/simplejson/encoder.py", line 202, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <function context_today at 0xaaa7064> is not JSON serializable
請幫我解決這問題,
EDITED
當它變爲fields.date.context_today()
然後錯誤出現如下
File "/home/bellvantage/Documents/openerp-7.0/openerp-7/openerp/addons/bpl/bpl.py", line 1059, in on_change_division
workers_list.append({'worker_id': record.id,'start_date': fields.date.context_today()})
TypeError: context_today() takes at least 3 arguments (0 given)
感謝Priyan ..!這次它真的工作。再次感謝你的答案。 – user2323577 2013-05-13 07:33:18
這是一個破解,因爲缺乏i18n支持。 – uprego 2014-08-13 08:24:59