报表
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
import datetime
|
||||
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class MonthlyPrecollectionReport(models.Model):
|
||||
_inherit = 'property.accounts.receivable'
|
||||
|
||||
@api.model
|
||||
def get_monthly_precollection_report(self, params):
|
||||
"""汇总当前筛选条件下的应收数据(本月预收视图)。"""
|
||||
domain = []
|
||||
|
||||
keyword = params.get("keyword")
|
||||
if keyword:
|
||||
domain += [
|
||||
'|', '|',
|
||||
('lessee_id.name', 'ilike', keyword),
|
||||
('property_name', 'ilike', keyword),
|
||||
('title_deed', 'ilike', keyword),
|
||||
]
|
||||
|
||||
date_start = params.get("date_start")
|
||||
date_end = params.get("date_end")
|
||||
if date_start:
|
||||
start_dt = datetime.datetime.fromisoformat(date_start).date()
|
||||
domain.append(("due_date", ">=", start_dt))
|
||||
if date_end:
|
||||
end_dt = datetime.datetime.fromisoformat(date_end).date()
|
||||
domain.append(("due_date", "<=", end_dt))
|
||||
|
||||
condition = params.get('condition')
|
||||
partner_id = params.get('partner_id')
|
||||
company_id = params.get('company_id')
|
||||
management_type_id = params.get('management_type_id')
|
||||
|
||||
if condition:
|
||||
domain.append(('tenure_type', '=', condition))
|
||||
if partner_id:
|
||||
domain.append(('precinct_id', '=', partner_id))
|
||||
if company_id:
|
||||
domain.append(('company_id', '=', company_id))
|
||||
if management_type_id:
|
||||
domain.append(('management_type_id', '=', management_type_id))
|
||||
|
||||
receivables = self.search(domain, limit=1000, order="due_date asc")
|
||||
|
||||
result = []
|
||||
total_amount = 0.0
|
||||
for index, rec in enumerate(receivables, start=1):
|
||||
amount = rec.original_amount or 0.0
|
||||
total_amount += amount
|
||||
result.append({
|
||||
"序号": index,
|
||||
"合同编号": rec.contract_id.contract_code if rec.contract_id else "",
|
||||
"物业名称": rec.property_name or "",
|
||||
"承租方名称": rec.lessee_id.name if rec.lessee_id else "",
|
||||
"金额": round(amount, 2),
|
||||
"所属公司": (
|
||||
rec.contract_id.lessor_id.referred
|
||||
or rec.contract_id.lessor_id.name
|
||||
if rec.contract_id and rec.contract_id.lessor_id
|
||||
else ""
|
||||
),
|
||||
"管理员": rec.contract_id.admin_id.name if rec.contract_id and rec.contract_id.admin_id else "",
|
||||
})
|
||||
|
||||
# 保持与示例一致,追加合计行
|
||||
result.append({
|
||||
"序号": "",
|
||||
"合同编号": "合计",
|
||||
"物业名称": "",
|
||||
"承租方名称": "",
|
||||
"金额": round(total_amount, 2),
|
||||
"所属公司": "",
|
||||
"管理员": "",
|
||||
})
|
||||
|
||||
return result
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="action_monthly_precollection_report" model="ir.actions.client">
|
||||
<field name="name">本月预收</field>
|
||||
<field name="tag">receivable_report_client</field>
|
||||
<field name="context">
|
||||
{
|
||||
"sideBar": true,
|
||||
"report_config": {
|
||||
"model": "property.accounts.receivable",
|
||||
"method": "get_monthly_precollection_report",
|
||||
"columns": [
|
||||
{"headerName": "序号", "field": "序号", "flex": 0.6},
|
||||
{"headerName": "合同编号", "field": "合同编号", "flex": 1},
|
||||
{"headerName": "物业名称", "field": "物业名称", "flex": 2},
|
||||
{"headerName": "承租方名称", "field": "承租方名称", "flex": 1.2},
|
||||
{"headerName": "金额", "field": "金额", "flex": 1, "type": "number"},
|
||||
{"headerName": "所属公司", "field": "所属公司", "flex": 1},
|
||||
{"headerName": "管理员", "field": "管理员", "flex": 1}
|
||||
]
|
||||
}
|
||||
}
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<menuitem
|
||||
id="menu_monthly_precollection_report"
|
||||
name="本月预收"
|
||||
parent="yuthon_property_approval.property_approval_report_menu"
|
||||
action="action_monthly_precollection_report"
|
||||
sequence="11"
|
||||
/>
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user