From ccfe9d24efdd85ed09b1943ef6fc0ba7b71a2915 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Thu, 22 Jan 2026 09:41:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A5=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/monthly_precollection_report.py | 80 +++++++++++++++++++ .../views/monthly_precollection_report.xml | 36 +++++++++ 2 files changed, 116 insertions(+) create mode 100644 yuthon_report/models/monthly_precollection_report.py create mode 100644 yuthon_report/views/monthly_precollection_report.xml diff --git a/yuthon_report/models/monthly_precollection_report.py b/yuthon_report/models/monthly_precollection_report.py new file mode 100644 index 000000000..f53d3bf26 --- /dev/null +++ b/yuthon_report/models/monthly_precollection_report.py @@ -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 + diff --git a/yuthon_report/views/monthly_precollection_report.xml b/yuthon_report/views/monthly_precollection_report.xml new file mode 100644 index 000000000..e8d616abb --- /dev/null +++ b/yuthon_report/views/monthly_precollection_report.xml @@ -0,0 +1,36 @@ + + + + + 本月预收 + receivable_report_client + + { + "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} + ] + } + } + + + + + + +