将链接添加到UserError
消息中是否正确?像这样:
url = 'https://www.google.com/'
raise UserError("Some text: " + '<a href="' + url + '">'))
我已经将开关状态切换为“完成”,但是在此之前已经进行了测试。
@api.multi
def set_state_inwork(self):
self.check_condition_for_set_state_inwork()
for r in self:
r.state = "inwork"`
def check_condition_for_set_state_inwork(self):
if self.request_id.lab_id.is_check_condition_for_workbook:
import datetime
wb_collection = []
for r in self:
data = self.env['labs.request'].search(['|', '&',
('protocol_desired_date', '<', r.request_id.protocol_desired_date),
('protocol_desired_date', '>=', fields.Date.from_string(r.request_id.protocol_desired_date) if r.request_id.protocol_desired_date else fields.Date.from_string(fields.Datetime.now()) + datetime.timedelta(days=7)),
('protocol_desired_date', '!=', False)])
if data:
for d in data:
wb_list = d.workbook_ids.filtered(lambda x: x.state == 'awaitstart' and x.is_estimated_research_date is False and x.lab_employee_id == r.lab_employee_id).mapped("name")
if wb_list:
wb_collection.append(wb_list)
if wb_collection:
raise UserError("You must add data at this documents: " + ", ".join(x[0] for x in wb_collection))
现在只是文档数,我想添加指向此文档的链接。