From d37fb1afeb45d4c04603bcb74fd76be5316103c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= <9664676+pengyuthon@user.noreply.gitee.com> Date: Mon, 1 Jun 2026 17:17:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_contract/models/inherit_hr_contract.py | 18 ++++++++++++++++++ .../models/yuthon_party_setting.py | 1 + .../views/yuthon_party_setting_views.xml | 1 + 3 files changed, 20 insertions(+) diff --git a/yuthon_contract/models/inherit_hr_contract.py b/yuthon_contract/models/inherit_hr_contract.py index a83b63d3e..1466d8aa9 100644 --- a/yuthon_contract/models/inherit_hr_contract.py +++ b/yuthon_contract/models/inherit_hr_contract.py @@ -91,6 +91,24 @@ class HrContract(models.Model): ) change_ids = fields.One2many('hr.contract.change.line', 'contract_id', string="异动信息") + @api.constrains('party_id') + def _constrains_party_company(self): + for rec in self: + company = False + if rec.party_id and rec.party_id.work_address: + company = self.env['res.company'].search( + [('name', 'ilike', rec.party_id.work_address)], + limit=1 + ) + rec.company_id = company + rec.employee_id.company_id = company + if rec.employee_id and rec.employee_id.user_id and company: + user = rec.employee_id.user_id + user.write({ + 'company_id': company.id, + 'company_ids': [(4, company.id)] + }) + @api.constrains('change_ids') def _onchange_change_ids(self): if self.change_ids: diff --git a/yuthon_hr_employee/models/yuthon_party_setting.py b/yuthon_hr_employee/models/yuthon_party_setting.py index 09a4f6f05..cd1cd28df 100644 --- a/yuthon_hr_employee/models/yuthon_party_setting.py +++ b/yuthon_hr_employee/models/yuthon_party_setting.py @@ -16,6 +16,7 @@ class YuthonPartySetting(models.Model): address = fields.Text(string='通讯地址') contact = fields.Char(string='联系人') phone = fields.Char(string='电话') + work_address = fields.Char(string='办公所在地') level = fields.Selection([('one', '一级'), ('two', '二级'), ('three', '三级')], string='层级') effective_date = fields.Date(string="生效日期", default=fields.Date.today) expiration_date = fields.Date(string="失效日期") diff --git a/yuthon_hr_employee/views/yuthon_party_setting_views.xml b/yuthon_hr_employee/views/yuthon_party_setting_views.xml index f2692b675..1819b7e9e 100644 --- a/yuthon_hr_employee/views/yuthon_party_setting_views.xml +++ b/yuthon_hr_employee/views/yuthon_party_setting_views.xml @@ -13,6 +13,7 @@ +