急件标识,报表

This commit is contained in:
李鹏宇
2026-01-26 17:49:31 +08:00
parent 165d70f3ab
commit d991a351a6
9 changed files with 122 additions and 37 deletions
+3
View File
@@ -47,8 +47,11 @@
'web.assets_backend': [
'soong_workflow/static/src/css/record_scss.scss',
'soong_workflow/static/src/css/button_css.scss',
'soong_workflow/static/src/css/urgency_level.scss',
'soong_workflow/static/src/js/view_button.js',
'soong_workflow/static/src/js/select_create_dialog.js',
'soong_workflow/static/src/js/urgency_level_widget.js',
'soong_workflow/static/src/js/urgency_level_widget.xml',
'soong_workflow/static/src/diagram_plus_dialog/*',
],
},
@@ -79,12 +79,33 @@ class SoongWorkflowRecord(models.Model):
)
priority = fields.Selection([('0', 'Normal'), ('1', 'Urgent')], 'Priority', default='0', index=True)
urgency_level = fields.Selection(
[('normal', '普件'), ('urgent', '急件'), ('emergency', '特急件')],
string='紧急度',
compute='_compute_urgency_level',
store=False
)
is_company = fields.Boolean(string="本公司", default=True, compute='_compute_is_company',search='_search_part_of_company')
# 办结时间(上一节点的结束时间)
node_update_time = fields.Datetime(string="办结时间")
@api.depends('res_model', 'res_id')
def _compute_urgency_level(self):
"""从关联的业务模型中获取urgency_level值"""
for record in self:
record.urgency_level = 'normal' # 默认值
if record.res_model and record.res_id:
try:
target_record = self.env[record.res_model].browse(record.res_id)
if target_record.exists() and hasattr(target_record, 'urgency_level'):
record.urgency_level = target_record.urgency_level or 'normal'
except Exception as e:
_logger.warning(f"Failed to get urgency_level from {record.res_model}: {e}")
record.urgency_level = 'normal'
@api.depends_context('uid', 'company')
@api.depends('company_id')
def _compute_is_company(self):
@@ -241,7 +241,8 @@
<button name="action_update_history_end_time" type="object" string="一键补全办结时间" class="oe_highlight"
groups="soong_workflow.group_soong_workflow_manager"/>
</header>
<field name="priority" optional="show" widget="priority" nolabel="1"/>
<field name="urgency_level" column_invisible="1"/>
<field name="urgency_level" widget="urgency_level_badge" nolabel="1" optional="show"/>
<field name="code"/>
<field name="workflow_id" string="审批类型"/>
<field name="name"/>
@@ -281,7 +282,8 @@
<button name="action_update_history_end_time" type="object" string="一键补全办结时间" class="oe_highlight"
groups="soong_workflow.group_soong_workflow_manager"/>
</header>
<field name="priority" optional="show" widget="priority" nolabel="1"/>
<field name="urgency_level" column_invisible="1"/>
<field name="urgency_level" widget="urgency_level_badge" nolabel="1" optional="show"/>
<field name="code"/>
<field name="workflow_id" string="审批类型"/>
<field name="name"/>
@@ -339,7 +341,8 @@
<button name="action_update_history_end_time" type="object" string="一键补全办结时间" class="oe_highlight"
groups="soong_workflow.group_soong_workflow_manager"/>
</header>
<field name="priority" optional="show" widget="priority" nolabel="1"/>
<field name="urgency_level" column_invisible="1"/>
<field name="urgency_level" widget="urgency_level_badge" nolabel="1" optional="show"/>
<field name="code"/>
<field name="workflow_id" string="审批类型"/>
<field name="name"/>
@@ -571,7 +571,7 @@
<field name="name">vacation.over.line.overtime.tree</field>
<field name="model">vacation.over.line</field>
<field name="arch" type="xml">
<tree string="加班情况" editable="bottom">
<tree string="加班明细" editable="bottom">
<field name="overtime_name"/>
<field name="employee_id"/>
<field name="department_id"/>
@@ -9,7 +9,7 @@ class CurrentReceivableRentReport(models.Model):
@api.model
def get_current_receivable_rent_report(self, params):
"""
当期应收-租金:
当期应收:
- 过滤应收日期区间
- 默认管理类型包含“租”,可通过 management_type_id 精确指定
- 含税金额:original_amount
@@ -50,32 +50,39 @@ class CurrentReceivableRentReport(models.Model):
if management_type_id:
domain.append(('management_type_id', '=', management_type_id))
else:
rent_types = self.env['yuthon.management.type'].search([('name', 'ilike', '租')])
if rent_types:
domain.append(('management_type_id', 'in', rent_types.ids))
# 删除默认过滤,显示所有类型
receivables = self.search(domain, limit=3000, order="due_date asc")
receivables = self.search(domain, order="due_date asc")
rows = []
total_amount = 0.0
total_amount_nt = 0.0
# 按管理类型分组统计
type_totals = {} # {'管理类型名称': {'amount': 0, 'amount_nt': 0}}
for idx, rec in enumerate(receivables, start=1):
amt = rec.original_amount or 0.0
discount = rec.discount_amount or 0.0
# 实际应收 = 原始金额 - 减免金额
actual_amt = amt - discount
tax_rate = rec.tax or 0.0
amt_nt = amt / (1 + tax_rate / 100) if tax_rate else amt
total_amount += amt
total_amount_nt += amt_nt
actual_amt_nt = actual_amt / (1 + tax_rate / 100) if tax_rate else actual_amt
# 统计每个管理类型的合计
type_name = rec.management_type_id.name if rec.management_type_id else "未分类"
if type_name not in type_totals:
type_totals[type_name] = {'amount': 0.0, 'amount_nt': 0.0}
type_totals[type_name]['amount'] += actual_amt
type_totals[type_name]['amount_nt'] += actual_amt_nt
rows.append({
"序号": idx,
"应收开始": rec.due_date.strftime("%Y-%m-%d") if rec.due_date else "",
"应收结束": rec.due_date_end.strftime("%Y-%m-%d") if rec.due_date_end else "",
"承租方名称": rec.lessee_id.name if rec.lessee_id else "",
"金额(含税)": round(amt, 2),
"原始金额": round(amt, 2),
"减免金额": round(discount, 2) if discount else "",
"实际金额(含税)": round(actual_amt, 2),
"税率": tax_rate,
"金额(不含税)": round(amt_nt, 2),
"实际金额(不含税)": round(actual_amt_nt, 2),
"物业名称": rec.property_name or "",
"产权证": rec.title_deed or "",
"合同编号": rec.contract_id.contract_code if rec.contract_id else "",
@@ -83,21 +90,40 @@ class CurrentReceivableRentReport(models.Model):
"acc_type": rec.acc_type if rec.acc_type else False,
})
# 返回字典格式,包含数据行和合计行
# 构造合计数据:将各分类合计作为独立的统计数据返回
summary_stats = []
total_all_amount = 0.0
total_all_amount_nt = 0.0
# 按管理类型名称排序
for type_name in sorted(type_totals.keys()):
totals = type_totals[type_name]
total_all_amount += totals['amount']
total_all_amount_nt += totals['amount_nt']
summary_stats.append({
'name': type_name,
'amount': round(totals['amount'], 2),
'amount_nt': round(totals['amount_nt'], 2)
})
# 返回字典格式,包含数据行、简化的表格合计行、独立的统计卡片数据
return {
"rows": rows,
"summary": {
"序号": "",
"应收开始": False,
"应收结束": False,
"承租方名称": "合计:",
"金额(含税)": round(total_amount, 2),
"应收开始": "",
"应收结束": "",
"承租方名称": "总合计:",
"原始金额": "",
"减免金额": "",
"实际金额(含税)": round(total_all_amount, 2),
"税率": "",
"金额(不含税)": round(total_amount_nt, 2),
"物业名称": False,
"产权证": False,
"合同编号": False,
"管理员": False,
}
"实际金额(不含税)": round(total_all_amount_nt, 2),
"物业名称": "",
"产权证": "",
"合同编号": "",
"管理员": "",
},
"stats": summary_stats # 新增统计卡片数据
}
@@ -37,7 +37,8 @@ class ReceivableReport extends Component {
{'name': '自有', 'value': 'self'},
{'name': '代管', 'value': 'agency'}
],
domainUsers: []
domainUsers: [],
stats: [] // 新增统计数据
});
this.config = this.props.action.context.report_config || {};
@@ -50,6 +51,11 @@ class ReceivableReport extends Component {
theme: agGrid.themeMaterial,
columnDefs: this.config.columns || [],
rowData: [],
rowClassRules: {
'ag-row-new-rent': function(params) {
return params.data && params.data.acc_type === 'new';
}
},
sideBar: {
toolPanels: [
{
@@ -224,10 +230,15 @@ class ReceivableReport extends Component {
if (result && typeof result === 'object' && result.rows && result.summary) {
// 新格式:分离数据行和合计行
this.grid.setGridOption('rowData', result.rows);
this.grid.setGridOption('pinnedBottomRowData', [result.summary]);
// summary可能是单个对象或数组
const summaryData = Array.isArray(result.summary) ? result.summary : [result.summary];
this.grid.setGridOption('pinnedBottomRowData', summaryData);
// 更新统计卡片数据
this.state.stats = result.stats || [];
} else {
// 兼容旧格式:数组
this.grid.setGridOption('rowData', result);
this.state.stats = [];
}
}
@@ -93,6 +93,19 @@
</div>
</div>
<!-- 统计卡片区域 -->
<div class="card mb-2" t-if="state.stats and state.stats.length">
<div class="card-body py-2">
<div class="row g-2">
<div class="col-auto" t-foreach="state.stats" t-as="stat" t-key="stat.name">
<div class="badge bg-light text-dark p-2" style="font-size: 0.9rem; background-color: #d1ecf1 !important; border: 1px solid #bee5eb;">
<strong t-esc="stat.name"/>: <t t-esc="stat.amount"/>
</div>
</div>
</div>
</div>
</div>
<!-- ag-grid 表格区域 -->
<div class="row flex-grow-1">
<div class="col-12 h-100">
@@ -28,4 +28,11 @@
/* 下拉框placeholder样式 */
#formview_default_conditions option[value=""] {
color: #6c757d;
}
/* 新租记录整行样式 */
.ag-row-new-rent {
background-color: #d4edda !important;
color: #155724 !important;
font-weight: bold;
}
@@ -12,18 +12,19 @@
"method": "get_current_receivable_rent_report",
"columns": [
{"headerName": "序号", "field": "序号", "flex": 0.6, "valueFormatter": "params.value === false || params.value === null || params.value === undefined || params.value === 'false' ? '' : params.value"},
{"headerName": "应收开始", "field": "应收开始", "flex": 1.2},
{"headerName": "应收结束", "field": "应收结束", "flex": 1.2},
{"headerName": "应收开始", "field": "应收开始", "flex": 1},
{"headerName": "应收结束", "field": "应收结束", "flex": 1},
{"headerName": "承租方名称", "field": "承租方名称", "flex": 1.6},
{"headerName": "金额(含税)", "field": "金额(含税)", "flex": 1, "type": "number"},
{"headerName": "税率", "field": "税率", "flex": 0.8, "valueFormatter": "params.value === false || params.value === null || params.value === undefined || params.value === 'false' ? '' : params.value"},
{"headerName": "金额(不含税)", "field": "金额(不含税)", "flex": 1, "type": "number"},
{"headerName": "原始金额", "field": "原始金额", "flex": 0.9, "type": "number", "valueFormatter": "params.value === '' || params.value === null || params.value === undefined ? '' : params.value"},
{"headerName": "减免金额", "field": "减免金额", "flex": 0.9, "type": "number", "valueFormatter": "params.value === '' || params.value === null || params.value === undefined ? '' : params.value"},
{"headerName": "实际金额(含税)", "field": "实际金额(含税)", "flex": 1.1, "type": "number"},
{"headerName": "税率", "field": "税率", "flex": 0.6, "valueFormatter": "params.value === false || params.value === null || params.value === undefined || params.value === 'false' || params.value === '' ? '' : params.value"},
{"headerName": "实际金额(不含税)", "field": "实际金额(不含税)", "flex": 1.1, "type": "number"},
{"headerName": "物业名称", "field": "物业名称", "flex": 2},
{"headerName": "产权证", "field": "产权证", "flex": 1.2},
{"headerName": "合同编号", "field": "合同编号", "flex": 1.2},
{"headerName": "管理员", "field": "管理员", "flex": 1}
],
"getRowStyle": "function(params) { if (params.data.acc_type === 'new') { return { color: '#28a745' }; } return null; }"
}
}
</field>
@@ -31,7 +32,7 @@
<menuitem
id="menu_current_receivable_rent_report"
name="当期应收-租金"
name="当期应收"
parent="yuthon_property_approval.property_approval_report_menu"
action="action_current_receivable_rent_report"
sequence="19"