Im having a problem linking a many2one field to another many2one field. Im getting numbers like 1,2,3(i think its the record number) instead of the field value in the drop down list.
Below, I have 3 classes Activity code, Activity data, and Activity summary.
Activity summary has a many2one field called 'activity_code' that relates to Activity data and activity data has a many2one field that relates to activity code. I am able to see the field values in the drop down list in activity data form, it works fine, but im not able to view it in Activity summary form. I get single digit numbers
Can anyone tell me why this is happening and how i may fix it to show the intended value instead of the numbers? Below is my code.
Activity code
class activity_yearcode(osv.osv):
_name = "budget.activity_code"
_description = "Activity Year Code"
_rec_name = "activity_code"
_columns = {
'activity_code' : fields.char("Activity Code", size=64, required=True),
'activity_name' : fields.char("Activity Name", size=128),
'act_status' : fields.selection([
('1', 'All'),
('2', 'Active'),
('3', 'Inactive'),
], 'Status'),
}
_sql_constraints = [
('activity_code_unique', 'UNIQUE(activity_code)', 'Each activity code is unique.'),
]
Activity Data - working fine
class activity_data(osv.osv):
_name = "management.activity_data"
_description = "Activity Data"
_rec_name = "activity_data_num"
_columns = {
'activity_data_num' : fields.char('activity_data_num', size=16),
'activity_code' : fields.many2one( "budget.activity_code","Activity Code",required=True),
'management_unit_code' : fields.many2one("budget.org_table","Management Unit Code", required=True),
}
_defaults = {
'activity_data_num': lambda self,cr,uid,context={}: self.pool.get('ir.sequence').get(cr, uid, 'management.activity_data'),
}
_sql_constraints = [
('activity_data_num', 'UNIQUE(activity_data_num)', 'Each activity_data_num is unique.'),
]
Activity Summary - In this model, im getting a single digit number in drop downl list instead of the the field value in 'activity_code' field.
class activity_summary(osv.osv):
_name = "work.activity_summary"
_description = "Activity Summary"
_columns = {
'activity_code' : fields.many2one("management.activity_data", "Activity Code", ondelete= "no action", required=True ),
'management_code' : fields.related("activity_code", "activity_data_num", "management_unit_code", type = "char", string = "Management code"),
'region_id' : fields.char("Region ID", size=64, required=True),
'daily_prod' : fields.integer("Daily Prod"),
'deviation' : fields.integer("Deviation Level"),
}
Please help..Thank you in advance.
try this code,
class activity_summary(osv.osv):
_name = "work.activity_summary"
_description = "Activity Summary"
_columns = {
'activity_code' : fields.many2one("budget.activity_code", "Activity Code", ondelete= "no action", required=True ),
'management_code' : fields.related("activity_code", "activity_data_num", "management_unit_code", type = "char", string = "Management code"),
'region_id' : fields.char("Region ID", size=64, required=True),
'daily_prod' : fields.integer("Daily Prod"),
'deviation' : fields.integer("Deviation Level"),
}
And your other code is OK. Please try this class if you have any problem to get values just ask.
Hope this will help you get value.