From 711cc9188b4b2401a5d99e6a63af559c1777811a 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: Fri, 17 Oct 2025 16:31:13 +0800 Subject: [PATCH 1/2] =?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_property_approval/wizard/property_rental_wizard.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/yuthon_property_approval/wizard/property_rental_wizard.py b/yuthon_property_approval/wizard/property_rental_wizard.py index 44bea1476..16113cf92 100644 --- a/yuthon_property_approval/wizard/property_rental_wizard.py +++ b/yuthon_property_approval/wizard/property_rental_wizard.py @@ -156,8 +156,12 @@ class PropertyRentalWizard(models.Model): end_year_month = rent_id.end_data.strftime('%Y-%m') start_day = start_date_adj.day rent_amount = rent_id.monthly_amount - # 调整后的租金 - date_str = f"{date_field_year_month}-{start_day}" + # 调整后的租金 + target_year, target_month = map(int, date_field_year_month.split('-')) + max_day = calendar.monthrange(target_year, target_month)[1] + # 修正日:如果原始日超过当月最大天数,取当月最后一天 + adjusted_day = min(start_day, max_day) + date_str = f"{date_field_year_month}-{adjusted_day}" start_date = datetime.strptime(date_str, "%Y-%m-%d") # 当期应收日期 if not record.is_contract: From a55a038966dc1f629cc2383dad07df7e217c3e61 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: Fri, 17 Oct 2025 16:37:08 +0800 Subject: [PATCH 2/2] =?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_property/models/property_rent_list.py | 1 + .../views/property_rent_list_views.xml | 1 + .../models/inherit_yuthon_property.py | 13 +-------- .../wizard/property_rental_wizard.py | 28 +++++++++++-------- 4 files changed, 19 insertions(+), 24 deletions(-) diff --git a/yuthon_property/models/property_rent_list.py b/yuthon_property/models/property_rent_list.py index a6d5736aa..3f7b86ea5 100644 --- a/yuthon_property/models/property_rent_list.py +++ b/yuthon_property/models/property_rent_list.py @@ -11,6 +11,7 @@ class PropertyRentList(models.Model): rent_month = fields.Float(string='当月租金') tax = fields.Float(string='税率') title_certificate = fields.Char(sting="产权证号") + acc_type = fields.Selection([('new', '新租'), ('done', '到期')], string='类型') invoicing_type = fields.Selection([('spot', '专票'), ('cape', '普票')], related='lessee_id.invoicing_type', string="开票类型") due_date = fields.Date(string='应收日期') diff --git a/yuthon_property/views/property_rent_list_views.xml b/yuthon_property/views/property_rent_list_views.xml index 370515589..ab16656ca 100644 --- a/yuthon_property/views/property_rent_list_views.xml +++ b/yuthon_property/views/property_rent_list_views.xml @@ -6,6 +6,7 @@ + diff --git a/yuthon_property_approval/models/inherit_yuthon_property.py b/yuthon_property_approval/models/inherit_yuthon_property.py index baa9387f1..ecfedc22b 100644 --- a/yuthon_property_approval/models/inherit_yuthon_property.py +++ b/yuthon_property_approval/models/inherit_yuthon_property.py @@ -879,17 +879,6 @@ class PropertyRentList(models.Model): due_date_end = False theoretical_end = False contract = rec.contract_id - - existing_receivable = self.env['property.accounts.receivable'].search([ - ('lessee_id', '=', rec.lessee_id.id), - ('management_type_id.name', '=', '租金'), - ('contract_id', '=', contract), - ], limit=1) - if not existing_receivable: - acc_type = 'new' - else: - acc_type = None - if contract and contract.cycle_mode and due_date: due_date_obj = fields.Date.from_string(due_date) contract_actual_end = fields.Date.from_string( @@ -927,7 +916,7 @@ class PropertyRentList(models.Model): 'lessee_id': contract.lessee_id.id if contract and contract.lessee_id else None, 'original_amount': rec.original_amount, 'due_date': due_date, - 'acc_type': acc_type, + 'acc_type': rec.acc_type, 'due_date_end': due_date_end, 'create_time': datetime.now(), 'management_type_id': management_type.id, diff --git a/yuthon_property_approval/wizard/property_rental_wizard.py b/yuthon_property_approval/wizard/property_rental_wizard.py index 16113cf92..110efa66b 100644 --- a/yuthon_property_approval/wizard/property_rental_wizard.py +++ b/yuthon_property_approval/wizard/property_rental_wizard.py @@ -27,23 +27,26 @@ class PropertyRentalWizard(models.Model): ('due_date', '<=', last_day_of_month), ]) + # 判断是否有已生成应收 + existing_receivable = self.env['property.accounts.receivable'].search([ + ('lessee_id', '=', record.lessee_id.id), + ('due_date', '>=', first_day_of_month), + ('due_date', '<=', last_day_of_month), + ('management_type_id.name', '=', '租金'), + ('contract_id', '=', record.id), + ], limit=1) + + if existing_receivable: + return + else: + acc_type = 'new' + if not rent_id: - # 判断是否有已生成应收 - existing_receivable = self.env['property.accounts.receivable'].search([ - ('lessee_id', '=', record.lessee_id.id), - ('due_date', '>=', first_day_of_month), - ('due_date', '<=', last_day_of_month), - ('management_type_id.name', '=', '租金'), - ('contract_id', '=', record.id), - ], limit=1) - - if existing_receivable: - return - self.sudo().env["property.rent.list"].create({ "contract_id": record.id, "due_date": start_date, 'multiplier': multiplier, + 'acc_type': acc_type, "lessee_id": record.lessee_id.id, "property_id": property_id, "original_amount": rent_amount, @@ -56,6 +59,7 @@ class PropertyRentalWizard(models.Model): "due_date": start_date, 'multiplier': multiplier, "lessee_id": record.lessee_id.id, + 'acc_type': acc_type, "property_id": property_id, "original_amount": rent_amount, "year": self.select_year,