修改badge
This commit is contained in:
@@ -752,6 +752,12 @@ class AppletAttendance(Controller):
|
||||
|
||||
all_records = []
|
||||
|
||||
# 接口调整, 电表,水表数据拆分.
|
||||
# 先根据状态,再根据楼层
|
||||
|
||||
# 电表数据
|
||||
electric_result_dict = {}
|
||||
|
||||
# 处理电表
|
||||
for electric in electric_records:
|
||||
property_infos = electric.yuthon_property_ids if electric.yuthon_property_ids else [None]
|
||||
@@ -769,8 +775,8 @@ class AppletAttendance(Controller):
|
||||
room = ''
|
||||
address = ''
|
||||
employee_name = ''
|
||||
|
||||
all_records.append({
|
||||
state = electric.state
|
||||
electric_value = {
|
||||
'code': electric.name or '',
|
||||
'last_dosage': electric.last_dosage or 0,
|
||||
'mater_data': str(electric.meter_date) if electric.meter_date else '',
|
||||
@@ -783,8 +789,31 @@ class AppletAttendance(Controller):
|
||||
'room': room,
|
||||
'epitope_values':electric.epitope_values,
|
||||
'unit_number':electric.unit_number,
|
||||
})
|
||||
'state': electric.state, # 状态 reading unreading
|
||||
}
|
||||
|
||||
electric_result_dict.setdefault(state, {}).setdefault(building,{}).setdefault(floor, []).append(electric_value)
|
||||
|
||||
electric_result = []
|
||||
for state, building_dict in electric_result_dict.items():
|
||||
building_list = []
|
||||
for building, floor_dict in building_dict.items():
|
||||
floor_list = []
|
||||
for floor, data_list in floor_dict.items():
|
||||
floor_list.append({
|
||||
'floor': floor,
|
||||
'data_list': data_list
|
||||
})
|
||||
building_list.append({
|
||||
'building': building,
|
||||
'floor_list': floor_list
|
||||
})
|
||||
electric_result.append({
|
||||
'state': state,
|
||||
'building_list': building_list
|
||||
})
|
||||
|
||||
water_result_dict = {}
|
||||
# 处理水表
|
||||
for water in water_records:
|
||||
property_infos = water.yuthon_property_ids if water.yuthon_property_ids else [None]
|
||||
@@ -803,8 +832,8 @@ class AppletAttendance(Controller):
|
||||
room = ''
|
||||
address = ''
|
||||
employee_name = ''
|
||||
|
||||
all_records.append({
|
||||
state = water.state
|
||||
water_value = {
|
||||
'code': water.name or '',
|
||||
'last_dosage': water.last_dosage or 0,
|
||||
'mater_data': str(water.meter_date) if water.meter_date else '',
|
||||
@@ -816,37 +845,74 @@ class AppletAttendance(Controller):
|
||||
'floor': floor,
|
||||
'room': room,
|
||||
'epitope_values':water.epitope_values,
|
||||
'unit_number':water.unit_number
|
||||
'unit_number':water.unit_number,
|
||||
'state': water.state, # 状态 reading unreading
|
||||
}
|
||||
water_result_dict.setdefault(state, {}).setdefault(building,{}).setdefault(floor, []).append(water_value)
|
||||
|
||||
water_result = []
|
||||
for state, building_dict in water_result_dict.items():
|
||||
building_list = []
|
||||
for building, floor_dict in building_dict.items():
|
||||
floor_list = []
|
||||
for floor, data_list in floor_dict.items():
|
||||
floor_list.append({
|
||||
'floor': floor,
|
||||
'data_list': data_list
|
||||
})
|
||||
building_list.append({
|
||||
'building': building,
|
||||
'floor_list': floor_list
|
||||
})
|
||||
water_result.append({
|
||||
'state': state,
|
||||
'building_list': building_list
|
||||
})
|
||||
|
||||
# 按“楼盘->楼层”分组
|
||||
building_floor_map = {}
|
||||
for record in all_records:
|
||||
building_name = record['building']
|
||||
floor_name = record['epitope_values']
|
||||
# building_floor_map = {}
|
||||
# for record in all_records:
|
||||
# building_name = record['building']
|
||||
# state = record['state']
|
||||
# floor_name = record['epitope_values']
|
||||
#
|
||||
# # 初始化楼盘分组(空楼盘名也作为有效分组)
|
||||
# if building_name not in building_floor_map:
|
||||
# building_floor_map[building_name] = {}
|
||||
#
|
||||
# # 初始化状态分组
|
||||
# if state not in building_floor_map[building_name]:
|
||||
# building_floor_map[building_name][state] = {}
|
||||
#
|
||||
# # 初始化楼层分组(空楼层名也作为有效分组)
|
||||
# if floor_name not in building_floor_map[building_name]:
|
||||
# building_floor_map[building_name][state][floor_name] = []
|
||||
#
|
||||
# # 移除building和floor字段,只保留数据项
|
||||
# record_data = {k: v for k, v in record.items() if k not in ['building', 'epitope_values']}
|
||||
# building_floor_map[building_name][state][floor_name].append(record_data)
|
||||
#
|
||||
# # 组装最终返回结构
|
||||
# table_list = []
|
||||
# # for building, floor_dict in building_floor_map.items():
|
||||
# # floor_list = [
|
||||
# # {'floor': floor, 'data_list': data_list}
|
||||
# # for floor, data_list in floor_dict.items()
|
||||
# # ]
|
||||
# # table_list.append({'building': building, 'floor_list': floor_list})
|
||||
#
|
||||
# # 三层结构组装
|
||||
# for building, state_dict in building_floor_map.items():
|
||||
# state_list = [
|
||||
# {'state': state, 'floor_list': [{'floor': floor, 'data_list': data_list} for floor, data_list in floor_dict.items()]}
|
||||
# for state, floor_dict in state_dict.items()
|
||||
# ]
|
||||
# table_list.append({'building': building, 'state_list': state_list})
|
||||
|
||||
# 初始化楼盘分组(空楼盘名也作为有效分组)
|
||||
if building_name not in building_floor_map:
|
||||
building_floor_map[building_name] = {}
|
||||
|
||||
# 初始化楼层分组(空楼层名也作为有效分组)
|
||||
if floor_name not in building_floor_map[building_name]:
|
||||
building_floor_map[building_name][floor_name] = []
|
||||
|
||||
# 移除building和floor字段,只保留数据项
|
||||
record_data = {k: v for k, v in record.items() if k not in ['building', 'epitope_values']}
|
||||
building_floor_map[building_name][floor_name].append(record_data)
|
||||
|
||||
# 组装最终返回结构
|
||||
table_list = []
|
||||
for building, floor_dict in building_floor_map.items():
|
||||
floor_list = [
|
||||
{'floor': floor, 'data_list': data_list}
|
||||
for floor, data_list in floor_dict.items()
|
||||
]
|
||||
table_list.append({'building': building, 'floor_list': floor_list})
|
||||
|
||||
return json.dumps(table_list)
|
||||
return json.dumps({
|
||||
'electric': electric_result,
|
||||
'water': water_result,
|
||||
})
|
||||
|
||||
@route('/yuthon/meter/dosage', methods=['POST'], type='http', auth='none', cors='*', csrf=False)
|
||||
def yuthon_meter_dosage(self, **kw):
|
||||
|
||||
@@ -3,6 +3,7 @@ from email.policy import default
|
||||
from odoo import models, fields, api
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
|
||||
|
||||
class PropertyMeterArchives(models.Model):
|
||||
_name = 'property.meter.archives'
|
||||
_description = '电表库'
|
||||
@@ -14,7 +15,8 @@ class PropertyMeterArchives(models.Model):
|
||||
type = fields.Selection([('public', '公共'), ('fees', '收费')], string='类型')
|
||||
gauge_magnification = fields.Integer(string='仪表倍率', default=1)
|
||||
maximum_count = fields.Integer(string='最大位数')
|
||||
lessee_id = fields.Many2one('property.tenant.information', string='承租方', store=True, compute='_compute_lessee_id')
|
||||
lessee_id = fields.Many2one('property.tenant.information', string='承租方', store=True,
|
||||
compute='_compute_lessee_id')
|
||||
employee_ids = fields.Many2many('hr.employee', string='抄表人')
|
||||
epitope_values = fields.Char(string='表位置')
|
||||
other = fields.Char(string='其他')
|
||||
@@ -25,7 +27,8 @@ class PropertyMeterArchives(models.Model):
|
||||
current_meter = fields.Float(string='本次用量', tracking=True)
|
||||
current_read = fields.Float(string='本次读数', tracking=True)
|
||||
unit = fields.Float(string='当月单价')
|
||||
archives_state = fields.Selection([('stop', '停用'), ('use', '正常'), ('rent', '出租')], string='状态', compute='_compute_archives_state', store=True, default='use')
|
||||
archives_state = fields.Selection([('stop', '停用'), ('use', '正常'), ('rent', '出租')], string='状态',
|
||||
compute='_compute_archives_state', store=True, default='use')
|
||||
is_push = fields.Boolean(string='已推送')
|
||||
start_time = fields.Date(string="安装日期")
|
||||
end_time = fields.Date(string="拆除日期")
|
||||
@@ -36,6 +39,7 @@ class PropertyMeterArchives(models.Model):
|
||||
yuthon_property_ids = fields.Many2many('yuthon.property', string='物业信息')
|
||||
line_ids = fields.One2many('meter.archives.line', 'archives_id', string='明细行')
|
||||
remarks = fields.Text(string='备注')
|
||||
state = fields.Selection([('unreading', '未抄'), ('reding', '已抄')], string='状态', default='unreading')
|
||||
|
||||
@api.depends('yuthon_property_ids')
|
||||
def _compute_lessee_id(self):
|
||||
@@ -49,11 +53,12 @@ class PropertyMeterArchives(models.Model):
|
||||
def _compute_receivables(self):
|
||||
for record in self:
|
||||
if record.line_loss and record.current_meter and record.unit:
|
||||
record.receivables = record.current_meter * record.unit * (1 + record.line_loss) * record.gauge_magnification
|
||||
record.receivables = record.current_meter * record.unit * (
|
||||
1 + record.line_loss) * record.gauge_magnification
|
||||
|
||||
def format_update(self):
|
||||
insurances_ids = self.env["property.meter.archives"].browse(
|
||||
self._context.get('active_ids', self._context.get('active_id')))
|
||||
self._context.get('active_ids', self._context.get('active_id')))
|
||||
for record in insurances_ids:
|
||||
value = record.unit_number
|
||||
if isinstance(value, str) and value.replace('.', '', 1).isdigit():
|
||||
@@ -88,12 +93,14 @@ class PropertyMeterArchives(models.Model):
|
||||
return record
|
||||
|
||||
def button_archives_state(self):
|
||||
archives_ids = self.env["property.meter.archives"].browse(self._context.get('active_ids', self._context.get('active_id')))
|
||||
archives_ids = self.env["property.meter.archives"].browse(
|
||||
self._context.get('active_ids', self._context.get('active_id')))
|
||||
for record in archives_ids:
|
||||
record.archives_state = 'stop'
|
||||
|
||||
def update_meter(self):
|
||||
meter_ids = self.env["property.meter.archives"].browse(self._context.get('active_ids', self._context.get('active_id')))
|
||||
meter_ids = self.env["property.meter.archives"].browse(
|
||||
self._context.get('active_ids', self._context.get('active_id')))
|
||||
for record in meter_ids:
|
||||
if record.lessee_id:
|
||||
record.archives_state = 'rent'
|
||||
@@ -136,7 +143,8 @@ class PropertyMeterArchives(models.Model):
|
||||
|
||||
def reading_publish(self):
|
||||
menu_id = self.env['ir.ui.menu'].search([('name', '=', '水表抄表')])
|
||||
reading_ids = self.env["property.meter.archives"].browse(self._context.get('active_ids', self._context.get('active_id')))
|
||||
reading_ids = self.env["property.meter.archives"].browse(
|
||||
self._context.get('active_ids', self._context.get('active_id')))
|
||||
for record in reading_ids:
|
||||
for employee_id in record.employee_ids:
|
||||
url = f'https://oa.thtzjt.com/web#id={self.id}&cids=2&action={menu_id.action.id}&model=property.meter.archives&view_type=list&menu_id={menu_id.id}'
|
||||
@@ -191,13 +199,15 @@ class MeterArchivesLine(models.Model):
|
||||
archives_state = fields.Selection([('stop', '停用'), ('use', '正常'), ('rent', '出租')], string='状态',
|
||||
default='use')
|
||||
maximum_count = fields.Integer(string='最大位数')
|
||||
# 状态,已抄 未抄
|
||||
state = fields.Selection([('reading', '已抄'), ('unreading', '未抄')], string='抄表状态', default='unreading')
|
||||
|
||||
@api.depends('line_loss', 'current_meter', 'unit')
|
||||
def _compute_receivables(self):
|
||||
for record in self:
|
||||
if record.line_loss and record.current_meter and record.unit:
|
||||
record.receivables = record.current_meter * record.unit * (
|
||||
1 + record.line_loss) * record.gauge_magnification
|
||||
1 + record.line_loss) * record.gauge_magnification
|
||||
|
||||
@api.depends('current_read', 'last_read')
|
||||
def _compute_current_meter(self):
|
||||
@@ -245,6 +255,7 @@ class MeterArchivesLine(models.Model):
|
||||
if record.last_meter:
|
||||
record.meter_date = record.last_meter
|
||||
|
||||
|
||||
class PropertyElectricReading(models.Model):
|
||||
_name = 'property.electric.reading'
|
||||
current_meter = fields.Float(string='本次用量', tracking=True)
|
||||
|
||||
@@ -34,6 +34,7 @@ class PropertyMeterWater(models.Model):
|
||||
standards_id = fields.Many2one('yuthon.electricity.setting', string='标准')
|
||||
yuthon_property_ids = fields.Many2many('yuthon.property', string='物业信息')
|
||||
line_ids = fields.One2many('meter.water.line', 'water_id', string='水表明细行')
|
||||
state = fields.Selection([('reading', '已抄'), ('unreading', '未抄')], string='抄表状态', default='unreading')
|
||||
remarks = fields.Text(string='备注')
|
||||
|
||||
def open_record(self):
|
||||
|
||||
@@ -106,13 +106,12 @@
|
||||
<field name="name">meter.archives.line.tree</field>
|
||||
<field name="model">meter.archives.line</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="电表任务" create="False" editable="bottom" js_class="custom_meter_button"
|
||||
decoration-success="not current_read">
|
||||
<tree string="电表任务" create="False" editable="bottom" js_class="custom_meter_button" decoration-success="not current_read" >
|
||||
<header>
|
||||
<button name="update_date" type="object" string="更新日期" dclass="oe_highlight"/>
|
||||
<button name="update_date" type="object" string="更新日期" class="oe_highlight"/>
|
||||
</header>
|
||||
<field name="name" readonly="1"/>
|
||||
<field name="epitope_values"/>
|
||||
<field name="epitope_values"/>
|
||||
<field name="unit_number"/>
|
||||
<field name="yuthon_property_ids" string="地址" readonly="1" widget="many2many_tags"/>
|
||||
<field name="lessee_id" options="{'no_create': True}" readonly="1"/>
|
||||
|
||||
@@ -110,13 +110,12 @@
|
||||
<field name="name">meter.water.line.tree</field>
|
||||
<field name="model">meter.water.line</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="水表任务" create="False" editable="bottom" js_clasee="custom_water_button"
|
||||
decoration-success="not current_read">
|
||||
<tree string="水表任务" create="0" editable="bottom" js_class="custom_water_button" decoration-success="not current_read" >
|
||||
<header>
|
||||
<button name="update_date" type="object" string="更新日期" dclass="oe_highlight"/>
|
||||
<button name="update_date" type="object" string="更新日期" class="oe_highlight"/>
|
||||
</header>
|
||||
<field name="name" readonly="1"/>
|
||||
<field name="yuthon_property_ids" string="地址" readonly="1" widget="many2many_tags"/>
|
||||
<field name="yuthon_property_ids" string="地址" readonly="1" widget="many2many_tags" />
|
||||
<field name="lessee_id" options="{'no_create': True}" readonly="1"/>
|
||||
<field name="meter_date" readonly="1"/>
|
||||
<field name="gauge_magnification" readonly="1"/>
|
||||
|
||||
@@ -673,7 +673,7 @@
|
||||
name="个人基础信息"
|
||||
parent="basic_information_board"
|
||||
sequence="1"
|
||||
action="yuthon_hr_employee.action_server_my_employee"/>
|
||||
action="yuthon_hr_employee.action_server_my_employee" />
|
||||
|
||||
<menuitem id="password_reset_board"
|
||||
name="重置密码"
|
||||
|
||||
Reference in New Issue
Block a user