相关类型字段未显示值 [英] Related type field not showing value
问题描述
我有一个相关的字段"region_id",该字段从像这样的另一个类中的many2one字段中获取值
I have a related field 'region_id' that get the value from a many2one field in another class like this
class activity_summary(osv.osv):
_name = "budget.activity_summary"
_rec_name = "activity_summarycode"
_columns = {
'activity_summarycode' : fields.many2one("budget.activity_year", "Activity Summary Code", ondelete= "no action", required=True ),
'region_id' : fields.related("activity_summarycode", "mgmt_code", type="char", string = "Management Code", size=64, store = True),
}
但是它没有给出正确的值,而是在我保存时给了我这个:browse_record(budget.org_table,12).为什么不返回值?我该如何解决?
But it's not giving the right value, instead when i save, it gives me this: browse_record(budget.org_table, 12). Why is it not returning the value? and how may i fix it?
活动年课程
class activity_year(osv.osv):
_name = "budget.activity_year"
_description = "Activity year"
_rec_name = "activity_yearcode"
_columns = {
'activity_yearcode' : fields.char("Activity Code", size=64, required=True),
'activity_name' : fields.char("Activity Name", size=128),
'mgmt_code' : fields.many2one("budget.org_table","Management Unit Code"),
}
_sql_constraints = [
('activity_yearcode_unique', 'UNIQUE(activity_yearcode)', 'Each activity code is unique.'),
]
budget.org-table类
budget.org-table class
class org_table(osv.osv):
_name = "budget.org_table"
_rec_name = "org_code"
_columns = {
'org_code' : fields.char("Code", size=64),
'org_name' : fields.char("Name"),
}
_sql_constraints = [
('org_code_unique', 'UNIQUE(org_code)', 'Each org_table ID is unique.'),
]
推荐答案
在OpenERP中,当您使用related
字段时,它基于type.
给出值或输出,例如type='char'
,
In OpenERP, When you use related
field, it's give value or output based on it's type.
For example type='char'
, See other fields type.
在您的情况下,您需要使用type='many2one'
来获取需求输出.
In your case you need to use type='many2one'
for getting desire output.
尝试一下
class activity_summary(osv.osv):
_name = "budget.activity_summary"
_rec_name = "activity_summarycode"
_columns = {
'activity_summarycode' : fields.many2one("budget.activity_year", "Activity Summary Code", ondelete= "no action", required=True ),
'region_id' : fields.related("activity_summarycode", "mgmt_code", type="many2one", string = "Management Code", relation="budget.activity_year", size=64, store = True),
}
这篇关于相关类型字段未显示值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!