From 9333c123911eaa0a1ea6a24df4734e9d28d5783b 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: Thu, 16 Apr 2026 18:50:22 +0800 Subject: [PATCH] =?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/property_approval.py | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/yuthon_property_approval/models/property_approval.py b/yuthon_property_approval/models/property_approval.py index 785441026..d8a204c6e 100644 --- a/yuthon_property_approval/models/property_approval.py +++ b/yuthon_property_approval/models/property_approval.py @@ -63,10 +63,11 @@ class PropertyApproval(models.Model): 'approval_date': fields.Datetime.now(), }) - # 审批触发按钮 def button_property_approval(self): for massage_id in self.property_massage_ids: - property_message_id = self.env['yuthon.property.message'].search([('name', '=', massage_id.property_address)]) + property_message_id = self.env['yuthon.property.message'].search([ + ('name', '=', massage_id.property_address) + ], limit=1) if not property_message_id: property_message_id = self.env['yuthon.property.message'].create({ 'name': massage_id.property_address, @@ -75,14 +76,26 @@ class PropertyApproval(models.Model): 'title_certificate': massage_id.title_number, 'registered_id': massage_id.registered_id.id, }) - property_id = self.env['yuthon.property'].create({ - 'name': massage_id.property_address, - 'is_confirm_authorization': massage_id.is_affirmation, - }) - self.env['title.information.line'].create({ - 'yuthon_property_id': property_id.id, - 'property_message_id': property_message_id.id, - }) + property_id = self.env['yuthon.property'].search([ + ('name', '=', massage_id.property_address) + ], limit=1) + + if not property_id: + property_id = self.env['yuthon.property'].create({ + 'name': massage_id.property_address, + 'is_new': True, + 'is_confirm_authorization': massage_id.is_affirmation, + }) + + line_exists = self.env['title.information.line'].search([ + ('yuthon_property_id', '=', property_id.id), + ('property_message_id', '=', property_message_id.id), + ], limit=1) + if not line_exists: + self.env['title.information.line'].create({ + 'yuthon_property_id': property_id.id, + 'property_message_id': property_message_id.id, + }) class PropertyApprovalLine(models.Model): _name = 'property.approval.line'