From df1929f1d7917c743030f4b5335b1fe71c403f0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Sun, 30 Mar 2025 15:11:21 +0800 Subject: [PATCH] 1 --- .../static/src/js/route_service.js | 60 +++++++++++-------- yuthon_salary/models/inherit_hr_payslip.py | 14 +++-- .../models/yuthon_payroll_project.py | 6 ++ .../views/inherit_hr_payslip_views.xml | 3 - 4 files changed, 50 insertions(+), 33 deletions(-) diff --git a/sh_backmate_theme_adv_enterprise/static/src/js/route_service.js b/sh_backmate_theme_adv_enterprise/static/src/js/route_service.js index 2397cfd28..fd7dcdd9f 100644 --- a/sh_backmate_theme_adv_enterprise/static/src/js/route_service.js +++ b/sh_backmate_theme_adv_enterprise/static/src/js/route_service.js @@ -151,7 +151,7 @@ function makeRouter(env) { */ function makeDebouncedPush(mode) { let allPushArgs = []; - async function doPush() { + function doPush() { // Aggregates push/replace state arguments const replace = allPushArgs.some(([, options]) => options && options.replace); const newHash = allPushArgs.reduce((finalHash, [hash, options]) => { @@ -168,34 +168,42 @@ function makeRouter(env) { } // If the route changed: pushes or replaces browser state const url = browser.location.origin + routeToUrl(newRoute); - - // softhealer ---quick menu start - - var sh_url = url - if (sh_url) { - var rec = await jsonrpc("/web/dataset/call_kw/sh.wqm.quick.menu/is_quick_menu_avail_url", { - model: 'sh.wqm.quick.menu', - method: 'is_quick_menu_avail_url', - args: ['', sh_url], - kwargs: {}, - }); - - if (rec) { + // softhealer ---quick menu start + var sh_url = url + if (sh_url) { + const jsonData = { + id: Math.floor(Math.random() * 1000 * 1000 * 1000), + jsonrpc: "2.0", + method: "call", + params: { + args: ['', sh_url], + kwargs: {}, + method: "is_quick_menu_avail_url", + model: "sh.wqm.quick.menu", + } + } + $.ajax({ + url: "/web/dataset/call_kw/", + method: "POST", + dataType: 'json', + async: false, // 设置为同步请求 + beforeSend: (xhr) => {xhr.setRequestHeader('Content-Type', 'application/json');}, + data : JSON.stringify(jsonData), + success: (rec) => { + if (rec) { $('.o_main_navbar').find('.o_menu_systray').find('.sh_bookmark').addClass('active'); - } - else { + } else { $('.o_main_navbar').find('.o_menu_systray').find('.sh_bookmark').removeClass('active'); } - } - else{ - $('.o_main_navbar').find('.o_menu_systray').find('.sh_bookmark').removeClass('active'); - } - // quick menu end - - - - - + }, + error: function(xhr, status, error) { + $('.o_main_navbar').find('.o_menu_systray').find('.sh_bookmark').removeClass('active'); + } + }); + } else{ + $('.o_main_navbar').find('.o_menu_systray').find('.sh_bookmark').removeClass('active'); + } + // quick menu end if (mode === "push") { browser.history.pushState({}, "", url); } else { diff --git a/yuthon_salary/models/inherit_hr_payslip.py b/yuthon_salary/models/inherit_hr_payslip.py index 7fe5887d6..7d8b9ad9b 100644 --- a/yuthon_salary/models/inherit_hr_payslip.py +++ b/yuthon_salary/models/inherit_hr_payslip.py @@ -71,10 +71,9 @@ class InheritHrPayslip(models.Model): paid_tax = fields.Float(string='已缴税额') based_pay = fields.Float(string='临时绩效工资') - performance_deduction = fields.Float(string='扣发绩效奖金', store=True) - attendance_deduction = fields.Float(string='扣发全勤奖', store=True) - commuting_deduction = fields.Float(string='扣发通信补贴', store=True) - base_salary_deduction = fields.Float(string='扣发基本工资', store=True) + performance_deduction = fields.Float(string='扣发绩效奖金', compute='_compute_salary', store=True) + commuting_deduction = fields.Float(string='扣发通信补贴', compute='_compute_salary', store=True) + base_salary_deduction = fields.Float(string='扣发基本工资', compute='_compute_salary', store=True) def action_refresh_from_work_entries(self): @@ -87,6 +86,7 @@ class InheritHrPayslip(models.Model): pay.mapped('line_ids').unlink() pay._compute_worked_days_line_ids() pay.compute_sheet() + @api.depends('line_ids') def _compute_salary(self): for rec in self: @@ -148,6 +148,12 @@ class InheritHrPayslip(models.Model): rec.work_injury_insurance = line.total if line.name == '住房公积金': rec.housing_provident_fund = line.total + if line.name == '扣发绩效奖金': + rec.performance_deduction = line.total + if line.name == '扣发基本工资': + rec.base_salary_deduction = line.total + if line.name == '扣发通讯补贴': + rec.commuting_deduction = line.total def put_payslip(self): diff --git a/yuthon_salary/models/yuthon_payroll_project.py b/yuthon_salary/models/yuthon_payroll_project.py index b89b240b3..6caa61894 100644 --- a/yuthon_salary/models/yuthon_payroll_project.py +++ b/yuthon_salary/models/yuthon_payroll_project.py @@ -53,6 +53,12 @@ class YuthonPayrollCommon(models.Model): rule_list = [] formula_salary = '' if ins.name not in sal.rule_ids.mapped('name'): + if ins.name == '扣发绩效奖金': + formula_salary = "result = employee.last_month_performance_deduction" + if ins.name == '扣发通信补贴': + formula_salary = "result = employee.last_month_commuting_deduction" + if ins.name == '扣发基本工资': + formula_salary = "result = employee.last_month_base_salary_deduction" if ins.name == '工龄工资': formula_salary = "result = (employee.company_old_year) * 10" if ins.name == '误餐费': diff --git a/yuthon_salary/views/inherit_hr_payslip_views.xml b/yuthon_salary/views/inherit_hr_payslip_views.xml index f1fd66e0d..b0a362ca8 100644 --- a/yuthon_salary/views/inherit_hr_payslip_views.xml +++ b/yuthon_salary/views/inherit_hr_payslip_views.xml @@ -36,7 +36,6 @@ - @@ -142,7 +141,6 @@ - @@ -185,7 +183,6 @@ -