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: