This commit is contained in:
李鹏宇
2026-03-13 11:50:47 +08:00
parent 087df9e42f
commit 0d186695a8
4 changed files with 121 additions and 2 deletions
+2 -1
View File
@@ -41,4 +41,5 @@ from . import penalty_year_cum_report
from . import deposit_month_receivable_report
from . import deposit_pre_received_report
from . import deposit_month_received_report
from . import deposit_cum_arrears_report
from . import deposit_cum_arrears_report
from . import deposit_month_refund_report
@@ -0,0 +1,88 @@
import datetime
from odoo import api, models
class DepositMonthRefundReport(models.Model):
_inherit = 'property.accounts.receivable'
@api.model
def get_deposit_month_refund_report(self, params):
"""
押金本月已退报表:
- 管理费用类型为"押金"
- has_date(退款日期)在本月范围内
- is_invalid = False
- 每条记录单独一行,金额 = delivered1
"""
today = datetime.date.today()
this_month_first = today.replace(day=1)
if today.month == 12:
next_month_first = today.replace(year=today.year + 1, month=1, day=1)
else:
next_month_first = today.replace(month=today.month + 1, day=1)
this_month_last = next_month_first - datetime.timedelta(days=1)
deposit_type = self.env['yuthon.management.type'].search([('name', '=', '押金')], limit=1)
domain = [
('has_date', '>=', this_month_first),
('has_date', '<=', this_month_last),
('is_invalid', '=', False),
]
if deposit_type:
domain.append(('management_type_id', '=', deposit_type.id))
keyword = params.get("keyword")
if keyword:
domain += ['|', '|',
('contract_id.contract_code', 'ilike', keyword),
('property_name', 'ilike', keyword),
('lessee_id.name', 'ilike', keyword),
]
condition = params.get('condition')
partner_id = params.get('partner_id')
company_id = params.get('company_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))
receivables = self.search(domain, order="has_date asc, contract_id asc")
rows = []
total_amount = 0.0
for idx, rec in enumerate(receivables, start=1):
amount = round(rec.delivered1 or 0.0, 2)
total_amount += amount
rows.append({
"序号": idx,
"退押日期": rec.has_date.strftime("%Y-%m-%d") if rec.has_date else "",
"合同编号": {
'model': 'property.lease.contract',
'id': rec.contract_id.id,
'display_name': rec.contract_id.contract_code,
} if rec.contract_id else "",
"物业名称": rec.property_name or "",
"承租方名称": {
'model': 'property.tenant.information',
'id': rec.lessee_id.id,
'display_name': rec.lessee_id.name,
} if rec.lessee_id else "",
"金额": amount,
"所属公司": rec.company_id.name if rec.company_id else "",
"管理员": {
'model': 'res.users',
'id': rec.admin_id.id,
'display_name': rec.admin_id.name,
} if rec.admin_id else "",
})
stats = [
{'name': '记录总数', 'amount': len(rows)},
{'name': '合计退款', 'amount': round(total_amount, 2)},
]
return {"rows": rows, "stats": stats}
+30
View File
@@ -114,5 +114,35 @@
parent="yuthon_property_approval.property_approval_report_menu"
action="action_deposit_cum_arrears_report"
sequence="590"/>
<record id="action_deposit_month_refund_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_deposit_month_refund_report",
"columns": [
{"headerName": "序号", "field": "序号", "flex": 0.5},
{"headerName": "退押日期", "field": "退押日期", "flex": 1.2},
{"headerName": "合同编号", "field": "合同编号", "flex": 1.2},
{"headerName": "物业名称", "field": "物业名称", "flex": 2.5},
{"headerName": "承租方名称", "field": "承租方名称", "flex": 1.4},
{"headerName": "金额", "field": "金额", "flex": 1, "type": "number"},
{"headerName": "所属公司", "field": "所属公司", "flex": 1},
{"headerName": "管理员", "field": "管理员", "flex": 1}
]
}
}
</field>
</record>
<menuitem id="menu_deposit_month_refund_report"
name="押金本月已退"
parent="yuthon_property_approval.property_approval_report_menu"
action="action_deposit_month_refund_report"
sequence="595"/>
</data>
</odoo>
+1 -1
View File
@@ -151,7 +151,7 @@
sequence="5"
name="本月已退"
parent="yuthon_property_deposit_menu"
action="action_cumulative_arrears_report"/>
action="action_deposit_month_refund_report"/>
<menuitem id="yuthon_property_deposit_cum_total_menu"
sequence="6"
name="累计押金"