From ab4eac55ec9f8b3113b457af2dd7b84fe368dce3 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: Fri, 31 Oct 2025 17:08:52 +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 | 33 +++++++++++++++---- .../views/yuthon_property_views.xml | 12 +++---- .../wizard/property_reconciliation_wizard.py | 2 +- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/yuthon_property/models/yuthon_property.py b/yuthon_property/models/yuthon_property.py index e1e4f9448..1047cffe3 100644 --- a/yuthon_property/models/yuthon_property.py +++ b/yuthon_property/models/yuthon_property.py @@ -579,12 +579,24 @@ class YuthonPropertyWater(models.Model): property_meter_water_id = fields.Many2one('property.meter.water', string="水表库") rate = fields.Integer(related='property_meter_water_id.gauge_magnification', string="倍率", store=True) - standard_id = fields.Many2one(related='property_meter_water_id.standards_id', string="标准", store=True) - installation_date = fields.Date(related='property_meter_water_id.start_time', string="安装日期") - demolition_date = fields.Date(related='property_meter_water_id.end_time', string="拆除日期") + unit_number = fields.Integer(related='property_meter_water_id.unit_number', string="单元编号/用途") + start_date = fields.Date(string="开始日期") + end_date = fields.Date(string="结束日期") epitope_values_id = fields.Many2one(related='property_meter_water_id.epitope_values_id', string="位置") yuthon_property_id = fields.Many2one('yuthon.property', string="物业管理") + @api.depends('property_meter_water_id') + def _compute_date(self): + for record in self: + if record.property_meter_water_id.yuthon_property_ids: + contract_id = record.env['property.lease.contract.line'].search( + [('address_id', '=', record.property_meter_water_id.yuthon_property_ids[0].id), + ('lease_id.contact_state', '=', 'ing')]) + if contract_id: + record.start_date = contract_id[0].term_start_time + record.end_date = contract_id[0].term_end_time + + # 水表跳转 def detail(self): return { @@ -612,12 +624,21 @@ class YuthonPropertyEnergy(models.Model): property_meter_archives_id = fields.Many2one('property.meter.archives', string="电表编号") rate = fields.Integer(related='property_meter_archives_id.gauge_magnification', string="倍率", store=True) - standard_id = fields.Many2one(related='property_meter_archives_id.standards_id', string="标准", store=True) - installation_date = fields.Date(related='property_meter_archives_id.start_time', string="安装日期") - demolition_date = fields.Date(related='property_meter_archives_id.end_time', string="拆除日期") + unit_number = fields.Integer(related='property_meter_archives_id.unit_number', string="单元编号/用途") + start_date = fields.Date(string="开始日期", compute='_compute_date') + end_date = fields.Date(string="结束日期", compute='_compute_date') epitope_values_id = fields.Many2one(related='property_meter_archives_id.epitope_values_id', string="位置") yuthon_property_id = fields.Many2one('yuthon.property', string="物业管理") + @api.depends('property_meter_archives_id') + def _compute_date(self): + for record in self: + if record.property_meter_water_id.yuthon_property_ids: + contract_id = record.env['property.lease.contract.line'].search([('address_id', '=', record.property_meter_archives_id.yuthon_property_ids[0].id), ('lease_id.contact_state', '=', 'ing')]) + if contract_id: + record.start_date = contract_id[0].term_start_time + record.end_date = contract_id[0].term_end_time + # 电表跳转 def detail(self): return { diff --git a/yuthon_property/views/yuthon_property_views.xml b/yuthon_property/views/yuthon_property_views.xml index 160d341ba..33c9516c8 100644 --- a/yuthon_property/views/yuthon_property_views.xml +++ b/yuthon_property/views/yuthon_property_views.xml @@ -248,9 +248,9 @@ - - - + + +