diff --git a/header_search_panel/static/src/search/header_search/components/quick_filter/quick_filter.js b/header_search_panel/static/src/search/header_search/components/quick_filter/quick_filter.js index bd9f04588..669ace439 100644 --- a/header_search_panel/static/src/search/header_search/components/quick_filter/quick_filter.js +++ b/header_search_panel/static/src/search/header_search/components/quick_filter/quick_filter.js @@ -1,27 +1,39 @@ /** @odoo-module **/ -import { Component, useRef } from "@odoo/owl"; - +import { Component, useState, onWillStart } from "@odoo/owl"; +import { useService } from "@web/core/utils/hooks"; export class QuickFilter extends Component { setup() { super.setup(); - // this.activeFilterIds = this.props.activeFilterIds; + this.orm = useService("orm"); + this.state = useState({ filters: [] }); this.activeFilterIds = this.env.searchModel.headerSearchInfo.quickFilter[this.props.groupId]?.filters || []; + onWillStart(async () => { + await this.loadFilters(); + }) } /** * 返回过滤器列表 */ get filters() { - // 通过ID查询过滤器列表 - const filters = this.env.searchModel.headerSearchInfo.headerQuickFilter[this.props.id].filters || []; - filters.forEach((filter,fdx) => { - filter.isChecked = this.activeFilterIds.includes(filter.inputId); - filter.index = fdx + 1; - }); - return filters; + // 这里直接返回 state,避免在 getter 里做异步 + return this.state.filters; } + async loadFilters() { + const { searchModel } = this.env; + const resModel = searchModel.resModel; + const filters = searchModel.headerSearchInfo.headerQuickFilter[this.props.id]?.filters || []; + for (let [idx, filter] of filters.entries()) { + const domain = this.safeParseDomain(filter.domain); + const count = await this.orm.searchCount(resModel, domain); + filter.count = count; + filter.isChecked = this.activeFilterIds.includes(filter.inputId); + filter.index = idx + 1; + } + this.state.filters = filters; + } /** * 设置活动的过滤器 */ @@ -75,6 +87,24 @@ export class QuickFilter extends Component { this.env.searchModel.applyHeaderFilters(); } + safeParseDomain(domain) { + if (Array.isArray(domain)) { + return domain; // 已经是数组 + } + if (typeof domain === "string") { + try { + // 替换 Python tuple 为 JS 数组 + const jsDomain = domain + .replace(/\(/g, "[") + .replace(/\)/g, "]"); + return JSON.parse(jsDomain.replace(/'/g, '"')); + } catch (e) { + console.warn("无法解析 domain:", domain, e); + return []; + } + } + return []; + } } QuickFilter.template = "header_search_panel.QuickFilter"; @@ -91,4 +121,5 @@ QuickFilter.props = { groupId: { type: Number, required: true }, // 显示label showLabel: { type: Boolean, required: false, default: true }, + resModel: { type: String } } diff --git a/header_search_panel/static/src/search/header_search/components/quick_filter/quick_filter.xml b/header_search_panel/static/src/search/header_search/components/quick_filter/quick_filter.xml index ee0540f56..17da74122 100644 --- a/header_search_panel/static/src/search/header_search/components/quick_filter/quick_filter.xml +++ b/header_search_panel/static/src/search/header_search/components/quick_filter/quick_filter.xml @@ -24,7 +24,7 @@ diff --git a/header_search_panel/static/src/search/header_search/header_search_filter.js b/header_search_panel/static/src/search/header_search/header_search_filter.js index 673d6b2ab..98bae0cc0 100644 --- a/header_search_panel/static/src/search/header_search/header_search_filter.js +++ b/header_search_panel/static/src/search/header_search/header_search_filter.js @@ -36,7 +36,7 @@ export class HeaderSearchFilter extends Component { } get class() { - return this.env.searchModel.headerSearchInfo.class; + return this.env.searchModel.headerSearchInfo.class; } // 点击筛选按钮显示筛选面板 @@ -74,7 +74,7 @@ export class HeaderSearchFilter extends Component { // 存储筛选ID的列表 const searchItems = this.env.searchModel.headerSearchInfo.searchItems; const items = []; - for (let {id, type} of searchItems) { + for (let { id, type } of searchItems) { // 解析所有筛选,根据类型决定使用不同的组件 switch (type) { case "field": diff --git a/yuthon_hr_attendance/controllers/applet_attendance.py b/yuthon_hr_attendance/controllers/applet_attendance.py index a2d7cc2e4..f5198b3e4 100644 --- a/yuthon_hr_attendance/controllers/applet_attendance.py +++ b/yuthon_hr_attendance/controllers/applet_attendance.py @@ -750,16 +750,15 @@ class AppletAttendance(Controller): first_day_str = first_day.strftime('%Y-%m-%d') last_day_str = last_day.strftime('%Y-%m-%d') + # 去掉 数据为 0 的数据. electric_records = request.env(user=SUPERUSER_ID)['meter.archives.line'].search([ ('archives_state', '=', 'use'), - ('current_read', '=', 0), ('meter_date', '>=', first_day_str), ('meter_date', '<=', last_day_str) ]) water_records = request.env(user=SUPERUSER_ID)['meter.water.line'].search([ ('water_state', '=', 'use'), - ('current_read', '=', 0), ('meter_date', '>=', first_day_str), ('meter_date', '<=', last_day_str) ]) @@ -803,6 +802,7 @@ class AppletAttendance(Controller): 'epitope_values':electric.epitope_values_id.name, 'unit_number':electric.unit_number, 'state': electric.state, # 状态 reading unreading + 'last_read': electric.last_read, } electric_result_dict.setdefault(state, {}).setdefault(building,{}).setdefault(floor, []).append(electric_value) @@ -861,6 +861,7 @@ class AppletAttendance(Controller): 'epitope_values':water.epitope_values_id.name, 'unit_number':water.unit_number, 'state': water.state, # 状态 reading unreading + 'last_read': water.last_read, } water_result_dict.setdefault(state, {}).setdefault(building,{}).setdefault(floor, []).append(water_value) @@ -916,7 +917,7 @@ class AppletAttendance(Controller): }) record = request.env(user=SUPERUSER_ID)[model_name].browse(int(id)) if record: - record.write({'current_read': current_read,'last_reading_time':last_reading_time}) + record.write({'current_read': current_read,'last_reading_time':last_reading_time,'state':'reading'}) # record.last_dosage += record.current_meter # record.current_meter = 0 # record.last_meter = datetime.now() diff --git a/yuthon_property/views/property_accounts_receivable_views.xml b/yuthon_property/views/property_accounts_receivable_views.xml index 365119798..04b17a67a 100644 --- a/yuthon_property/views/property_accounts_receivable_views.xml +++ b/yuthon_property/views/property_accounts_receivable_views.xml @@ -8,11 +8,11 @@ - + diff --git a/yuthon_property/views/property_bank_statements_views.xml b/yuthon_property/views/property_bank_statements_views.xml index 15adb461b..db5319215 100644 --- a/yuthon_property/views/property_bank_statements_views.xml +++ b/yuthon_property/views/property_bank_statements_views.xml @@ -33,7 +33,7 @@ - + diff --git a/yuthon_property/views/yuthon_epitope_values_views.xml b/yuthon_property/views/yuthon_epitope_values_views.xml index 3152d741f..ed3728f8d 100644 --- a/yuthon_property/views/yuthon_epitope_values_views.xml +++ b/yuthon_property/views/yuthon_epitope_values_views.xml @@ -5,7 +5,6 @@ yuthon.epitope.values - diff --git a/yuthon_property_approval/models/inherit_yuthon_property.py b/yuthon_property_approval/models/inherit_yuthon_property.py index b4f33c417..bc73d233d 100644 --- a/yuthon_property_approval/models/inherit_yuthon_property.py +++ b/yuthon_property_approval/models/inherit_yuthon_property.py @@ -43,6 +43,7 @@ class PropertyBankStatements(models.Model): contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批") contract_ids = fields.Many2many('property.lease.contract', string="租赁合同审批") + property_name = fields.Char(string="物业名称") accounts_id = fields.Many2one('property.accounts.approval', string="关联生成应收审批单") def batch_revocation(self): @@ -393,6 +394,13 @@ class PropertyAccountsReceivable(models.Model): actual_coping = fields.Float(string="实际应付") + def update_lessee_id(self): + accounts_ids = self.env["property.accounts.receivable"].browse( + self._context.get('active_ids', self._context.get('active_id'))) + for rec in accounts_ids: + rec.lessee_id = rec.contract_id.lessee_id + + @api.depends('management_type_id') def _compute_is_rent(self): for rec in self: diff --git a/yuthon_property_approval/views/inherit_yuthon_property_views.xml b/yuthon_property_approval/views/inherit_yuthon_property_views.xml index f5f1b973f..082e58d61 100644 --- a/yuthon_property_approval/views/inherit_yuthon_property_views.xml +++ b/yuthon_property_approval/views/inherit_yuthon_property_views.xml @@ -293,11 +293,11 @@ + + - -