From 888fe74ebcae1cd2666b67e10d2ac593bf9988b0 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, 12 Dec 2025 18:28:56 +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 --- .../views/yuthon_official_views.xml | 2 +- .../models/property_bills_list.py | 2 +- .../models/property_lease_contract.py | 32 +++++++++++++++++-- .../views/property_lease_contract.xml | 2 +- .../views/yuthon_business_approval_viwes.xml | 2 +- 5 files changed, 34 insertions(+), 6 deletions(-) diff --git a/yuthon_official/views/yuthon_official_views.xml b/yuthon_official/views/yuthon_official_views.xml index dd18d0528..7966b5f9f 100644 --- a/yuthon_official/views/yuthon_official_views.xml +++ b/yuthon_official/views/yuthon_official_views.xml @@ -37,7 +37,7 @@ - + diff --git a/yuthon_property_approval/models/property_bills_list.py b/yuthon_property_approval/models/property_bills_list.py index 409cd735e..3908d204d 100644 --- a/yuthon_property_approval/models/property_bills_list.py +++ b/yuthon_property_approval/models/property_bills_list.py @@ -3,7 +3,7 @@ from odoo import models, fields, api class PropertyBillsList(models.Model): _name = 'property.bills.list' - _description = '应收账单' + _description = '应付账单' management_type_id = fields.Many2one('yuthon.management.type', string='类型') due_date = fields.Date(string='应付日期') diff --git a/yuthon_property_approval/models/property_lease_contract.py b/yuthon_property_approval/models/property_lease_contract.py index c643e3ab2..e1056d81f 100644 --- a/yuthon_property_approval/models/property_lease_contract.py +++ b/yuthon_property_approval/models/property_lease_contract.py @@ -677,7 +677,10 @@ class PropertyLeaseContract(models.Model): if lease.address_id.is_message_fee and lease.address_id.message_standard_id: if lease.address_id.rent_area > 0: - total_months = (end.year - start.year) * 12 + (end.month - start.month) + if start and end: + total_months = (end.year - start.year) * 12 + (end.month - start.month) + else: + total_months = 0 management_month_number = max(total_months, 0) message_fee_values.append([0, 0, { 'breakdown_id': rec.id, @@ -729,7 +732,32 @@ class PropertyLeaseContract(models.Model): def end_approval(self): current_date = date.today() - old_contact_state = None + # 续租审批应退押金逻辑 + if self.contract_id: + management_type_id = self.env['yuthon.management.type'].search([('name', '=', '押金')], limit=1) + bills_list = self.env['property.bills.list'].search([ + 'contract_id', '=', self.contract_id.id, + ]) + if not bills_list: + self.env['property.bills.list'].create({ + 'due_date': fields.Date.today(), + 'management_type_id': management_type_id.id, + 'amount': self.contract_id.deposit, + 'contract_id': self.contract_id.id, + }) + + bank_id = self.env['property.bank.statements'].search([ + ('name_account', '=', self.contract_id.lessee_id.name), + ('remake', '=', '应退押金'), + ]) + if not bank_id: + self.env['property.bank.statements'].sudo().create({ + 'start_time': fields.Datetime.now() + timedelta(hours=8), + 'original_amount': self.contract_id.deposit, + 'name_account': self.contract_id.lessee_id.name, + 'remake': '应退押金', + }) + if self.term_start_time <= current_date <= self.term_end_time: new_contact_state = 'ing' old_contact_state = 'terminate' diff --git a/yuthon_property_approval/views/property_lease_contract.xml b/yuthon_property_approval/views/property_lease_contract.xml index 13f13e4c7..07b15048b 100644 --- a/yuthon_property_approval/views/property_lease_contract.xml +++ b/yuthon_property_approval/views/property_lease_contract.xml @@ -46,7 +46,7 @@ - + diff --git a/yuthon_trade/views/yuthon_business_approval_viwes.xml b/yuthon_trade/views/yuthon_business_approval_viwes.xml index 22460699a..8915c1b62 100644 --- a/yuthon_trade/views/yuthon_business_approval_viwes.xml +++ b/yuthon_trade/views/yuthon_business_approval_viwes.xml @@ -29,7 +29,7 @@ - +