gpt4 book ai didi

openerp - 我如何在创建表单中有初始默认值

转载 作者:行者123 更新时间:2023-12-04 05:08:15 25 4
gpt4 key购买 nike

我有这个代表 URL 书签的类

from openerp.osv import osv, fields

class jbbookmark_jbbookmark(osv.osv):

_name = "jbbookmark.jbbookmark"
_description = "Bookmark"

def default_get(self, cr, uid, fields, context=None):
res = super(jbbookmark_jbbookmark, self).default_get(cr, uid, fields, context=context)

res.update({'name': 'initial value test'})
res.update({'description': 'initial value test'})
return res

_columns = {
'name': fields.char('URL', required=True, translate=True),
'description': fields.text('Description'),
'title': fields.char('Name', size=20, required=True),
}
_defaults = {
'name':'test URL',
}

我尝试在添加记录时设置表单字段的初始值,但这些字段只是空白。如何让这些值显示在表单 View 中

最佳答案

您应该将值分配给字典中的键而不是更新。

这肯定会起作用。

def default_get(self, cr, uid, fields, context=None):
res = super(jbbookmark_jbbookmark, self).default_get(cr, uid, fields, context=context)
res['name'] = 'initial value test'
res['description'] = 'initial value test'
return res

关于openerp - 我如何在创建表单中有初始默认值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15228171/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com