添加功能
This commit is contained in:
@@ -124,12 +124,36 @@ class HrContract(models.Model):
|
||||
|
||||
@api.constrains('change_ids')
|
||||
def _onchange_change_ids(self):
|
||||
if self.change_ids:
|
||||
latest = self.change_ids.sorted('change_end_date', reverse=True)[0]
|
||||
self.department_id = latest.department_id
|
||||
self.job_id = latest.job_id
|
||||
self.structure_type_id = latest.structure_type_id
|
||||
self.salary_group_id = latest.salary_group_id
|
||||
today = fields.Date.today()
|
||||
for contract in self:
|
||||
active_line = False
|
||||
for line in contract.change_ids.sorted('change_start_date', reverse=True):
|
||||
# change_end_date 为空视为无限大
|
||||
if line.change_start_date <= today and (not line.change_end_date or line.change_end_date >= today):
|
||||
active_line = line
|
||||
break
|
||||
if active_line:
|
||||
contract.department_id = active_line.department_id
|
||||
contract.job_id = active_line.job_id
|
||||
contract.structure_type_id = active_line.structure_type_id
|
||||
contract.salary_group_id = active_line.salary_group_id
|
||||
|
||||
def init_change_lines(self):
|
||||
"""为选中的合同补初始异动行"""
|
||||
contract_ids = self.env["hr.contract"].browse(
|
||||
self._context.get("active_ids", self._context.get("active_id"))
|
||||
)
|
||||
for contract in contract_ids:
|
||||
if not contract.change_ids:
|
||||
self.env['hr.contract.change.line'].create({
|
||||
'contract_id': contract.id,
|
||||
'department_id': contract.department_id.id,
|
||||
'job_id': contract.job_id.id,
|
||||
'structure_type_id': contract.structure_type_id.id,
|
||||
'salary_group_id': contract.salary_group_id.id,
|
||||
'change_start_date': contract.date_start,
|
||||
'change_end_date': contract.date_end,
|
||||
})
|
||||
|
||||
def update_version(self):
|
||||
contract_ids = self.env["hr.contract"].browse(
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<button name="renew" string="续签" type="object" class="btn btn-primary"/>
|
||||
<button name="pub_leaving_employee" string="离职" type="object" class="btn btn-primary"/>
|
||||
<button name="yuthon_employee_add" string="合同补充" type="object" class="btn btn-primary"/>
|
||||
<button name="init_change_lines" string="初始化数据" type="object" class="btn btn-primary"/>
|
||||
</header>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='employee_id']" position="attributes">
|
||||
|
||||
Reference in New Issue
Block a user