添加功能

This commit is contained in:
李鹏宇
2025-09-22 09:58:06 +08:00
parent 599019c4db
commit f9bb16cdb3
7 changed files with 19 additions and 82 deletions
@@ -744,8 +744,8 @@ class AppletAttendance(Controller):
_logger.info("----------------/yuthon/meter/reading---------接口收到请求-------------------------------")
# 获取需要推送的电表和水表记录
electric_records = request.env(user=SUPERUSER_ID)['property.meter.archives'].search([('is_push', '=', True), ('archives_state', '=', 'use'), ('current_read', '=', 0)])
water_records = request.env(user=SUPERUSER_ID)['property.meter.water'].search([('is_push', '=', True), ('water_state', '=', 'use'), ('current_read', '=', 0)])
electric_records = request.env(user=SUPERUSER_ID)['meter.archives.line'].search([('archives_state', '=', 'use'), ('current_read', '=', 0)])
water_records = request.env(user=SUPERUSER_ID)['meter.water.line'].search([('water_state', '=', 'use'), ('current_read', '=', 0)])
all_records = []
@@ -31,6 +31,7 @@ class ResourceCalendar(models.Model):
# store=True, index=True, string="哺乳期人员")
breastfeeding_holiday_ids = fields.One2many('breastfeeding.holiday', 'resource_calendar_id', string='哺乳假明细')
def get_baidu_holiday(self):
"""
通过百度日历接口获取法定节假日信息
@@ -117,8 +118,8 @@ class BreastfeedingHolidaye(models.Model):
resource_calendar_id = fields.Many2one('resource.calendar')
employee_id = fields.Many2one('hr.employee', string="员工")
breastfeeding_type = fields.Selection([('1', '上午'), ('2', '下午')], string="类型")
calendar_start_time = fields.Datetime(string="假期开始时间")
calendar_end_time = fields.Datetime(string="假期结束时间")
calendar_start_time = fields.Date(string="假期开始时间")
calendar_end_time = fields.Date(string="假期结束时间")
class ResourceCalendarHolidaye(models.Model):
_name = "resource.calendar.holiday"
@@ -26,11 +26,11 @@
<button name="get_baidu_holiday" string="更新法定节假日" type="object"/>
<field name="holiday_data_lines" invisible="1"/>
<field name="calendar_holiday_ids">
<tree>
<tree editable="bottom">
<field name="resource_calendar_id" column_invisible="1"/>
<field name="holiday_type"/>
<field name="calendar_start_time"/>
<field name="calendar_end_time"/>
<field name="holiday_type"/>
</tree>
</field>
</page>
@@ -18,20 +18,12 @@ class PropertyMeterArchives(models.Model):
employee_ids = fields.Many2many('hr.employee', string='抄表人')
epitope_values = fields.Char(string='表位置')
other = fields.Char(string='其他')
meter_date = fields.Date(string='任务日期')
last_dosage = fields.Float(string='上次用量')
last_read = fields.Float(string='上次读数')
last_meter = fields.Date(string='上次抄表日期')
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')
is_push = fields.Boolean(string='已推送')
start_time = fields.Date(string="安装日期")
end_time = fields.Date(string="拆除日期")
line_loss = fields.Float(string="线损", default=0.02)
receivables = fields.Float(string="应收", compute='_compute_receivables', store=True)
last_reading_time = fields.Date(string="最后读数时间")
standards_id = fields.Many2one('yuthon.electricity.setting', string='标准')
yuthon_property_ids = fields.Many2many('yuthon.property', string='物业信息')
line_ids = fields.One2many('meter.archives.line', 'archives_id', string='明细行')
@@ -45,11 +37,6 @@ class PropertyMeterArchives(models.Model):
else:
record.lessee_id = False
@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
def format_update(self):
insurances_ids = self.env["property.meter.archives"].browse(
@@ -202,10 +189,14 @@ class MeterArchivesLine(models.Model):
@api.depends('current_read', 'last_read')
def _compute_current_meter(self):
for record in self:
if record.current_read and record.last_read:
if record.current_read > record.last_read:
record.current_meter = record.current_read - record.last_read
else:
record.current_meter = 0
if record.maximum_count > 0:
max_value = 10 ** record.maximum_count - 1
record.current_meter = max_value - record.last_read + record.current_read
else:
record.current_meter = 0
@api.depends('yuthon_property_ids')
def _compute_lessee_id(self):
+6 -29
View File
@@ -17,18 +17,11 @@ class PropertyMeterWater(models.Model):
employee_ids = fields.Many2many('hr.employee', string='抄表人')
epitope_values = fields.Char(string='表位置')
other = fields.Char(string='其他')
meter_date = fields.Date(string='任务日期')
last_dosage = fields.Float(string='上次用量')
last_read = fields.Float(string='上次读数')
last_meter = fields.Date(string='上次抄表日期')
unit = fields.Float(string='当月单价')
current_meter = fields.Float(string='本次用量', tracking=True)
current_read = fields.Float(string='本次读数', tracking=True)
is_push = fields.Boolean(string='已推送')
start_time = fields.Date(string="安装日期")
end_time = fields.Date(string="拆除日期")
line_loss = fields.Float(string="线损", default=0.05)
receivables = fields.Float(string="应收", compute='_compute_receivables', store=True)
last_reading_time = fields.Date(string="最后读数时间")
water_state = fields.Selection([('stop', '停用'), ('use', '使用'), ('rent', '出租')], string='状态', compute='_compute_water_state', store=True)
standards_id = fields.Many2one('yuthon.electricity.setting', string='标准')
@@ -52,13 +45,6 @@ class PropertyMeterWater(models.Model):
else:
record.lessee_id = False
@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
@api.depends('lessee_id')
def _compute_water_state(self):
for record in self:
@@ -90,19 +76,6 @@ class PropertyMeterWater(models.Model):
else:
record.water_state = 'use'
@api.onchange('current_read', 'last_read')
def _onchange_current_meter(self):
for record in self:
if record.current_read > record.last_read:
record.current_meter = record.current_read - record.last_read
else:
if record.maximum_count > 0:
max_value = 10 ** record.maximum_count - 1
record.current_meter = max_value - record.last_read + record.current_read
else:
record.current_meter = 0
@api.onchange('yuthon_property_ids')
def _onchange_property(self):
if self.yuthon_property_ids:
@@ -180,10 +153,14 @@ class MeterWaterLine(models.Model):
@api.depends('current_read', 'last_read')
def _compute_current_meter(self):
for record in self:
if record.current_read and record.last_read:
if record.current_read > record.last_read:
record.current_meter = record.current_read - record.last_read
else:
record.current_meter = 0
if record.maximum_count > 0:
max_value = 10 ** record.maximum_count - 1
record.current_meter = max_value - record.last_read + record.current_read
else:
record.current_meter = 0
@api.depends('yuthon_property_ids')
def _compute_lessee_id(self):
@@ -14,15 +14,8 @@
<field name="epitope_values"/>
<field name="lessee_id" options="{'no_create': True}"/>
<field name="yuthon_property_ids" string="物业信息" widget="many2many_tags"/>
<!-- <field name="meter_date" />-->
<!-- <field name="last_meter" />-->
<!-- <field name="last_dosage"/>-->
<!-- <field name="last_read" readonly="1"/>-->
<!-- <field name="current_meter" readonly="1"/>-->
<!-- <field name="current_read"/>-->
<field name="unit_number"/>
<field name="gauge_magnification" readonly="1"/>
<!-- <field name="last_reading_time"/>-->
<field name="type"/>
<field name="start_time"/>
<field name="end_time"/>
@@ -58,12 +51,6 @@
<field name="yuthon_property_ids" string="物业信息" widget="many2many_tags"/>
</group>
<group>
<!-- <field name="last_meter"/>-->
<!-- <field name="last_dosage"/>-->
<!-- <field name="last_read" readonly="1"/>-->
<!-- <field name="current_meter" readonly="1"/>-->
<!-- <field name="current_read"/>-->
<!-- <field name="last_reading_time"/>-->
<field name="start_time"/>
<field name="end_time"/>
<field name="archives_state"/>
@@ -139,9 +126,6 @@
<field name="name"/>
<field name="yuthon_property_ids"/>
<field name="lessee_id"/>
<group expand="0" string="Group By">
<filter string="按月" name="group_by_meter_date_month" domain="[]" context="{'group_by': 'meter_date:month'}"/>
</group>
</search>
</field>
</record>
@@ -15,15 +15,8 @@
<field name="epitope_values"/>
<field name="lessee_id" options="{'no_create': True}"/>
<field name="yuthon_property_ids" string="物业信息" widget="many2many_tags"/>
<!-- <field name="meter_date" />-->
<!-- <field name="last_meter" />-->
<!-- <field name="last_dosage"/>-->
<!-- <field name="last_read" readonly="1"/>-->
<!-- <field name="current_meter" readonly="1"/>-->
<!-- <field name="current_read"/>-->
<field name="unit_number"/>
<field name="gauge_magnification" readonly="1"/>
<!-- <field name="last_reading_time"/>-->
<field name="type"/>
<field name="start_time"/>
<field name="end_time"/>
@@ -61,12 +54,6 @@
<field name="yuthon_property_ids" string="物业信息" widget="many2many_tags"/>
</group>
<group>
<!-- <field name="last_meter"/>-->
<!-- <field name="last_dosage"/>-->
<!-- <field name="last_read" readonly="1"/>-->
<!-- <field name="current_meter" readonly="1"/>-->
<!-- <field name="current_read"/>-->
<!-- <field name="last_reading_time"/>-->
<field name="start_time"/>
<field name="end_time"/>
<field name="water_state"/>
@@ -140,9 +127,6 @@
<field name="name"/>
<field name="yuthon_property_ids"/>
<field name="lessee_id"/>
<group expand="0" string="Group By">
<filter string="按月" name="group_by_meter_date_month" domain="[]" context="{'group_by': 'meter_date:month'}"/>
</group>
</search>
</field>
</record>