From 058f3daf9192b35cce4a4cdd23150e320f5c0ff4 Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Thu, 2 Jan 2025 19:56:50 +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 --- yuthon_property/models/yuthon_property.py | 3 +- .../models/yuthon_property_message.py | 1 + .../views/yuthon_property_message_views.xml | 1 + .../wizard/yuthon_property_wizard.py | 43 ++++++++++++++++++- 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/yuthon_property/models/yuthon_property.py b/yuthon_property/models/yuthon_property.py index bfaa7bd78..387bd1684 100644 --- a/yuthon_property/models/yuthon_property.py +++ b/yuthon_property/models/yuthon_property.py @@ -92,7 +92,6 @@ class YuthonProperty(models.Model): rec.write({ 'management_area':latest_record_id.management_area, 'rent_area': latest_record_id.rent_area, - 'equity_area':latest_record_id.equity_area, 'admin_id':latest_record_id.admin_id.id }) @@ -307,7 +306,7 @@ class TitleInformationLine(models.Model): yuthon_property_id = fields.Many2one('yuthon.property', string="关联物业信息") property_message_id = fields.Many2one('yuthon.property.message', string='产权地址') owner_id = fields.Many2one(related='property_message_id.owner_id', string="权属人") - equity_area = fields.Float(string="产权面积", digits=(16, 4)) + equity_area = fields.Float(related='property_message_id.equity_area', string="产权面积", digits=(16, 4)) title_certificate = fields.Char(related='property_message_id.title_certificate', string="产权证号") start_time = fields.Date(string="生效日期", default=fields.Date.today) end_date = fields.Date(string="失效日期") diff --git a/yuthon_property/models/yuthon_property_message.py b/yuthon_property/models/yuthon_property_message.py index e1e046bef..d63eea638 100644 --- a/yuthon_property/models/yuthon_property_message.py +++ b/yuthon_property/models/yuthon_property_message.py @@ -9,5 +9,6 @@ class YuthonPropertyMessage(models.Model): name = fields.Char(string='产权地址') owner_id = fields.Many2one('yuthon.owner.message', string="权属人") title_certificate = fields.Char(string="产权证号") + equity_area = fields.Float(string="产权面积", digits=(16, 4)) documents_ids = fields.Many2many('ir.attachment', string="附件") diff --git a/yuthon_property/views/yuthon_property_message_views.xml b/yuthon_property/views/yuthon_property_message_views.xml index 1725a717d..2f5930409 100644 --- a/yuthon_property/views/yuthon_property_message_views.xml +++ b/yuthon_property/views/yuthon_property_message_views.xml @@ -8,6 +8,7 @@ + diff --git a/yuthon_property/wizard/yuthon_property_wizard.py b/yuthon_property/wizard/yuthon_property_wizard.py index a26e5a024..750c27554 100644 --- a/yuthon_property/wizard/yuthon_property_wizard.py +++ b/yuthon_property/wizard/yuthon_property_wizard.py @@ -24,7 +24,7 @@ class YuthonPropertyWizard(models.Model): sh = book.sheet_by_index(0) for rx in range(1, sh.nrows): row = sh.row(rx) - self.yuthon_property_data(row) + self.yuthon_property_update(row) def yuthon_property_data(self,row): property_name = row[2].value @@ -130,3 +130,44 @@ class YuthonPropertyWizard(models.Model): 'property_message_id': property_message_id.id, })) property_id.title_information_ids = information_list + + def yuthon_property_update(self,row): + property_message_id = self.env['yuthon.property.message'].search([('name', '=', row[0].value)]) + + equity_area = row[5].value + property_id = self.env['yuthon.property'].search([('name', '=', row[1].value)]) + company_id = self.env['yuthon.property.company'].search([('name', '=', row[2].value)]) + if not company_id: + company_id = self.env['yuthon.property.company'].create({ + 'name': row[2].value, + }) + tenure_type_dict = {'自有': 'self', '代管': 'agency', '': ''} + tenure_type = tenure_type_dict.get(row[3].value, '') + admin_id = self.env['res.users'].search([('name', '=', row[4].value)]) + management_area = row[6].value + rent_area = row[7].value + precinct_id = self.env['yuthon.precinct.message'].search([('name', '=', row[8].value)]) + if property_id: + management_list = [] + management_list.append((0, 0, { + 'yuthon_property_id':property_id.id, + 'company_id':company_id.id, + 'tenure_type':tenure_type, + 'management_area':management_area, + 'rent_area':rent_area, + 'admin_id':admin_id.id, + 'precinct_id':precinct_id.id, + })) + property_id.manage_information_ids = management_list + + if property_message_id: + property_message_id.write({ + 'equity_area': equity_area + }) + information_list = [] + information_list.append((0, 0, { + 'yuthon_property_id': property_id.id, + 'property_message_id': property_message_id.id, + })) + property_id.title_information_ids = information_list +