Files
gzth/yuthon_property_approval/wizard/choose_confirm_property_wizard.py
2026-03-04 15:15:07 +08:00

34 lines
1.1 KiB
Python

from odoo import models, fields, api
class ChooseConfirmPropertyWizard(models.TransientModel):
_name = 'choose.confirm.property.wizard'
_description = '成交确认选择物业'
confirm_id = fields.Many2one('property.confirm', string="成交确认")
property_ids = fields.Many2many('yuthon.property', string="物业信息")
def confirm(self):
rec = self.confirm_id
lease_ids_to_add = []
names = []
for record in self.property_ids:
lease_ids_to_add.append((0, 0, {
'confirm_id': rec.id,
'address_id': record.id,
}))
if record.name:
names.append(record.name)
existing_names = []
for line in rec.lease_ids:
if line.address_id and line.address_id.name:
existing_names.append(line.address_id.name)
rec.lease_ids = lease_ids_to_add
all_names = list(set(existing_names + names))
property_name_str = ','.join(all_names)
rec.property_name = property_name_str
rec.name = '成交确认书-' + property_name_str if property_name_str else '成交确认书'