我正在尝试打开另一个模型表单视图但是未找到错误的外部标识。
py文件中的
class ru_assignments(models.Model):
name = 'ru.assignments
class ru_assignments_sub(models.Model):
_name = 'ru.assignments.sub'
这是ru_assignments_sub xml
<record model="ir.actions.act_window" id="action_sub">
<field name="name">Assignment Sub</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">ru.assignments.sub</field>
<field name="view_type">form</field>
<field name="view_id" ref="ru_assignments_sub_view"/>
</record>
这是ru_assignments xml视图,其中我按下了打开ru_assignments_sub窗口的按钮
<record id="ru_assignments_view" model="ir.ui.view">
<field name="name">Assignments Form View</field>
<field name="model">ru.assignments</field>
<field name="arch" type="xml">
<form string="Assignments">
<sheet>
<button type="action" name="%(ru_assignments_sub.action_sub)d" string="Submit" class="oe_right oe_highlight"/>
<div class="oe_title">
<label for="teacher"/>
<field name="teacher" required="1" placeholder="e.g. Business Administration"/>
</div>
<group>
<field name="batch"/>
<field name="class_id"/>
<field name="faculty"/>
</group>
<notebook>
<page string="Related Students">
<field name="students"/>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
这是openerp.py文件
# always loaded
'data': [
# 'security/ir.model.access.csv',
'ru_students/workflow/workflow.xml',
'ru_students/students_view.xml',
'ru_students/sequence.xml',
'ru_students/address_view.xml',
'ru_teacher/teacher_view.xml',
'ru_teacher/batch_view.xml',
'ru_teacher/sequence.xml',
'ru_faculty/faculty_view.xml',
'ru_batch/batch_view.xml',
'ru_class/class_view.xml',
'ru_subjects/subjects_view.xml',
'ru_standards/standards_view.xml',
'ru_schedule/schedule_view.xml',
'ru_assignments_sub/assignments_sub_view.xml',
'ru_assignments/assignments_view.xml',
'ru_attendance/op_attendance_sheet_view.xml',
'ru_attendance_line/op_attendance_line_view.xml',
'ru_invoice/invoice_view.xml',
'ru_invoice_line/invoice_line_view.xml',
'ru_exam_line/exam_line_view.xml',
'ru_exam/exam_view.xml',
'ru_menu/menu.xml',
'css.xml',
答案 0 :(得分:2)
使用按钮调用打开另一个模块表单视图有两种方法。
在python中写这个
def show_ru_assignments_sub_view(self, cr, uid, ids, context=None):
return {
'name': ('Assignment Sub'),
'view_type': 'form',
'view_mode': 'form',
'res_model': 'ru.assignments.sub',
'view_id': False,
'type': 'ir.actions.act_window',
'target':'new'
}
以XML格式编写此按钮:
<button name="show_ru_assignments_sub_view" string="Submit" type="object" status="draft" />
用XML编写这两种编码:
<record id="action_assignments_sub_view" model="ir.actions.act_window">
<field name="name">Assignment Sub</field>
<field name="res_model">ru.assignments.sub</field>
<field name="src_model">ru.assignments</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="context">{'order_id': active_id}</field>
</record>
按钮操作
<button name="%(action_assignments_sub_view)d" type="action" string="Submit" />