From bb814e59de91a83bc52b340806f9c139cdeda9fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?=
<9664676+pengyuthon@user.noreply.gitee.com>
Date: Wed, 22 Oct 2025 18:03:01 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/property_meter_archives.py | 4 ++--
.../models/property_meter_water.py | 4 ++--
.../wizard/electric_water_wizard.py | 4 ++--
.../models/inherit_yuthon_property.py | 19 +++++++++++++++++--
.../views/inherit_yuthon_property_views.xml | 2 +-
.../wizard/property_reconciliation_wizard.py | 19 ++++++++++++++++++-
6 files changed, 42 insertions(+), 10 deletions(-)
diff --git a/yuthon_property/models/property_meter_archives.py b/yuthon_property/models/property_meter_archives.py
index b951b8047..db1dcea97 100644
--- a/yuthon_property/models/property_meter_archives.py
+++ b/yuthon_property/models/property_meter_archives.py
@@ -312,8 +312,8 @@ class MeterArchivesLine(models.Model):
i.last_meter = i.meter_date
i.current_meter = 0
- @api.constrains('current_read', 'last_read', 'maximum_count')
- def _check_reading_consistency(self):
+ @api.onchagne('current_read', 'last_read', 'maximum_count')
+ def onchange_current_meter(self):
for record in self:
if record.last_read is not None and record.current_read is not None and record.last_read > 0:
if record.current_read < record.last_read:
diff --git a/yuthon_property/models/property_meter_water.py b/yuthon_property/models/property_meter_water.py
index 287716c5d..56aab6be6 100644
--- a/yuthon_property/models/property_meter_water.py
+++ b/yuthon_property/models/property_meter_water.py
@@ -275,8 +275,8 @@ class MeterWaterLine(models.Model):
i.last_meter = i.meter_date
i.current_meter = 0
- @api.constrains('current_read', 'last_read', 'maximum_count')
- def _check_reading_consistency(self):
+ @api.onchange('current_read', 'last_read', 'maximum_count')
+ def onchange_current_meter(self):
for record in self:
if record.last_read is not None and record.current_read is not None and record.last_read > 0:
if record.current_read < record.last_read:
diff --git a/yuthon_property/wizard/electric_water_wizard.py b/yuthon_property/wizard/electric_water_wizard.py
index 4c5ddcfd1..491dc786e 100644
--- a/yuthon_property/wizard/electric_water_wizard.py
+++ b/yuthon_property/wizard/electric_water_wizard.py
@@ -52,7 +52,7 @@ class ElectricWaterWizard(models.TransientModel):
'type': meter.type,
'archives_state': meter.archives_state,
'maximum_count': meter.maximum_count,
- 'contract_id': contract_line.lease_id if contract_line else False,
+ 'contract_id': contract_line.lease_id.id if contract_line and contract_line.lease_id else False,
})
# 处理水表推送
@@ -93,5 +93,5 @@ class ElectricWaterWizard(models.TransientModel):
'type': water.type,
'water_state': water.water_state,
'maximum_count': water.maximum_count,
- 'contract_id': contract_line.lease_id if contract_line else False,
+ 'contract_id': contract_line.lease_id.id if contract_line and contract_line.lease_id else False,
})
diff --git a/yuthon_property_approval/models/inherit_yuthon_property.py b/yuthon_property_approval/models/inherit_yuthon_property.py
index f43e07579..b7e8ccc62 100644
--- a/yuthon_property_approval/models/inherit_yuthon_property.py
+++ b/yuthon_property_approval/models/inherit_yuthon_property.py
@@ -157,8 +157,6 @@ class PropertyBankStatements(models.Model):
record.admin_id = record.contract_ids[0].admin_id.id if record.contract_ids[0].admin_id else False
record.lessee_ids = [(6, 0, list(lessee_set))] if lessee_set else [(5, 0, 0)]
-
-
def update_property_name(self):
property_ids = self.env["property.bank.statements"].browse(
self._context.get('active_ids', self._context.get('active_id')))
@@ -230,6 +228,23 @@ class PropertyBankStatements(models.Model):
self.no_amount = self.original_amount
self.yes_amount = 0
self.reconciliation_time = None
+ self._filter_contracts_based_on_receivables()
+
+ def _filter_contracts_based_on_receivables(self):
+ """筛选合同:仅保留存在未对账应收单的合同"""
+ for stmt in self:
+ if not stmt.contract_ids:
+ continue
+ remaining_contract_ids = []
+ for contract in stmt.contract_ids:
+ unreconciled_receivables = self.env["property.accounts.receivable"].search([
+ ('contract_id', '=', contract.id),
+ ('is_reconciliation', '=', False),
+ ], limit=1)
+ if unreconciled_receivables:
+ remaining_contract_ids.append(contract.id)
+ if remaining_contract_ids != stmt.contract_ids.ids:
+ stmt.contract_ids = [(6, 0, remaining_contract_ids)]
def binding_information(self):
return {
diff --git a/yuthon_property_approval/views/inherit_yuthon_property_views.xml b/yuthon_property_approval/views/inherit_yuthon_property_views.xml
index e3fccab5c..1dd346850 100644
--- a/yuthon_property_approval/views/inherit_yuthon_property_views.xml
+++ b/yuthon_property_approval/views/inherit_yuthon_property_views.xml
@@ -627,7 +627,7 @@
-
+
diff --git a/yuthon_property_approval/wizard/property_reconciliation_wizard.py b/yuthon_property_approval/wizard/property_reconciliation_wizard.py
index 4c844f47a..4b25eefc2 100644
--- a/yuthon_property_approval/wizard/property_reconciliation_wizard.py
+++ b/yuthon_property_approval/wizard/property_reconciliation_wizard.py
@@ -30,7 +30,7 @@ class PropertyReconciliationWizard(models.Model):
for rec in self:
rec.amount_reconciled = rec.actual_total - rec.amount_been_reconciled - sum(line.amount for line in rec.reconciliation_line_ids)
for line in rec.reconciliation_line_ids:
- if line.rent_month == line.amount:
+ if line.rent_month == line.amount and line.collection_type == 'rent':
line.remake = str(rec.actual_date) + '补' + str(line.due_date)
@api.depends('reconciliation_line_ids')
@@ -483,6 +483,23 @@ class PropertyReconciliationWizard(models.Model):
rec.bank_id.no_amount = amount_reconciled
+ # 更新流水的合同信息
+ remaining_contract_ids = []
+ for contract in self.bank_id.contract_ids:
+ unreconciled_receivables = self.env["property.accounts.receivable"].search([
+ ('contract_id', '=', contract.id),
+ ('is_reconciliation', '=', False),
+ ], limit=1)
+
+ # 核心逻辑:存在未对账应收单 → 保留合同;否则 → 移除
+ if unreconciled_receivables:
+ remaining_contract_ids.append(contract.id)
+
+ bank_ids = self.env["property.bank.statements"].search([('name', '=', self.bank_id.name)])
+ for rec in bank_ids:
+ if remaining_contract_ids != rec.contract_ids.ids:
+ rec.contract_ids = [(6, 0, remaining_contract_ids)]
+
class PropertyReconciliationLine(models.Model):
_name = 'property.reconciliation.line'