From 428d3205eb57f0045d1d9d890e1b2eea487bdff5 Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Fri, 3 Jan 2025 15:21:57 +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_meter_archives.py | 8 ++- .../models/property_meter_water.py | 9 +++- yuthon_property/models/yuthon_property.py | 53 ++++++++++++++----- yuthon_property/security/ir.model.access.csv | 2 + .../views/yuthon_property_views.xml | 33 ++++++++++-- .../models/property_lease_contract.py | 13 +++-- 6 files changed, 94 insertions(+), 24 deletions(-) diff --git a/yuthon_property/models/property_meter_archives.py b/yuthon_property/models/property_meter_archives.py index 8f371e52d..fec268b7f 100644 --- a/yuthon_property/models/property_meter_archives.py +++ b/yuthon_property/models/property_meter_archives.py @@ -43,5 +43,11 @@ class PropertyMeterArchives(models.Model): @api.onchange('yuthon_property_id') def _onchange_property(self): if self.yuthon_property_id: + meter_list = [] property_id = self.env['yuthon.property'].search([('id', '=', self.yuthon_property_id.id)]) - property_id.property_archives_id = self.id.origin + property_id.is_message_fee = True + meter_list.append((0, 0, { + 'yuthon_property_id':property_id.id, + 'property_meter_water_id':self.id.origin, + })) + property_id.water_meter_ids = meter_list diff --git a/yuthon_property/models/property_meter_water.py b/yuthon_property/models/property_meter_water.py index b430d1db9..9e4c5aa2f 100644 --- a/yuthon_property/models/property_meter_water.py +++ b/yuthon_property/models/property_meter_water.py @@ -42,6 +42,13 @@ class PropertyMeterWater(models.Model): @api.onchange('yuthon_property_id') def _onchange_property(self): if self.yuthon_property_id: + meter_list = [] property_id = self.env['yuthon.property'].search([('id', '=', self.yuthon_property_id.id)]) - property_id.property_water_id = self.id.origin + property_id.is_message_fee = True + meter_list.append((0, 0, { + 'yuthon_property_id': property_id.id, + 'property_meter_archives_id': self.id.origin, + })) + property_id.energy_meter_ids = meter_list + diff --git a/yuthon_property/models/yuthon_property.py b/yuthon_property/models/yuthon_property.py index 7e552271b..6b3770bad 100644 --- a/yuthon_property/models/yuthon_property.py +++ b/yuthon_property/models/yuthon_property.py @@ -50,9 +50,8 @@ class YuthonProperty(models.Model): property_use_id = fields.Integer(string="物业用途ID") image_1920 = fields.Image(string="图片") description = fields.Html(string="描述") - message_standard_id = fields.Many2one('property.message.fee', string="管理费") - property_archives_id = fields.Many2one('property.meter.archives', string="电表库") - property_water_id = fields.Many2one('property.meter.water', string="水表库") + is_message_fee = fields.Boolean(string="管理费") + message_standard_id = fields.Many2one('property.message.fee', string="管理费标准") rental_unit_price = fields.Float(string="评估单价") title_number = fields.Char(string="产权编号") suite_area = fields.Float(string="套内面积", digits=(16, 4)) @@ -71,6 +70,8 @@ class YuthonProperty(models.Model): equity_area = fields.Float(string="产权面积", group_operator=None, digits=(16, 4)) decoration_type = fields.Selection([('blank', '毛坯'), ('hardcover', '精装'), ('brands', '简装'), ('rsz', '豪装')], string="装修类型") + water_meter_ids = fields.One2many('yuthon.property.water', 'yuthon_property_id', string='水表列表') + energy_meter_ids = fields.One2many('yuthon.property.energy', 'yuthon_property_id', string='电表列表') title_information_ids = fields.One2many('title.information.line', 'yuthon_property_id', string='关联产权信息明细行') manage_information_ids = fields.One2many('manage.information.line', 'yuthon_property_id', string='关联管理信息明细行') @@ -91,17 +92,19 @@ class YuthonProperty(models.Model): 'company_id':latest_record_id.company_id.id, }) - @api.onchange('property_archives_id') - def _onchange_property_archives_id(self): - for rec in self: - meter_id = self.env['property.meter.archives'].search([('id', '=', rec.property_archives_id.id)]) - meter_id.yuthon_property_id = self.id.origin + @api.onchange('energy_meter_ids') + def _onchange_energy_meter_ids(self): + for rec in self.energy_meter_ids: + meter_id = self.env['property.meter.archives'].search([('id', '=', rec.property_meter_archives_id.id)]) + meter_id.yuthon_property_id.write({ + 'yuthon_property_id': self.id}) - @api.onchange('property_water_id') + @api.onchange('water_meter_ids') def _onchange_property_water_id(self): - for rec in self: - water_id = self.env['property.meter.water'].search([('id', '=', rec.property_water_id.id)]) - water_id.yuthon_property_id = self.id.origin + for rec in self.water_meter_ids: + water_id = self.env['property.meter.water'].search([('id', '=', rec.property_meter_water_id.id)]) + water_id.yuthon_property_id.write({ + 'yuthon_property_id': self.id}) @api.onchange('building_area') def _onchange_building_area(self): @@ -271,6 +274,32 @@ class YuthonProperty(models.Model): "target": "new", } +class YuthonPropertyWater(models.Model): + _name = 'yuthon.property.water' + _description = '水表' + + property_meter_water_id = fields.Many2one('property.meter.water', string="水表库") + rate = fields.Float(related='property_meter_water_id.gauge_magnification', string="倍率") + standard_id = fields.Many2one(related='property_meter_water_id.standards_id', string="标准") + installation_date = fields.Date(related='property_meter_water_id.start_time', string="安装日期") + demolition_date = fields.Date(related='property_meter_water_id.end_time', string="拆除日期") + location = fields.Char(related='property_meter_water_id.installation_location', string="位置") + yuthon_property_id = fields.Many2one('yuthon.property', string="物业管理") + + +class YuthonPropertyEnergy(models.Model): + _name = 'yuthon.property.energy' + _description = '电表' + + property_meter_archives_id = fields.Many2one('property.meter.archives', string="电表库") + rate = fields.Float(related='property_meter_archives_id.gauge_magnification', string="倍率") + standard_id = fields.Many2one(related='property_meter_archives_id.standards_id', string="标准") + installation_date = fields.Date(related='property_meter_archives_id.start_time', string="安装日期") + demolition_date = fields.Date(related='property_meter_archives_id.end_time', string="拆除日期") + location = fields.Char(related='property_meter_archives_id.installation_location', string="位置") + yuthon_property_id = fields.Many2one('yuthon.property', string="物业管理") + + class TitleInformationLine(models.Model): _name = 'title.information.line' _description = '产权信息明细行' diff --git a/yuthon_property/security/ir.model.access.csv b/yuthon_property/security/ir.model.access.csv index 814679767..d3d421be9 100644 --- a/yuthon_property/security/ir.model.access.csv +++ b/yuthon_property/security/ir.model.access.csv @@ -7,6 +7,8 @@ access_property_patrol_position,property_patrol_position,model_property_patrol_p access_property_patrol_standard,property_patrol_standard,model_property_patrol_standard,base.group_user,1,1,1,1 access_yuthon_draw_result,yuthon_draw_result,model_yuthon_draw_result,base.group_user,1,1,1,1 access_yuthon_expert_database,yuthon_expert_database,model_yuthon_expert_database,base.group_user,1,1,1,1 +access_yuthon_property_water,yuthon_property_water,model_yuthon_property_water,base.group_user,1,1,1,1 +access_yuthon_property_energy,yuthon_property_energy,model_yuthon_property_energy,base.group_user,1,1,1,1 access_yuthon_resource_type,yuthon_resource_type,model_yuthon_resource_type,base.group_user,1,1,1,1 access_yuthon_resource_house_type,yuthon_resource_house_type,model_yuthon_resource_house_type,base.group_user,1,1,1,1 access_yuthon_resource_purpose,yuthon_resource_purpose,model_yuthon_resource_purpose,base.group_user,1,1,1,1 diff --git a/yuthon_property/views/yuthon_property_views.xml b/yuthon_property/views/yuthon_property_views.xml index 3bd6b8054..e2cea7cab 100644 --- a/yuthon_property/views/yuthon_property_views.xml +++ b/yuthon_property/views/yuthon_property_views.xml @@ -87,13 +87,14 @@ - + - + - + + @@ -163,6 +164,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/yuthon_property_approval/models/property_lease_contract.py b/yuthon_property_approval/models/property_lease_contract.py index 80b27975f..6b53ad469 100644 --- a/yuthon_property_approval/models/property_lease_contract.py +++ b/yuthon_property_approval/models/property_lease_contract.py @@ -458,19 +458,18 @@ class PropertyLeaseContract(models.Model): for record in rec.lease_ids: if record.address_id: lease_name.append(record.address_id.name) - rec.name = ','.join(lease_name) property_id = self.env['yuthon.property'].search([('id', '=', record.address_id.id)]) - meter_id = property_id.property_archives_id - if meter_id: + if property_id.energy_meter_ids: rec.is_electricity = True - electricity_list.append([0, 0, { - 'fees_id': meter_id.standards_id.id, - 'proportional':meter_id.gauge_magnification, + for electricity_id in property_id.energy_meter_ids: + electricity_list.append([0, 0, { + 'fees_id': property_id.electricity_id.id, + 'proportional':electricity_id.rate, }]) else: rec.is_electricity = False - if property_id.message_standard_id: + if property_id.is_message_fee: rec.is_mange = True standard_id = property_id.message_standard_id fee_list.append([0, 0, {