From 407d2ad9eefcbe1873dd07ce5d3f6390ad857502 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: Tue, 28 Oct 2025 09:30:14 +0800 Subject: [PATCH 1/2] =?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/inherit_yuthon_property.py | 18 +++++++++++++++--- .../models/property_lease_contract.py | 1 + .../wizard/property_reconciliation_wizard.py | 4 ++-- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/yuthon_property_approval/models/inherit_yuthon_property.py b/yuthon_property_approval/models/inherit_yuthon_property.py index 6bc2db38e..2918850c0 100644 --- a/yuthon_property_approval/models/inherit_yuthon_property.py +++ b/yuthon_property_approval/models/inherit_yuthon_property.py @@ -128,10 +128,22 @@ class YuthonProperty(models.Model): def update_lessee_id(self): property_ids = self.env["yuthon.property"].browse( - self._context.get('active_ids', self._context.get('active_id'))) + self._context.get('active_ids', [self._context.get('active_id')]) + ) + current_date = date.today() for rec in property_ids: - if rec.property_contract_ids: - rec.lessee_id = rec.property_contract_ids[-1].lessee_id + valid_contracts = rec.property_contract_ids.filtered(lambda c: + isinstance(c.start_time, + date) and c.start_time <= current_date and + (not c.end_date or (isinstance(c.end_date, + date) and c.end_date > current_date)) + ) + + if valid_contracts: + latest_contract = valid_contracts.sorted(key=lambda c: c.start_time, reverse=True)[0] + rec.lessee_id = latest_contract.lessee_id + else: + rec.lessee_id = False @api.onchange('property_contract_ids') def _onchange_property_contract_ids(self): diff --git a/yuthon_property_approval/models/property_lease_contract.py b/yuthon_property_approval/models/property_lease_contract.py index 98882dbaf..5f9d9e968 100644 --- a/yuthon_property_approval/models/property_lease_contract.py +++ b/yuthon_property_approval/models/property_lease_contract.py @@ -62,6 +62,7 @@ class PropertyContractLine(models.Model): }) + class PropertyTenantLine(models.Model): _name = 'property.tenant.line' _description = '物业承租方合同明细行' diff --git a/yuthon_property_approval/wizard/property_reconciliation_wizard.py b/yuthon_property_approval/wizard/property_reconciliation_wizard.py index 9bcd576d0..d2719cd12 100644 --- a/yuthon_property_approval/wizard/property_reconciliation_wizard.py +++ b/yuthon_property_approval/wizard/property_reconciliation_wizard.py @@ -45,7 +45,7 @@ class PropertyReconciliationWizard(models.Model): rec.amount_reconciled = max(rec.bank_id.no_amount - sum(line.amount for line in rec.reconciliation_line_ids), 0) for line in rec.reconciliation_line_ids: if line.amount and line.collection_type != 'penalty': - if (line.due_date.month >= rec.actual_date.month and line.due_date.year == line.due_date.year) or (line.due_date.year > rec.actual_date.year): + if (line.due_date.month >= rec.actual_date.month and line.due_date.year == line.due_date.year) or (line.due_date.year < rec.actual_date.year): if line.rent >= line.amount: due_date_str = fields.Date.to_date(line.due_date).strftime('%Y-%m') line.remake = f'补{due_date_str},欠{round(line.rent - line.amount, 2)}' @@ -55,7 +55,7 @@ class PropertyReconciliationWizard(models.Model): due_date_str = fields.Date.to_date(line.due_date).strftime('%Y-%m') line.remake = f'交{due_date_str},欠{round(line.rent - line.amount, 2)}' - if (line.due_date.month < rec.actual_date.month and line.due_date.year == line.due_date.year) or (line.due_date.year < rec.actual_date.year): + if (line.due_date.month < rec.actual_date.month and line.due_date.year == line.due_date.year) or (line.due_date.year > rec.actual_date.year): if line.rent >= line.amount: due_date_str = fields.Date.to_date(line.due_date).strftime('%Y-%m') line.remake = str(rec.actual_date) + '预' + str(due_date_str) + ',欠' + str(round(line.rent - line.amount, 2)) From 3d939cdbd188a440e0050147e7e854f21f74f729 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: Tue, 28 Oct 2025 09:32:52 +0800 Subject: [PATCH 2/2] =?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 --- .../wizard/property_reconciliation_wizard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yuthon_property_approval/wizard/property_reconciliation_wizard.py b/yuthon_property_approval/wizard/property_reconciliation_wizard.py index d2719cd12..017ca0803 100644 --- a/yuthon_property_approval/wizard/property_reconciliation_wizard.py +++ b/yuthon_property_approval/wizard/property_reconciliation_wizard.py @@ -45,7 +45,7 @@ class PropertyReconciliationWizard(models.Model): rec.amount_reconciled = max(rec.bank_id.no_amount - sum(line.amount for line in rec.reconciliation_line_ids), 0) for line in rec.reconciliation_line_ids: if line.amount and line.collection_type != 'penalty': - if (line.due_date.month >= rec.actual_date.month and line.due_date.year == line.due_date.year) or (line.due_date.year < rec.actual_date.year): + if (line.due_date.month > rec.actual_date.month and line.due_date.year == line.due_date.year) or (line.due_date.year < rec.actual_date.year): if line.rent >= line.amount: due_date_str = fields.Date.to_date(line.due_date).strftime('%Y-%m') line.remake = f'补{due_date_str},欠{round(line.rent - line.amount, 2)}'