49 lines
2.2 KiB
Python
49 lines
2.2 KiB
Python
import datetime
|
|
|
|
from odoo import fields, models, api
|
|
|
|
|
|
class PropertyAccountsReceivable(models.Model):
|
|
_inherit = 'property.accounts.receivable'
|
|
_description = '收款信息表'
|
|
|
|
@api.model
|
|
def get_receipt_ledger_report(self, params):
|
|
domain = [('is_reconciliation', '=', True)]
|
|
if params.get("date_start"):
|
|
date_start = datetime.datetime.fromisoformat(params.get("date_start")).date()
|
|
domain.append(("due_date", ">=", date_start))
|
|
if params.get(" "):
|
|
date_end = datetime.datetime.fromisoformat(params.get("date_end")).date()
|
|
domain.append(("due_date", "<=", date_end))
|
|
|
|
if params.get("precinct_id"):
|
|
domain.append(("precinct_id", "=", params.get("precinct_id")))
|
|
|
|
if params.get("company_id"):
|
|
domain.append(("company_id", "=", params.get("company_id")))
|
|
|
|
if params.get("condition"):
|
|
domain.append(('tenure_type', '=', params.get("condition")))
|
|
|
|
receivables = self.search(domain, limit=1000)
|
|
|
|
return [
|
|
{
|
|
"收款日期": rec.payout_date.strftime("%Y-%m-%d") if rec.payout_date else "",
|
|
"合同编号": rec.contract_id.contract_code or "" if rec.contract_id else "",
|
|
"物业名称": {
|
|
'model': 'yuthon.property',
|
|
'id': rec.contract_id.lease_ids[0].address_id.id,
|
|
'display_name': rec.property_name,
|
|
} if rec.contract_id and rec.contract_id.lease_ids and rec.contract_id.lease_ids[0].address_id else rec.property_name or "",
|
|
"承租方": rec.lessee_id.name or "" if rec.lessee_id else "",
|
|
"收款类型": rec.management_type_id.name or "" if rec.management_type_id else "",
|
|
"金额": rec.original_amount or 0.0,
|
|
"应收金额": round((rec.original_amount or 0.0) - (rec.discount_amount or 0.0), 2),
|
|
"备注": rec.remark or "",
|
|
"所属公司": rec.company_id.referred or "" if rec.company_id else "",
|
|
"管理员": rec.admin_id.name or "" if rec.admin_id else ""
|
|
}
|
|
for rec in receivables
|
|
] |