diff --git a/yuthon_property/models/property_meter_archives.py b/yuthon_property/models/property_meter_archives.py index 13027e4a8..333c7ce09 100644 --- a/yuthon_property/models/property_meter_archives.py +++ b/yuthon_property/models/property_meter_archives.py @@ -310,8 +310,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 f0e0e83cc..17368941d 100644 --- a/yuthon_property/models/property_meter_water.py +++ b/yuthon_property/models/property_meter_water.py @@ -285,8 +285,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 @@