请让我知道我在哪里犯了错误我正在尝试添加一个可点击的文本,当单击该移动到表单和树视图时,我可以保存数据,当单击保存按钮时,我可以返回上一个视图,然后之前的视图有一个可点击的文本可以再次查看数据
视图.xml
<odoo>
<data>
<record id="kts_project_task" model="ir.ui.view">
<field name="name">kts.project.task.view.form</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_form2" />
<field name="arch" type="xml">
<field name="date_deadline" position="after">
<field name="actual_completion_date" />
<field name="testscript_ids"/>
</field>
</field>
</record>
Error--->> <record id="kts_project_script" model="ir.ui.view">
<field name="name">kts.project.task.testscript.view.form</field>
<field name="model">kts.project.task.testscript</field>
<field name="arch" type="xml">
<form string="Test Script">
<group col="2">
<group>
<field name="test_case_id"/>
<field name="test_priority"/>
<field name="module_name"/>
<field name="test_title"/>
<field name="overall_status"/>
</group>
<group>
<field name="test_designed_by"/>
<field name="test_designed_date"/>
<field name="test_executed_by"/>
<field name="test_executed_date"/>
<field name="remark"/>
</group>
</group>
<group>
<field name="pre_conditions"/>
</group>
</form>
<field name="test_script_line_ids" mode="tree">
<tree editable="bottom" string="Test Script" >
<field name="step_name" />
<field name="description" />
<field name="expected" />
<field name="actual_result" />
<field name="pass_fail"/>
<field name="remark"/>
</tree>
</field>
</field>
</record>
</data>
</odoo>
模型.py
class kts_project_task(models.Model):
_inherit = 'project.task'
actual_completion_date = fields.Date(string='Actual Completion Date', index=True, copy=False, tracking=True)
testscript_ids = fields.Many2one('kts.project.task.testscript', string="Test Script")
@api.returns('self', lambda value: value.id)
def copy(self, default=None):
if default is None:
default = {}
default['user_id']=False
return super(kts_project_task, self).copy(default)
def get_user(self):
if SUPERUSER_ID == self._uid:
return True
else:
return False
#field level readonly managed for users
@api.model
def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
res = super(kts_project_task, self).fields_view_get(view_id=view_id,
view_type=view_type,
toolbar=toolbar,
submenu=submenu)
if self.env.user.has_group('project.group_task_user') :
doc = etree.XML(res['arch'])
for field in ['date_deadline','project_id','user_id','tag_ids','name', 'partner_id']:
for node in doc.xpath("//field[@name='%s']" % field):
node.set("readonly", "1")
modifiers = json.loads(node.get("modifiers"))
modifiers['readonly'] = True
node.set("modifiers", json.dumps(modifiers))
res['arch'] = etree.tostring(doc)
return res
class kts_project_task_testscript(models.Model):
_name = 'kts.project.task.testscript'
test_case_id = fields.Char(string='Test Case ID')
test_priority = fields.Char(string='Test Priority')
module_name = fields.Char(string='Module Name')
test_title = fields.Char(string='Test Title')
overall_status = fields.Char(string='Overall Status')
test_designed_by = fields.Char(string='Test Designed By')
test_designed_date = fields.Date(string='Test Designed Date')
test_executed_by = fields.Char(string='Test Executed By')
test_executed_date = fields.Date(string='Test Executed Date')
remark = fields.Char(string='Remarks')
pre_conditions = fields.Text(string='Pre-conditions')
test_script_line_ids = fields.One2many('kts.project.task.testscript.line', 'testscript_id', 'Test Script Id')
class kts_project_task_testscript_line(models.Model):
_name = 'kts.project.task.testscript.line'
step_name = fields.Char(string='Steps')
description = fields.Text(string='Test Steps')
expected = fields.Text(string='Excepted results')
actual_result = fields.Text(string='Actual Results')
pass_fail = fields.Selection([
('pass', 'Pass'),
('fail', 'Fail'),
], string="Status(P/F)")
remark = fields.Text(string='Remarks')
testscript_id = fields.Many2one('kts.project.task.testscript', string="Task Activities")