!10480 !10479 Merge branch 'dev' of <a href="https://gitee.com/jinan-pengyuse…

Merge pull request !10480 from 李鹏宇/dev
This commit is contained in:
李鹏宇
2026-04-01 07:58:03 +00:00
committed by Gitee
2 changed files with 34 additions and 1 deletions
@@ -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()
@@ -12,7 +12,8 @@
<field name="available_contract_ids" widget="many2many_tags"/>
<field name="your_own_unit" invisible="1"/>
<field name="property_ids" widget="many2many_tags" options="{'no_create': True}"/>
<field name="contract_ids" widget="many2many_tags" domain="[('is_split', '=', False), ('id', 'not in', available_contract_ids)]" options="{'no_create': True}"/>
<field name="contract_ids" widget="many2many_tags" domain="[('is_split', '=', False), ('id', 'not in', available_contract_ids)]" options="{'no_create': True}" context="{'show_lessor_in_contract_name': True}"/>
</group>
</sheet>
<footer>