【发布时间】:2015-09-28 10:24:11
【问题描述】:
美好的一天!加载kanban 视图时出现错误。我继承了hr.employeeKanban xml,如果某个文档过期,它会在kanban视图中添加过期文档通知,这里是xml代码:
<record model="ir.ui.view" id="hr_kanban_view_employees_recruitment_kanban">
<field name="name">HR - Employees Kanban Document Status</field>
<field name="model">hr.employee</field>
<field name="inherit_id" ref="hr.hr_kanban_view_employees"/>
<field name="arch" type="xml">
<xpath expr="//templates" position="before">
<field name="employee_id"/>
<field name="documents_status"/>
</xpath>
<xpath expr="//div[@class='oe_employee_details']/ul/li[@id='last_login']" position="inside">
<span t-if="record.documents_status.raw_value" style="font-size: 100%%"
t-att-class="record.documents_status.raw_value==true'oe_kanban_button oe_kanban_color_3'">
<field name="employee_id" readonly = "1"/>
Has Expired Documents
</span>
</xpath>
</field>
</record>
以及documents_status 字段的模型
加载时
documents_status = fields.Boolean('DocumentStatus', readonly = True,store = False,compute ='getdocumentStatus')
@api.one
def getdocumentStatus(self):
raise Warning(self.employee_id)
server_date = datetime.datetime.strptime(DATE_NOW.strftime("%Y-%m-%d") ,"%Y-%m-%d")
result = {}
for id in self.ids:
result[id] = {
'documents_status': True
}
totaldoc = self.env['hr.employee_documents'].search_count([('date_expiry', '<', server_date),('employee_doc_id','=', id)])
if totaldoc > 0:
result[id]['documents_status'] = True
self.documents_status = True
else:
result[id]['documents_status'] = False
self.documents_status = False
return result
员工中的kanban 视图发生错误
预期的单身人士:hr.employee(1, 2)。
有人能帮我解决这个问题吗?提前致谢。
【问题讨论】:
-
你可以使用 api.multi 代替 api.one
-
试过了还是提示错误
-
为什么要在模型
hr.employee中添加一个名为employee_id的字段?是不是和只放id不一样?
标签: python xml odoo-8 odoo qweb