diff --git a/yuthon_contract/models/inherit_hr_contract.py b/yuthon_contract/models/inherit_hr_contract.py
index 43b8ef15d..d107bfa85 100644
--- a/yuthon_contract/models/inherit_hr_contract.py
+++ b/yuthon_contract/models/inherit_hr_contract.py
@@ -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(
diff --git a/yuthon_contract/views/inherit_hr_contract_views.xml b/yuthon_contract/views/inherit_hr_contract_views.xml
index ea4a83aaa..e4094d7db 100644
--- a/yuthon_contract/views/inherit_hr_contract_views.xml
+++ b/yuthon_contract/views/inherit_hr_contract_views.xml
@@ -10,6 +10,7 @@
+
diff --git a/yuthon_issue/views/issue_library_views.xml b/yuthon_issue/views/issue_library_views.xml
index dc33065f5..3b4f01cb3 100644
--- a/yuthon_issue/views/issue_library_views.xml
+++ b/yuthon_issue/views/issue_library_views.xml
@@ -378,7 +378,7 @@
issue.library
tree,form
- [('issue_state', 'not in', ['draft', 'to_draft', 'to_do']), ('is_company', '=', True)]
+ [('issue_state', 'not in', ['draft', 'to_draft', 'to_do']), ('is_meeting', '=', False), ('is_company', '=', True)]