From ccfb84aa6a1260e1022e8140639e4c00f3003051 Mon Sep 17 00:00:00 2001
From: zhou <123@>
Date: Sat, 11 Jan 2025 15:27:53 +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
---
.../models/property_lease_contract.py | 48 +++++++++++++++++--
.../views/property_lease_contract.xml | 7 ++-
.../wizard/property_rental_wizard.py | 7 ++-
3 files changed, 53 insertions(+), 9 deletions(-)
diff --git a/yuthon_property_approval/models/property_lease_contract.py b/yuthon_property_approval/models/property_lease_contract.py
index b49e20b65..b7a846d71 100644
--- a/yuthon_property_approval/models/property_lease_contract.py
+++ b/yuthon_property_approval/models/property_lease_contract.py
@@ -144,7 +144,6 @@ class PropertyLeaseContract(models.Model):
other_ids = fields.One2many('property.other.fee.line', 'other_id', string="其他费用明细行")
rent_list_ids = fields.One2many('property.rent.list', 'contract_id', string="租金明细行")
management_list_ids = fields.One2many('property.management.list', 'contract_id', string="管理费用明细行")
-
# 附件
license_id = fields.Many2one('ir.attachment', string="营业执照")
card_id = fields.Many2one('ir.attachment', string="经办人身份证")
@@ -155,6 +154,49 @@ class PropertyLeaseContract(models.Model):
responsibility_book_id = fields.Many2one('ir.attachment', string="安全生产责任书")
handover_time = fields.Date(string="交接日期")
+ def get_breakdown_rent(self, select_month, select_year):
+ rent_monthly = 0
+ monthly_records = self.env['property.lease.contract'].search([('cycle_dict', '=', 'monthly')])
+ year = int(select_year)
+ month = int(select_month)
+ date_field = datetime(year, month, 1).date()
+ for record in monthly_records:
+ days = record.date_payment_month
+ if not record.rent_free_period_month:
+ for rent_id in record.breakdown_ids:
+ start_date_year_month = rent_id.start_date.strftime('%Y-%m')
+ end_date_year_month = rent_id.end_date.strftime('%Y-%m')
+ date_field_year_month = date_field.strftime('%Y-%m')
+ if start_date_year_month <= date_field_year_month < end_date_year_month:
+ rent_monthly = rent_id.monthly_amount
+ elif start_date_year_month <= date_field_year_month <= end_date_year_month:
+ end_days = rent_id.end_date.day
+ if end_days < days:
+ rent_monthly = rent_id.monthly_amount
+ else:
+ rent_monthly = rent_id[+1].monthly_amount
+ else:
+ pass
+ else:
+ period_month = record.rent_free_period_month
+ for rent_id in record.breakdown_ids:
+ start_date_year_month = (rent_id.start_date + relativedelta(months=period_month)).strftime('%Y-%m')
+ end_date_year_month = rent_id.end_date.strftime('%Y-%m')
+ date_field_year_month = date_field.strftime('%Y-%m')
+ if start_date_year_month <= date_field_year_month < end_date_year_month:
+ rent_monthly = rent_id.monthly_amount
+ elif start_date_year_month <= date_field_year_month <= end_date_year_month:
+ end_days = rent_id.end_date.day
+ if end_days < days:
+ rent_monthly = rent_id.monthly_amount
+ else:
+ rent_monthly = rent_id[+1].monthly_amount
+ else:
+ pass
+
+ return rent_monthly
+
+
@api.depends('not_received', 'now_receivable')
def _compute_comparison(self):
for record in self:
@@ -416,7 +458,7 @@ class PropertyLeaseContract(models.Model):
all_period_rent = record.do_generate_details_core(start_date, first_year_end_date, False)
record.first_year_rent = all_period_rent
- def do_generate_details_core(self, start_date=None, end_date=None, write_db=False):
+ def do_generate_details_core(self, start_date, end_date, write_db=False):
all_period_rent = 0
unit_price = self.unit_price # 单价
@@ -823,7 +865,7 @@ class PropertyLeaseContract(models.Model):
rec.is_electricity = True
for electricity_id in property_id.energy_meter_ids:
electricity_list.append([0, 0, {
- 'fees_id': property_id.electricity_id.id,
+ 'fees_id': electricity_id.id,
'proportional':electricity_id.rate,
}])
else:
diff --git a/yuthon_property_approval/views/property_lease_contract.xml b/yuthon_property_approval/views/property_lease_contract.xml
index 789e832e1..a86ae79fc 100644
--- a/yuthon_property_approval/views/property_lease_contract.xml
+++ b/yuthon_property_approval/views/property_lease_contract.xml
@@ -310,7 +310,7 @@
-
+
@@ -379,7 +379,7 @@
-
+
@@ -624,6 +624,7 @@
+
@@ -646,6 +647,7 @@
全部合同
property.lease.contract
+ [('condition', 'in', ['be_executed', 'executed', 'expired' ,'advance'])]
tree,form,search
合同审批
property.lease.contract
tree,form,search
+ [('condition', 'in', ['new', 'approval', 'cancel'])]
{'search_default_group_by_condition':1}