This commit is contained in:
李鹏宇
2025-10-02 18:21:15 +08:00
parent 07fc6026f4
commit 53a85da88e
14 changed files with 93 additions and 124 deletions
@@ -53,6 +53,22 @@ class SoongWorkflowRecord(models.Model):
soong_state = fields.Selection([('to_do', '待办'), ('done', '已办')], string="流程状态", default="to_do")
member_of_department = fields.Boolean("是否是本部门数据", compute='_compute_part_of_department', search='_search_part_of_department')
# 人力资源流程的发生日期
workflow_happen_date = fields.Date(string="发生日期", compute="_compute_happen_date", store=True, index=True)
@api.depends('workflow_id')
def _compute_happen_date(self):
"""
人力资源流程的发生日期
:return:
workflow_record_id = self.env["soong.workflow.record"].search(
[("res_model", "=", self._name), ("res_id", "=", self.id)])
"""
for i in self.search([]):
workflow_happen_date = False
def admin_end(self):
workflow_ids = self.env["soong.workflow.record"].browse(
self._context.get('active_ids', self._context.get('active_id', []))
@@ -57,9 +57,9 @@
<t t-if="o.is_day">
<table width="100%" style="table-layout:fixed;">
<tr>
<td width="15%"><strong>开始日期:</strong></td>
<td width="15%"><strong>开始日期</strong></td>
<td width="35%"><span t-field="o.statr_date"/></td>
<td width="15%"><strong>结束日期:</strong></td>
<td width="15%"><strong>结束日期</strong></td>
<td width="35%"><span t-field="o.end_date"/></td>
</tr>
<tr>
@@ -73,18 +73,18 @@
<t t-if="o.is_half">
<table width="100%" style="table-layout:fixed;">
<tr>
<td width="15%"><strong>开始日期:</strong></td>
<td width="15%"><strong>开始日期</strong></td>
<td width="35%"><span t-field="o.statr_date"/></td>
<td width="15%"><strong>结束日期:</strong></td>
<td width="15%"><strong>结束日期</strong></td>
<td width="35%"><span t-field="o.end_date"/></td>
</tr>
<tr>
<td width="15%"><strong>开始时段:</strong></td>
<td width="15%"><strong>开始时段</strong></td>
<td width="35%">
<span t-if="o.start_day_selection == 'half'">上半天</span>
<span t-if="o.start_day_selection == 'afternoon'">下半天</span>
</td>
<td width="15%"><strong>结束时段:</strong></td>
<td width="15%"><strong>结束时段</strong></td>
<td width="35%">
<span t-if="o.end_day_selection == 'half'">上半天</span>
<span t-if="o.end_day_selection == 'afternoon'">下半天</span>
@@ -64,14 +64,14 @@
<group>
<label for="start_time"/>
<div class="d-inline-flex w-100">
<field name="start_time" string="开始日期:" class="me-2"
<field name="start_time" string="开始日期" class="me-2"
style="max-width: 17rem !important;"/>
<field name="start_week" string=" " class="ms-2"
style="max-width: 5rem !important;"/>
</div>
<label for="end_time"/>
<div class="d-inline-flex w-100">
<field name="end_time" string="结束日期:" class="me-2"
<field name="end_time" string="结束日期" class="me-2"
style="max-width: 17rem !important;" required="1"/>
<field name="end_week" string=" " class="ms-2"
style="max-width: 5rem !important;"/>
@@ -36,14 +36,15 @@ class PropertyMeterArchives(models.Model):
state = fields.Selection([('reading', '已抄'), ('unreading', '未抄')], string='抄表状态', default='unreading')
# @api.model_create_multi 多条创建
# @api.model
# def create(self, vals):
# record = super().create(vals)
# if record.lessee_id:
# record.archives_state = 'rent'
# else:
# record.archives_state = 'use'
# return record
@api.model
def create(self, vals):
record = super().create(vals)
if 'name' in vals and vals['name']:
existing_records = self.search([('name', '=', vals['name'])])
if existing_records:
raise ValidationError(f"仪表编号 '{vals['name']}' 已存在,请使用其他编号!")
record.archives_state = 'rent' if record.lessee_id else 'use'
return record
def update_epitope_values(self):
meter_ids = self.env["property.meter.archives"].browse(
@@ -165,7 +166,7 @@ class MeterArchivesLine(models.Model):
_order = 'number asc, sequence asc'
archives_id = fields.Many2one('property.meter.archives', string='电表库', required=True, ondelete='cascade')
name = fields.Char(string='仪表编号')
# name = fields.Char(string='仪表编号')
number = fields.Integer(related='epitope_values_id.sequence', string="序号", store=True)
sequence = fields.Integer(related='archives_id.sequence1', string="表序号", store=True)
epitope_values_id = fields.Many2one('yuthon.epitope.values', string='表位置')
+11 -10
View File
@@ -34,6 +34,16 @@ class PropertyMeterWater(models.Model):
state = fields.Selection([('reading', '已抄'), ('unreading', '未抄')], string='抄表状态', default='unreading')
remarks = fields.Text(string='备注')
@api.model
def create(self, vals):
record = super().create(vals)
if 'name' in vals and vals['name']:
existing_records = self.search([('name', '=', vals['name'])])
if existing_records:
raise ValidationError(f"仪表编号 '{vals['name']}' 已存在,请使用其他编号!")
record.archives_state = 'rent' if record.lessee_id else 'use'
return record
def update_epitope_values(self):
meter_ids = self.env["property.meter.water"].browse(
self._context.get('active_ids', self._context.get('active_id')))
@@ -73,15 +83,6 @@ class PropertyMeterWater(models.Model):
else:
record.water_state = 'use'
# @api.model
# def create(self, vals):
# record = super().create(vals)
# if record.lessee_id:
# record.water_state = 'rent'
# else:
# record.water_state = 'use'
# return record
def button_water_state(self):
archives_ids = self.env["property.meter.water"].browse(
self._context.get('active_ids', self._context.get('active_id')))
@@ -128,7 +129,7 @@ class MeterWaterLine(models.Model):
_description = '水表库明细行'
_order = 'number asc, sequence asc'
name = fields.Char(string='仪表编号')
# name = fields.Char(string='仪表编号')
water_id = fields.Many2one('property.meter.water', string='水表库', required=True, ondelete='cascade')
number = fields.Integer(related='epitope_values_id.sequence', string="序号", store=True)
sequence = fields.Integer(related='water_id.sequence1', string="表序号", store=True)
@@ -57,8 +57,7 @@
<page string="抄表明细">
<field name="line_ids" string=" ">
<tree editable="bottom">
<field name="archives_id" column_invisible="1"/>
<field name="name"/>
<field name="archives_id"/>
<field name="epitope_values_id" domain="[('type', '=', 'ammeter')]"/>
<field name="lessee_id" options="{'no_create': True}"/>
<field name="yuthon_property_ids" string="物业信息" widget="many2many_tags"/>
@@ -89,11 +88,7 @@
<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" >
<!-- <header>-->
<!-- <button name="update_date" type="object" string="更新合同" class="oe_highlight"/>-->
<!-- </header>-->
<field name="sequence" column_invisible="1"/>
<field name="name" readonly="1"/>
<field name="number" column_invisible="1"/>
<field name="epitope_values_id" domain="[('type', '=', 'ammeter')]"/>
<field name="unit_number"/>
@@ -119,7 +114,6 @@
<field name="model">property.meter.archives</field>
<field name="arch" type="xml">
<search string="电表">
<field name="name"/>
<field name="yuthon_property_ids"/>
<field name="lessee_id"/>
</search>
@@ -130,11 +124,9 @@
<field name="model">meter.archives.line</field>
<field name="arch" type="xml">
<search string="电表任务">
<field name="name"/>
<field name="yuthon_property_ids"/>
<field name="lessee_id"/>
<group expand="0" string="Group By">
<filter string="仪表编号" name="group_by_name" domain="[]" context="{'group_by': 'name'}"/>
<filter string="按月" name="group_by_meter_date_month" domain="[]" context="{'group_by': 'meter_date:month'}"/>
</group>
</search>
@@ -59,8 +59,7 @@
<page string="抄表明细">
<field name="line_ids" string=" ">
<tree editable="bottom">
<field name="water_id" column_invisible="1"/>
<field name="name"/>
<field name="water_id"/>
<field name="epitope_values_id" domain="[('type', '=', 'watermeter')]"/>
<field name="lessee_id" options="{'no_create': True}"/>
<field name="yuthon_property_ids" string="物业信息" widget="many2many_tags"/>
@@ -92,11 +91,8 @@
<field name="model">meter.water.line</field>
<field name="arch" type="xml">
<tree string="水表任务" create="0" editable="bottom" js_class="custom_water_button" decoration-success="not current_read" >
<!-- <header>-->
<!-- <button name="update_date" type="object" string="更新" class="oe_highlight"/>-->
<!-- </header>-->
<field name="sequence" column_invisible="1"/>
<field name="name" readonly="1"/>
<field name="water_id"/>
<field name="number" column_invisible="1"/>
<field name="yuthon_property_ids" string="地址" readonly="1" widget="many2many_tags" />
<field name="lessee_id" options="{'no_create': True}" readonly="1"/>
@@ -131,11 +127,9 @@
<field name="model">meter.water.line</field>
<field name="arch" type="xml">
<search string="水表">
<field name="name"/>
<field name="yuthon_property_ids"/>
<field name="lessee_id"/>
<group expand="0" string="Group By">
<filter string="仪表编号" name="group_by_name" domain="[]" context="{'group_by': 'name'}"/>
<filter string="按月" name="group_by_meter_date_month" domain="[]" context="{'group_by': 'meter_date:month'}"/>
</group>
</search>
+20 -51
View File
@@ -11,53 +11,29 @@ class ElectricWaterWizard(models.TransientModel):
water_ids = fields.Many2many('property.meter.water', string='水表库')
def confirm(self):
self.ensure_one()
if not self.push_date:
raise ValidationError('请选择推送日期')
push_year = self.push_date.year
push_month = self.push_date.month
# 计算上个月的年份和月份
if push_month == 1:
last_month = 12
last_year = push_year - 1
else:
last_month = push_month - 1
last_year = push_year
# 处理电表推送
if self.meter_ids:
for meter in self.meter_ids:
# 查找上个月的记录
last_month_line = meter.line_ids.filtered(
lambda l: l.meter_date and
l.meter_date.year == last_year and
l.meter_date.month == last_month and
l.unit_number == meter.unit_number
)
existing_line = meter.line_ids.filtered(
lambda l: l.meter_date and
l.meter_date.year == push_year and
l.meter_date.month == push_month and
l.unit_number == meter.unit_number
)
if not existing_line:
# 查找上个月的记录,上次用量,上次读数,上次抄表日期
last_month_line = meter.line_ids.search([('meter_date', '<', self.push_date)]).sorted('meter_date')[-1]
# 如果当前数据不存在,则新建任务,按照天的纬度
self_month_line = meter.line_ids.search([('meter_date', '=', self.push_date)])
if not self_month_line:
meter.line_ids.create({
'archives_id': meter.id,
'name': meter.name,
'last_meter': last_month_line.last_meter,
'last_read': last_month_line.last_read,
'last_dosage': last_month_line.last_dosage,
'meter_date': self.push_date,
'epitope_values_id': meter.epitope_values_id.id,
'lessee_id': meter.lessee_id.id,
'yuthon_property_ids': [(6, 0, meter.yuthon_property_ids.ids)],
'current_meter': 0,
'unit_number': meter.unit_number,
'last_meter': last_month_line.meter_date,
'gauge_magnification': meter.gauge_magnification,
'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,
@@ -68,32 +44,25 @@ class ElectricWaterWizard(models.TransientModel):
# 处理水表推送
if self.water_ids:
for water in self.water_ids:
# 查找上个月的记录
last_month_line = water.line_ids.filtered(
lambda l: l.meter_date and
l.meter_date.year == last_year and
l.meter_date.month == last_month
)
existing_line = water.line_ids.filtered(
lambda l: l.meter_date and
l.meter_date.year == push_year and
l.meter_date.month == push_month
)
if not existing_line:
# 查找上个月的记录,上次用量,上次读数,上次抄表日期
last_month_line = water.line_ids.search([('meter_date', '<', self.push_date)]).sorted('meter_date')[-1]
# 如果当前数据不存在,则新建任务,按照天的纬度
self_month_line = water.line_ids.search([('meter_date', '=', self.push_date)])
if not self_month_line:
water.line_ids.create({
'water_id': water.id,
'name': water.name,
'last_meter': last_month_line.last_meter,
'last_read': last_month_line.last_read,
'last_dosage': last_month_line.last_dosage,
'meter_date': self.push_date,
'epitope_values_id': water.epitope_values_id.id,
'lessee_id': water.lessee_id.id,
'yuthon_property_ids': [(6, 0, water.yuthon_property_ids.ids)],
'current_meter': 0,
'unit_number': water.unit_number,
'last_meter': last_month_line.meter_date,
'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,
@@ -6,7 +6,7 @@
<field name="arch" type="xml">
<form string="电水表">
<group>
<field name="push_date"/>
<field name="push_date" required="1"/>
<field name="water_ids" invisible="1"/>
<field name="meter_ids" invisible="1"/>
</group>
@@ -86,9 +86,9 @@
<!-- 日期信息 -->
<table width="100%" style="table-layout:fixed;">
<tr>
<td width="15%"><strong>开始日期:</strong></td>
<td width="15%"><strong>开始日期</strong></td>
<td width="35%"><span t-field="o.start_date"/></td>
<td width="15%"><strong>结束日期:</strong></td>
<td width="15%"><strong>结束日期</strong></td>
<td width="35%"><span t-field="o.end_date"/></td>
</tr>
</table>
@@ -111,12 +111,12 @@
<!-- 时间信息 -->
<table width="100%" style="table-layout:fixed;">
<tr>
<td width="15%"><strong>代理开始日期:</strong></td>
<td width="15%"><strong>代理开始日期</strong></td>
<td width="35%">
<span t-if="o.start_date"><span t-field="o.start_date"/></span>
<span t-if="not o.start_date">未设置</span>
</td>
<td width="15%"><strong>代理结束日期:</strong></td>
<td width="15%"><strong>代理结束日期</strong></td>
<td width="35%">
<span t-if="o.end_date"><span t-field="o.end_date"/></span>
<span t-if="not o.end_date">未设置</span>
@@ -137,13 +137,13 @@
<t t-if="o.purchase_type == 'service'">
<table width="100%" style="table-layout:fixed;">
<tr>
<td width="15%"><strong>服务开始日期:</strong></td>
<td width="15%"><strong>服务开始日期</strong></td>
<td width="85%"><span t-field="o.service_start_date"/></td>
</tr>
</table>
<table width="100%" style="table-layout:fixed;">
<tr>
<td width="15%"><strong>服务结束日期:</strong></td>
<td width="15%"><strong>服务结束日期</strong></td>
<td width="85%"><span t-field="o.service_end_date"/></td>
</tr>
</table>
@@ -18,6 +18,7 @@ class YouthonReport extends Component {
this.serviceOrm = useService("orm")
this.state = useState({
result: null,
startDate: null,
endDate: null,
keyword: "", // 绑定的是 char 类型的数据 input 框,
@@ -83,6 +84,7 @@ class YouthonReport extends Component {
[params]
);
console.log(result)
this.state.result = result
this.grid.setGridOption('rowData',result);
}
@@ -2,7 +2,6 @@
<templates id="template" xml:space="preserve">
<t t-name="youthon_report.YouthonReport">
<div class="container-fluid d-flex flex-column h-100 mt-2 pb-3 ">
<div class="card mb-2">
<div class="row g-4">
@@ -64,14 +63,11 @@
<div class="col-4">
<label>条件</label>
<select id="formview_default_conditions" class="o_input" t-model="state.condition">
<option t-foreach="state.conditions" t-as="cond"
t-att-value="cond.value"
t-key="cond.name">
<t t-esc="cond.name"/>
</option>
<option t-foreach="state.conditions" t-as="cond"
t-att-value="cond.value"
t-key="cond.name">
<t t-esc="cond.name"/>
</option>
</select>
</div>
<!-- bool -->
@@ -105,20 +101,20 @@
<div class="row">
<div class="col-5">
<DateTimeInput
value="state.startDate"
type="'date'"
placeholder="fromPlaceholder"
onChange="(date) => this.onChangeStartDate(date)"
/>
value="state.startDate"
type="'date'"
placeholder="fromPlaceholder"
onChange="(date) => this.onChangeStartDate(date)"
/>
</div>
<div class="col-2">至</div>
<div class="col-5">
<DateTimeInput
value="state.startDate"
type="'date'"
placeholder="fromPlaceholder"
onChange="(date) => this.onChangeStartDate(date)"
/>
value="state.startDate"
type="'date'"
placeholder="fromPlaceholder"
onChange="(date) => this.onChangeStartDate(date)"
/>
</div>
</div>
</div>
@@ -167,11 +163,9 @@
<!-- ag-grid 区域 -->
<div class="row flex-grow-1">
<div class="col-12 h-100">
<div class="ag-theme-alpine w-100 h-100" t-ref="grid"></div>
<div class="ag-theme-alpine w-100 h-100" t-ref="grid"/>
</div>
</div>
</div>
</t>
</templates>