From 2621158d07bccf748a78098f3c36c719474f2f66 Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Mon, 23 Jun 2025 14:47:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_salary/wizard/salary_compute_wizard.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/yuthon_salary/wizard/salary_compute_wizard.py b/yuthon_salary/wizard/salary_compute_wizard.py index f25b20e67..45646eb52 100644 --- a/yuthon_salary/wizard/salary_compute_wizard.py +++ b/yuthon_salary/wizard/salary_compute_wizard.py @@ -29,19 +29,24 @@ class SalaryComputeWizard(models.Model): current_month = datetime.now().month return str(current_month) - @api.onchange('company_id') - def onchange_company_id(self): + @api.onchange('select_year', 'select_time') + def onchange_select_year_select_time(self): + year = int(self.select_year) + month = int(self.select_time) + import calendar + last_day = calendar.monthrange(year, month)[1] + start_date = datetime(year, month, last_day).strftime('%Y-%m-%d') if self.company_id: employees = self.env['hr.employee'].search([ ('company_id', '=', self.company_id.id), ('is_salary', '=', True), - ('contract_id.state', 'not in', ['draft', 'cancel']), # 改一下逻辑 要按入职时间和薪资计算选择的年月 + ('entry_date', '<=', start_date), + ('contract_id.state', 'not in', ['draft', 'cancel']), ('contract_id', '!=', False), ]) self.employee_ids = [(6, 0, employees.ids)] self.employee_number = len(self.employee_ids) - @api.onchange('employee_ids') def onchange_employee_ids(self): if self.employee_ids: