From ace3a49011e573ba0a5786fe144d4402b422bbf6 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: Sun, 28 Sep 2025 17:29:37 +0800 Subject: [PATCH 1/2] =?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/property_meter_archives.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/yuthon_property/models/property_meter_archives.py b/yuthon_property/models/property_meter_archives.py index 95f75c64f..981211487 100644 --- a/yuthon_property/models/property_meter_archives.py +++ b/yuthon_property/models/property_meter_archives.py @@ -168,7 +168,7 @@ class MeterArchivesLine(models.Model): yuthon_property_ids = fields.Many2many('yuthon.property', string='物业信息') last_meter = fields.Date(string='上次抄表日期') last_dosage = fields.Float(string='上次用量', compute="compute_meter_values") - last_read = fields.Float(string='上次读数') + last_read = fields.Float(string='上次读数', compute="compute_meter_values") meter_date = fields.Date(string='任务日期') current_meter = fields.Float(string='本次用量', compute='compute_meter_values') current_read = fields.Float(string='本次读数') @@ -238,10 +238,13 @@ class MeterArchivesLine(models.Model): idx = lines.ids.index(line.id) if idx > 0: prev_line = lines[idx - 1] - line.last_dosage = (prev_line.current_read or 0) - (prev_line.last_read or 0) + line.last_dosage = prev_line.current_meter + line.last_read = prev_line.current_read else: + line.last_read = 0 line.last_dosage = 0.0 else: + line.last_read = 0 line.last_dosage = 0.0 @api.onchange('yuthon_property_ids') From bffa95d571088dcd1b3260cb792db92cbc1a181c 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: Sun, 28 Sep 2025 17:38:19 +0800 Subject: [PATCH 2/2] =?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 | 2 -- .../models/property_meter_water.py | 17 +++++++----- .../wizard/electric_water_wizard.py | 26 +++++++++---------- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/yuthon_property/models/property_meter_archives.py b/yuthon_property/models/property_meter_archives.py index 981211487..a0efd56c9 100644 --- a/yuthon_property/models/property_meter_archives.py +++ b/yuthon_property/models/property_meter_archives.py @@ -183,7 +183,6 @@ class MeterArchivesLine(models.Model): end_time = fields.Date(string="拆除日期") employee_ids = fields.Many2many('hr.employee', string='抄表人') remarks = fields.Text(string='备注') - is_push = fields.Boolean(string='已推送') archives_state = fields.Selection([('stop', '停用'), ('use', '正常'), ('rent', '出租')], string='状态', default='use') state = fields.Selection([('reading', '已抄'), ('unreading', '未抄')], string='抄表状态', default='unreading') @@ -212,7 +211,6 @@ class MeterArchivesLine(models.Model): 'state': 'reading' }) - @api.depends('current_read', 'last_read', 'meter_date', 'maximum_count', 'archives_id') def compute_meter_values(self): """合并计算当前用量和上次用量""" diff --git a/yuthon_property/models/property_meter_water.py b/yuthon_property/models/property_meter_water.py index 6bba9baa0..4d19d94a2 100644 --- a/yuthon_property/models/property_meter_water.py +++ b/yuthon_property/models/property_meter_water.py @@ -187,13 +187,15 @@ class MeterWaterLine(models.Model): def compute_meter_values(self): """合并计算当前用量和上次用量""" for line in self: - # 计算当前用量 (原 _compute_current_meter 逻辑) - if line.current_read > line.last_read: + if line.current_read >= line.last_read: line.current_meter = line.current_read - line.last_read else: - if line.maximum_count > 0: - max_value = 10 ** line.maximum_count - 1 - line.current_meter = max_value - line.last_read + line.current_read + if line.current_read != 0: + if line.maximum_count > 0: + max_value = 10 ** line.maximum_count - 1 + line.current_meter = max_value - line.last_read + line.current_read + else: + line.current_meter = 0 else: line.current_meter = 0 @@ -206,10 +208,13 @@ class MeterWaterLine(models.Model): idx = lines.ids.index(line.id) if idx > 0: prev_line = lines[idx - 1] - line.last_dosage = (prev_line.current_read or 0) - (prev_line.last_read or 0) + line.last_dosage = prev_line.current_meter + line.last_read = prev_line.current_read else: + line.last_read = 0 line.last_dosage = 0.0 else: + line.last_read = 0 line.last_dosage = 0.0 @api.onchange('yuthon_property_ids') diff --git a/yuthon_property/wizard/electric_water_wizard.py b/yuthon_property/wizard/electric_water_wizard.py index 83e501218..63ed84e5b 100644 --- a/yuthon_property/wizard/electric_water_wizard.py +++ b/yuthon_property/wizard/electric_water_wizard.py @@ -46,29 +46,23 @@ class ElectricWaterWizard(models.TransientModel): ) if not existing_line: - last_read = last_month_line.current_read if last_month_line else 0 - last_dosage = last_month_line.current_meter if last_month_line else 0 - meter.line_ids.create({ 'archives_id': meter.id, 'name': meter.name, 'epitope_values': meter.epitope_values, 'lessee_id': meter.lessee_id.id, 'yuthon_property_ids': [(6, 0, meter.yuthon_property_ids.ids)], - 'last_read': last_read, - 'last_dosage': last_dosage, 'current_meter': 0, 'unit_number': meter.unit_number, 'last_meter': last_month_line.meter_date, 'gauge_magnification': meter.gauge_magnification, - 'last_reading_time': self.push_date, + 'last_reading_time': last_month_line.meter_date, 'meter_date': self.push_date, 'type': meter.type, 'start_time': meter.start_time, 'end_time': meter.end_time, 'archives_state': meter.archives_state, 'maximum_count': meter.maximum_count, - 'is_push': True }) # 处理水表推送 @@ -88,17 +82,21 @@ class ElectricWaterWizard(models.TransientModel): ) if not existing_line: - last_read = last_month_line.current_read if last_month_line else 0 - last_dosage = last_month_line.current_meter if last_month_line else 0 - water.line_ids.create({ 'water_id': water.id, 'name': water.name, + 'epitope_values': water.epitope_values, 'lessee_id': water.lessee_id.id, - 'last_read': last_read, - 'last_dosage': last_dosage, + 'yuthon_property_ids': [(6, 0, water.yuthon_property_ids.ids)], 'current_meter': 0, - 'meter_date': self.push_date, + 'unit_number': water.unit_number, 'last_meter': last_month_line.meter_date, - 'is_push': True + 'gauge_magnification': water.gauge_magnification, + 'last_reading_time': last_month_line.meter_date, + 'meter_date': self.push_date, + 'type': water.type, + 'start_time': water.start_time, + 'end_time': water.end_time, + 'archives_state': water.archives_state, + 'maximum_count': water.maximum_count, })