From 8eadb00877e872455e9e324839f3fb57e0d4b85b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Wed, 1 Apr 2026 15:55:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=BC=E6=8E=A5=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/property_lease_contract.py | 32 +++++++++++++++++++ .../binding_information_wizard_views.xml | 3 +- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/yuthon_property_approval/models/property_lease_contract.py b/yuthon_property_approval/models/property_lease_contract.py index 5d69c18b9..9742b8345 100644 --- a/yuthon_property_approval/models/property_lease_contract.py +++ b/yuthon_property_approval/models/property_lease_contract.py @@ -463,6 +463,38 @@ class PropertyLeaseContract(models.Model): else: rec.display_name = False + def name_get(self): + """ + 默认保持原来的显示(各处仍然用 display_name,例如 含版本号); + 只有在 context 里带了 'show_lessor_in_contract_name' 时, + 才在后面拼接出租方公司名称,并且不带版本号: + 例如:租(2024) 86号(天河物管) + """ + # 先拿到原始 name_get 结果,保证不破坏默认行为 + names = super(PropertyLeaseContract, self).name_get() + + # 没有上下文标记 → 完全按原来返回(仍然是 租(2024) 86号(V1.0) 这种) + if not self.env.context.get('show_lessor_in_contract_name'): + return names + + name_map = dict(names) + result = [] + for rec in self: + # 这里只用合同编号,不带版本号 + # contract_code 形如 “租(2024) 86号” + base_name = rec.contract_code or name_map.get(rec.id, rec.display_name or '') + + # 出租方公司在 lessor_id 上 + lessor_name = rec.lessor_id.display_name if rec.lessor_id else False + name = base_name + if lessor_name: + # 拼成:租(2024) 86号(天河物管) + name = '%s(%s)' % (base_name, lessor_name) + + result.append((rec.id, name)) + + return result + @api.depends('payment_ids.print_date', 'payment_ids.is_print') def _compute_is_print(self): today = date.today() diff --git a/yuthon_property_approval/wizard/binding_information_wizard_views.xml b/yuthon_property_approval/wizard/binding_information_wizard_views.xml index dcd9df598..15af42517 100644 --- a/yuthon_property_approval/wizard/binding_information_wizard_views.xml +++ b/yuthon_property_approval/wizard/binding_information_wizard_views.xml @@ -12,7 +12,8 @@ - + +