4
hr.employeeの従業員が女性の場合、女性従業員にのみ割り当て可能な休暇タイプを表示し、男性従業員と同じ私は休暇条件に取り組んでおり、性別に応じて休暇タイプをodooで表示したい
特定休暇として提供 hr_leave_rules.leave_rules コードから救われる性別は次のとおりです。
class HRLeaveRules(models.Model):
_name = 'hr_leave_rules.leave_rules'
half_day_allowed = fields.Selection([
('yes',"Yes"),
('no',"No")],
string="Half Day Allowed", required=True)
gender_specific = fields.Selection([
('all' ,"All"),
('male',"Male"),
('female',"Female")],
string="Gender Specific", required=True)
leaves_allowed_on_prorata_basis = fields.Selection([
('yes',"Yes"),
('no',"No")],
string="Leaves allowed on pro rata basis", required=True)
leave_encashment = fields.Boolean(string="Leave Encashment",
required=True)
leave_encashment_for_maximum = fields.Integer(
string = "Leave Encashment for maximum", required=True)
can_emp_club_leave = fields.Selection([
('yes',"Yes"),
('no',"No")],
string="Can Employees Club this leave with any other leave",
required=True)
past_dated_leave_allowed = fields.Selection([
('yes',"Yes"),
('no',"No")],
string="Past dated leave application allowed", required=True)
override_paid_leave_to_unpaid = fields.Selection([
('yes',"Yes"),
('no',"No")],
string="Can managers override paid leaves to unpaid", required=True)
carry_frwrdng_leaves = fields.Boolean(string="Carry forwarding of leaves",
required=True)
maximum_accumulation_in_year = fields.Integer(string = "Maximum Accumulation in year",
required=True)
leave_encash_rest_leaves = fields.Selection([
('yes',"Yes"),
('no',"No")],
string="Leave Encashment for Rest Leaves", required=True)
employee_id = fields.Many2one('hr.employee', string="Employee")
holiday_status_id = fields.Many2one("hr.holidays.status",
string="Leave Type", required=True)
department_id = fields.Many2one('hr.department',
related='employee_id.department_id', string='Department')
count_intervening_leaves = fields.Boolean(
string="Count intervening holidays/weekly offs as leaves",
required=True)
count_intervening_leaves_back_date = fields.Boolean(
string="Count intervening holidays/weekly offs as leaves if applying for back date",
required=True)
leaves_probation_period = fields.Boolean(string="Leaves allowed in probation period",
required=True)
max_con_leaves_month = fields.Boolean(string="Maximum consecutive leaves per month",
required=True)
leave_encashment_cycle = fields.Selection([
('annually',"Annually"),
('super_annuation',"Super Annuation/Relieving")],
string="Leave Encashment Cycle", required=True)
description = fields.Text(string="Description")
ここで私はすべてのエラーを見つけていないよ
コードは次のとおりです。 -
@api.onchange('employee_id')
def _gender_specification_check(self):
listed = []
return_domain_list = []
res={}
if self.employee_id.gender == 'male' or self.employee_id.gender == 'female':
if self.employee_id.gender == 'male':
s='male'
else :
s='female'
current = self.env['hr_leave_rules.leave_rules'].search([('gender_specific','=',s)])
for item in current:
listed.append(item.holiday_status_id.id)
for item in range(len(listed)-1):
return_domain_list.append('&')
for item in listed:
return_domain_list.append(('id','!=',str(item)))
else:
current = self.env['hr_leave_rules.leave_rules'].search([('gender_specific','=',self.employee_id.gender)])
for item in current:
listed.append(item.holiday_status_id.id)
for item in range(len(listed)-1):
return_domain_list.append('|')
for item in listed:
return_domain_list.append(('id','=',str(item)))
res['domain']={'holiday_status_id':return_domain_list}
return res
おかげで...
あなたの質問には問題はありませんか? –
HRLeaveRulesクラスで、私が女性のために休暇を割り当てていると言うと、女性のための出産休暇が選択されていれば、_gender_specification_checkは女性従業員が選択されているように働くはずです。育児休暇などの他の休暇は表示しないでください。 –
ifの最初の部分でドメインを返していません。あなたの答えで私の更新を見て –