如何通过default_get方法预先从数据加载记录。
我有这种记录数据/ project_data.xml
的数据文件class ProjectPartWizard(models.TransientModel):
_name = 'project.part.wizard'
_description = 'Part wizard'
part_ids = fields.Many2many('project.part')
@api.model
def default_get(self, fields_list):
result = super(ProjectPartWizard, self).default_get(fields_list)
part_ids = []
if self._context.get('active_model') == 'project.project':
project = self.env['project.project'].browse(
self._context.get('active_id'))
project and part_ids.extend(project.project_part_ids.ids)
# TODO load all part from template
result.update(part_ids=[(6, 0, part_ids)])
return result
和向导。
<xpath expr="//field[@name='task_count']/.." position="before">
<button string="Generate Parts" class="oe_stat_button"
name="%(project_part_wizard_action)d"
type="action" icon="fa-th">
</button>
</xpath>
更新
ipaddress
这是按钮
所以有一个模板,我需要在打开它时所有模板都在向导中预加载。我怎么能用default_get
来做