Hi, I have this class:
class ProjectTrackList(ModelSQL, ModelView):
'Project Track List'
__name__ = 'afx.project.tracklist'
list_name = fields.Char('List Name', required=True, readonly=True)
duration = fields.Selection('_get_durations', 'Duration', sort=False)
resource_name = fields.Selection('_get_resource_names', 'Resource Name')
client_name = fields.Selection('_get_client_names', 'Client Name')
team = fields.Selection('_get_teams', 'Team', sort=False)
proj_name = fields.Selection('_get_proj_names', 'Project Name', sort=False)
proj_status = fields.Selection([], 'Project Status', sort=False)
completion = fields.Selection([], 'Completion', sort=False)
start_date = fields.Date('Start Date')
end_date = fields.Date('End Date')
pic = fields.Selection('_get_resource_names', 'PIC')
duration = fields.Selection([], 'Duration', sort=False)
projects = fields.One2Many('afx.project.tracklist.record', 'tracklist', 'Projects')
# ----------- UTIL METHODS --------------
@classmethod
def __setup__(cls):
cls.duration.selection = cls._get_durations()
cls.completion.selection = cls._get_completions()
cls.proj_status.selection = cls._get_proj_statuses()
return super().__setup__()
@classmethod
def default_list_name(cls):
pool = Pool()
ProjectTrackList = pool.get('afx.project.tracklist')
tracklist = ProjectTrackList.search([('id', '=', '1')])
if tracklist:
return tracklist[0].list_name
return None
@classmethod
def default_projects(cls):
pool = Pool()
ProjectTrackListRecord = pool.get('afx.project.tracklist.record')
records = ProjectTrackListRecord.search([('tracklist', '=', '1')])
if records:
logger.info('>>'*30)
logger.info(f"{records}")
logger.info('>>'*30)
return records
return None
And I open the form of this class directly from Nav-bar link, as below
From the screenshot and also the console (not attached here), you can see that the projects field (One2Many to afx_project_tracklist_record) did loaded using default_projects method.
But why the records not appears in the table below the form? and only the rows?
It is supposed to be like below:
Only after I clicked save button, the table populated.
Regards
Bromo