Bla*_*ite 1 python xml odoo qweb odoo-8
美好的一天!加载kanban视图时,我每个人都有错误。我继承了hr.employee Kanbanxml并仅在某些文档过期时添加条件,它将在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>
Run Code Online (Sandbox Code Playgroud)
和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
Run Code Online (Sandbox Code Playgroud)
的 kanban在雇员的错误发生视图
预期单身人士:hr.employee(1、2)。
有人可以帮我这个问题,谢谢。
我不知道之间的关系hr.employee和hr.employee_documents。如果是One2many(一个唯一雇员的许多文档),则模型中必须有一个指向的One2many字段。假设此字段已命名(这对于通过触发计算方法很重要)。然后编写以下代码:hr.employeehr.employee_documentsdocumentsapi.depends
@api.multi
@api.depends('documents.date_expiry')
def getdocumentStatus(self):
server_date = datetime.datetime.strptime(DATE_NOW.strftime("%Y-%m-%d"), "%Y-%m-%d")
for record in self:
totaldoc = self.env['hr.employee_documents'].search_count([('date_expiry', '<', server_date),('employee_doc_id','=', self.id)])
if totaldoc > 0:
record.documents_status = True
else:
record.documents_status = False
Run Code Online (Sandbox Code Playgroud)
您应该给我们写两个模型之间的关系,以便给您准确的答案。
| 归档时间: |
|
| 查看次数: |
1789 次 |
| 最近记录: |