添加功能
This commit is contained in:
@@ -18,10 +18,17 @@ class YuthonProperty(models.Model):
|
||||
if params.get("date_start"):
|
||||
date_start = datetime.datetime.fromisoformat(params.get("date_start")).date()
|
||||
domain.append(("effective_date", ">=", date_start))
|
||||
else:
|
||||
date_start = None
|
||||
if params.get("date_end"):
|
||||
date_end = datetime.datetime.fromisoformat(params.get("date_start")).date()
|
||||
domain.append(("end_date", "<=", date_end))
|
||||
|
||||
domain.append([
|
||||
"|",
|
||||
("end_date", "<=", date_end),
|
||||
("end_date", "=", False)
|
||||
])
|
||||
else:
|
||||
date_end = None
|
||||
|
||||
condition = params.get('condition',False)
|
||||
partner_id = params.get('partner_id',False)
|
||||
@@ -48,22 +55,24 @@ class YuthonProperty(models.Model):
|
||||
|
||||
result = []
|
||||
for p in properties:
|
||||
# 1. 筛选符合日期范围的合同:property_contract_ids中满足周期交集的记录
|
||||
filtered_contracts = p.property_contract_ids.filtered(
|
||||
lambda contract:
|
||||
contract.start_time and
|
||||
(not contract.end_time or contract.end_time >= date_start) and
|
||||
contract.start_time <= (date_end or datetime.max.date())
|
||||
(not date_start or not contract.end_date or contract.end_date >= date_start) and
|
||||
(not date_end or contract.start_time <= date_end)
|
||||
)
|
||||
|
||||
# 2. 处理筛选后的合同
|
||||
target_contract = filtered_contracts if filtered_contracts else False
|
||||
target_contract = False
|
||||
if filtered_contracts:
|
||||
sorted_contracts = filtered_contracts.sorted(key=lambda c: c.start_time)
|
||||
target_contract = sorted_contracts[0].lease_contract_id
|
||||
|
||||
# 3. 获取合同信息
|
||||
rent_company = target_contract.rent_company if target_contract else ""
|
||||
lessee_id = target_contract.lessee_id.name if (target_contract and target_contract.lessee_id) else ""
|
||||
property_name = target_contract.property_name if target_contract else ""
|
||||
contact = target_contract.lessee_id.contact if (target_contract and target_contract.lessee_id) else ""
|
||||
rental_purposes = target_contract.rental_purposes if target_contract else ""
|
||||
rental_purposes = target_contract.rental_purposes.name if target_contract else ""
|
||||
contract_code = target_contract.contract_code if target_contract else ""
|
||||
total_area = target_contract.total_area if target_contract else 0.0
|
||||
first_year_rent = target_contract.first_year_rent if target_contract else 0.0
|
||||
@@ -87,7 +96,7 @@ class YuthonProperty(models.Model):
|
||||
if target_contract:
|
||||
lease_line = self.env['property.lease.contract.line'].search([
|
||||
('address_id', '=', p.id), # 按资产ID匹配明细行
|
||||
('lease_contract_id', '=', target_contract.id) # 按目标合同匹配
|
||||
('lease_id', '=', target_contract.id) # 按目标合同匹配
|
||||
], limit=1)
|
||||
evaluate_unit_price = lease_line.evaluate_unit_price if lease_line else 0.0
|
||||
|
||||
@@ -105,7 +114,7 @@ class YuthonProperty(models.Model):
|
||||
"出租地址": property_name,
|
||||
"联系人": contact,
|
||||
"出租用途": rental_purposes,
|
||||
"审批情况": p.approval_status or "",
|
||||
"审批情况": "已审批",
|
||||
"租赁合同号": contract_code,
|
||||
"出租面积": total_area,
|
||||
"评估价(元/m² •月)": evaluate_unit_price,
|
||||
|
||||
Reference in New Issue
Block a user