Files
gzth/yuthon_report/models/ledger_report.py
T
2025-09-27 17:28:48 +08:00

54 lines
2.7 KiB
Python

from odoo import fields, models, api
class YuthonProperty(models.Model):
_inherit = 'yuthon.property'
@api.model
def get_complete_ledger_report(self, params):
domain = []
if params.get("keyword"):
domain.append(
domain.append(("name", "ilike", params["keyword"]))
)
if params.get("date_start"):
domain.append(("actual_start_time", ">=", params.get("date_start")))
if params.get("date_end"):
domain.append(("actual_end_time", "<=", params.get("date_end")))
# 查询数据,限制100条
properties = self.search(domain, limit=100)
state_selection = dict(self._fields['property_state']._description_selection(self.env))
return [
{
"资产地址": p.name or "",
"资产面积": p.equity_area or 0.0,
"街道": p.street or "",
"小区": p.precinct_id.name or "" if p.precinct_id else "",
"证载用途": p.registered_id.name or "" if p.registered_id else "",
"资产目前状态": state_selection.get(p.property_state, ""),
"片区管理员": p.admin_id.name or "" if p.admin_id else "",
"出租单位": p.property_contract_ids.lease_contract_id.lessor_id.name or ""
if p.property_contract_ids and p.property_contract_ids.lease_contract_id.lessor_id else "",
"承租方": p.lessee_id.name or "" if p.lessee_id else "",
"出租地址": p.rental_address or "",
"联系人": p.contact or "",
"出租用途": p.property_contract_ids.lease_contract_id.rental_purposes.name or ""
if p.property_contract_ids and p.property_contract_ids.lease_contract_id.rental_purposes else "",
"审批情况": p.approval_status or "",
"租赁合同号": p.contract_id.name or "" if p.contract_id else "",
"出租面积": p.rental_area or 0.0,
"评估价(元/m² •月)": p.appraisal_price or 0.0,
"首年租金": p.first_year_rent or 0.0,
"合同签订日期": p.contract_date.strftime("%Y-%m-%d") if p.contract_date else "",
"合约开始时间": p.term_start_time.strftime("%Y-%m-%d") if p.term_start_time else "",
"合约结束时间": p.term_end_time.strftime("%Y-%m-%d") if p.term_end_time else "",
"单价": p.unit_price or 0.0,
"月租金": p.monthly_amount or 0.0,
"合同总金额": p.total_amount or 0.0,
"实际已收到金额": p.real_amount or 0.0
}
for p in properties
]