From 903ee66c9321b33f91ff94e1d2046611905abd7e 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: Thu, 18 Sep 2025 16:10:45 +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_holiday/views/hr_leave_batch.xml | 7 +------ .../models/property_lease_renewal.py | 11 ++++++++++- .../views/property_lease_renewal.xml | 1 - .../wizard/property_rental_wizard.py | 18 +++++++++++++++--- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/yuthon_holiday/views/hr_leave_batch.xml b/yuthon_holiday/views/hr_leave_batch.xml index 6b2471a46..b271b1773 100644 --- a/yuthon_holiday/views/hr_leave_batch.xml +++ b/yuthon_holiday/views/hr_leave_batch.xml @@ -39,14 +39,9 @@ -
-
+ diff --git a/yuthon_property_approval/models/property_lease_renewal.py b/yuthon_property_approval/models/property_lease_renewal.py index eeb1b4f50..5880ae057 100644 --- a/yuthon_property_approval/models/property_lease_renewal.py +++ b/yuthon_property_approval/models/property_lease_renewal.py @@ -11,7 +11,6 @@ class PropertyLeaseRenewal(models.Model): _rec_name = 'name' name = fields.Char(string='标题') - reason_application = fields.Text(string="申请事由") user_id = fields.Many2one('res.users', string="申请人", default=lambda self: self.env.user) department_id = fields.Many2one(related='user_id.department_id', string="部门") company_id = fields.Many2one(related='user_id.company_id', string="公司") @@ -87,5 +86,15 @@ class PropertyLeaseRenewal(models.Model): 'actual_end_time': rec.early_quitting_date}) rec.hide = True + @api.onchange('contract_id', 'renewal_type') + def _onchange_name(self): + if self.contract_id and self.renewal_type: + renewal_type_text = dict(self._fields['renewal_type'].selection).get(self.renewal_type, '') + self.name = f"{self.contract_id.name} + {renewal_type_text}" + elif self.contract_id: + self.name = self.contract_id.property_name + else: + self.name = False + class PropertyEarlyQuitting(models.Model): _name = 'property.early.quitting' diff --git a/yuthon_property_approval/views/property_lease_renewal.xml b/yuthon_property_approval/views/property_lease_renewal.xml index 39d548a86..aeb553893 100644 --- a/yuthon_property_approval/views/property_lease_renewal.xml +++ b/yuthon_property_approval/views/property_lease_renewal.xml @@ -39,7 +39,6 @@ - diff --git a/yuthon_property_approval/wizard/property_rental_wizard.py b/yuthon_property_approval/wizard/property_rental_wizard.py index ba89fc32b..a4f9326e8 100644 --- a/yuthon_property_approval/wizard/property_rental_wizard.py +++ b/yuthon_property_approval/wizard/property_rental_wizard.py @@ -214,13 +214,25 @@ class PropertyRentalWizard(models.Model): date_field = datetime(year, month, 1).date() date_field_year_month = date_field.strftime('%Y-%m') # 获取当月第一天和最后一天 - first_day = datetime.strptime(date_field_year_month, '%Y-%m').date() # 当月第一天 - last_day = (first_day + relativedelta(months=1, days=-1)) # 当月最后一天 + first_day = datetime.strptime(date_field_year_month, '%Y-%m').date() + last_day = first_day + relativedelta(months=1) - relativedelta(days=1) records = self.env['property.lease.contract'].search([ ('actual_start_time', '<=', last_day), ('actual_end_time', '>=', first_day), + ('contract_code', '=', 'SWZ2020-001') ]) - for record in records: + filtered_records = [ + rec for rec in records + if not ( + rec.cycle_mode == 'fixed_monthly' + # 条件2:实际开始日期的日是1号 + and getattr(rec.actual_start_time, 'day', None) != 1 + # 条件3:实际结束日期的年月等于目标年月 + and getattr(rec.actual_end_time, 'year', None) == year + and getattr(rec.actual_end_time, 'month', None) == month + ) + ] + for record in filtered_records: date_data = { 'five': 5, 'fifteen': 15,