添加功能
This commit is contained in:
@@ -45,7 +45,7 @@
|
||||
<group>
|
||||
<field name="number"/>
|
||||
<field name="user_type"/>
|
||||
<field name="department_id"/>
|
||||
<field name="department_id" domain="[('yuthon_company', '=' , yuthon_company)]"/>
|
||||
<field name="create_time"/>
|
||||
<field name="end_time"/>
|
||||
</group>
|
||||
|
||||
@@ -14,6 +14,8 @@ class YuthonHrDepartment(models.Model):
|
||||
department_function = fields.Char(string="部门职能")
|
||||
is_institution = fields.Boolean(string="是否机构")
|
||||
is_global_department = fields.Boolean(string="是否全局部门")
|
||||
yuthon_company = fields.Selection([('thtz', '天河投资集团'), ('thwg', '天河物管'),
|
||||
('thlc', '天河粮储')], default='thtz', store=True, compute="compute_company",string="所属公司")
|
||||
create_date = fields.Date(string="创建时间", default=fields.Date.today())
|
||||
start_date = fields.Date(string="生效日期", default=fields.Date.today())
|
||||
expiration_date = fields.Date(string="失效日期", default=fields.Date.today())
|
||||
@@ -55,4 +57,21 @@ class YuthonHrDepartment(models.Model):
|
||||
domain = expression.AND([search_domain, domain])
|
||||
return self._search(domain, limit=limit, order=order)
|
||||
|
||||
@api.depends('name', 'parent_id')
|
||||
def _compute_company(self):
|
||||
company_mapping = {
|
||||
'天河投资集团': 'thtz',
|
||||
'天河物管': 'thwg',
|
||||
'天河粮储': 'thlc',
|
||||
'天河投资本部': 'thtjbb',
|
||||
}
|
||||
|
||||
for record in self:
|
||||
department = record
|
||||
while department:
|
||||
if department.name in company_mapping:
|
||||
record.yuthon_company = company_mapping[department.name]
|
||||
break
|
||||
department = department.parent_id
|
||||
else:
|
||||
record.yuthon_company = 'thtz'
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
<xpath expr="//field[@name='department_id']" position="attributes">
|
||||
<attribute name="string">所属部门</attribute>
|
||||
<attribute name="required">1</attribute>
|
||||
<attribute name="domain">[('yuthon_company', '=' , yuthon_company)]</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//div[@class='oe_chatter']" position="attributes">
|
||||
<attribute name="invisible">1</attribute>
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
<field name="department_fax" column_invisible="1"/>
|
||||
<field name="department_location"/>
|
||||
<field name="parent_id" string="上级部门"/>
|
||||
<field name="yuthon_company" string="所属公司"/>
|
||||
<field name="total_employee" string="员工数量"/>
|
||||
<field name="department_function" column_invisible="1"/>
|
||||
<field name="is_institution" column_invisible="1"/>
|
||||
|
||||
@@ -37,8 +37,8 @@ class YuthonEmployeePerformance(models.Model):
|
||||
performance_records = super().create(vals_list)
|
||||
for performance in performance_records:
|
||||
self.env['yuthon.assessment.tasks'].create({
|
||||
'name': performance.name, # 使用创建的 performance 记录的 name
|
||||
'performance_id': performance.id, # 建立关联关系
|
||||
'name': performance.name,
|
||||
'performance_id': performance.id,
|
||||
'index_statu': performance.index_statu,
|
||||
'assessment_time': performance.assessment_time,
|
||||
'performance_type': 'employs'
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<record id="performance_template_downloads_tian_he_action" model="ir.actions.act_url">
|
||||
<field name="name">绩效模板 下载</field>
|
||||
<field name="target">self</field>
|
||||
<field name="url">/yuthon_performance/static/others/performance_template.xlsx</field>
|
||||
</record>
|
||||
<record id="yuthon_performance_wizard_form" model="ir.ui.view">
|
||||
<field name="name">审批意见弹窗</field>
|
||||
<field name="model">yuthon.performance.indicators.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<sheet>
|
||||
<header>
|
||||
<button name="%(performance_template_downloads_tian_he_action)d" string="模板下载" type="action"
|
||||
class="btn btn-primary"/>
|
||||
</header>
|
||||
<group>
|
||||
<group>
|
||||
<field name="excel_file" filename="excel_name"/>
|
||||
<field name="excel_name" invisible="1"/>
|
||||
</group>
|
||||
<group>
|
||||
</group>
|
||||
</group>
|
||||
</sheet>
|
||||
<footer>
|
||||
<button name="confirm" string="确认" type="object" class="oe_highlight"/>
|
||||
<button string="返回" class="btn-secondary" special="cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -0,0 +1,23 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import models, fields, api, _, SUPERUSER_ID
|
||||
from odoo.exceptions import ValidationError, UserError
|
||||
import xlrd
|
||||
import base64
|
||||
import datetime
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class YuthonPerformanceIndicatorsWizard(models.Model):
|
||||
_name = 'yuthon.performance.indicators.wizard'
|
||||
excel_file = fields.Binary(string="上传Excel表")
|
||||
excel_name = fields.Char(string="文件名")
|
||||
|
||||
def confirm(self):
|
||||
"""
|
||||
导入excel文件,按行读取数据并处理
|
||||
:return: 导入员工信息表并更新
|
||||
"""
|
||||
if not self.excel_file:
|
||||
raise ValidationError('请上传文件。')
|
||||
book = xlrd.open_workbook(file_contents=base64.decodebytes(self.excel_file))
|
||||
sh = book.sheet_by_index(0)
|
||||
Reference in New Issue
Block a user