From 188a2b3a54faddd6741624b9c5503a395409a2b8 Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Tue, 17 Jun 2025 20:03:23 +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 --- .../soong_workflow_comment_wizard_view.xml | 7 ++--- yuthon_contract/models/inherit_hr_contract.py | 26 ++++++++++++------- .../views/property_deposit_list_views.xml | 2 +- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/soong_workflow/wizard/soong_workflow_comment_wizard_view.xml b/soong_workflow/wizard/soong_workflow_comment_wizard_view.xml index 253cbe92c..a69a26134 100644 --- a/soong_workflow/wizard/soong_workflow_comment_wizard_view.xml +++ b/soong_workflow/wizard/soong_workflow_comment_wizard_view.xml @@ -11,13 +11,14 @@ +
@@ -25,7 +26,7 @@
@@ -33,7 +34,7 @@
diff --git a/yuthon_contract/models/inherit_hr_contract.py b/yuthon_contract/models/inherit_hr_contract.py index b0b5423a6..912dd63f6 100644 --- a/yuthon_contract/models/inherit_hr_contract.py +++ b/yuthon_contract/models/inherit_hr_contract.py @@ -39,16 +39,22 @@ class HrContract(models.Model): documents_ids = fields.Many2many('ir.attachment', string="合同附件") is_company = fields.Boolean(string="本公司", default=True, compute='_compute_is_company', search='_search_part_of_company') - @api.constrains("state") - def _constrains_state(self): - today = date.today() - if self.date_end: - if self.date_end < today: - self.state = 'close' - elif self.date_end == today: - self.state = 'close' - else: - self.state = 'open' + def write(self, vals): + """在写入时自动更新合同状态""" + # 先执行状态更新 + today = fields.Date.today() + if 'date_end' in vals: + new_end_date = fields.Date.to_date(vals['date_end']) + # 遍历所有要更新的合同 + for contract in self: + end_date = new_end_date + if end_date > today: + vals['state'] = 'open' + elif end_date < today: + vals['state'] = 'close' + + # 调用原生写入逻辑 + return super(HrContract, self).write(vals) @api.depends_context('uid', 'company') @api.depends('company_id') diff --git a/yuthon_property/views/property_deposit_list_views.xml b/yuthon_property/views/property_deposit_list_views.xml index d58b9250f..be6b9efb3 100644 --- a/yuthon_property/views/property_deposit_list_views.xml +++ b/yuthon_property/views/property_deposit_list_views.xml @@ -4,7 +4,7 @@ property.deposit.tree property.deposit.list - +