添加功能
This commit is contained in:
@@ -67,6 +67,26 @@ class HrLeave(models.Model):
|
||||
else:
|
||||
self.request_hour_to = False
|
||||
|
||||
@api.ondelete(at_uninstall=False)
|
||||
def _unlink_if_correct_states(self):
|
||||
"""重写删除校验:先将请假单改为拒绝状态,再执行原生校验/删除"""
|
||||
to_cancel_leaves = self.filtered(lambda r: r.state != 'cancel')
|
||||
if to_cancel_leaves:
|
||||
to_cancel_leaves.write({
|
||||
'state': 'cancel',
|
||||
'notes': _('%s:删除前自动标记为拒绝') % fields.Datetime.now()
|
||||
})
|
||||
error_message = _('You cannot delete a time off which is in %s state')
|
||||
state_description_values = {elem[0]: elem[1] for elem in self._fields['state']._description_selection(self.env)}
|
||||
if not self.user_has_groups('hr_holidays.group_hr_holidays_user'):
|
||||
for hol in self:
|
||||
if hol.state not in ['draft', 'confirm', 'validate1', 'cancel']:
|
||||
raise UserError(error_message % state_description_values.get(hol.state))
|
||||
if hol.sudo().employee_ids and not hol.employee_id:
|
||||
raise UserError(_('You cannot delete a time off assigned to several employees'))
|
||||
else:
|
||||
for holiday in self.filtered(lambda holiday: holiday.state not in ['draft', 'cancel', 'confirm']):
|
||||
raise UserError(error_message % (state_description_values.get(holiday.state),))
|
||||
|
||||
def action_leave_wizard(self):
|
||||
return {
|
||||
|
||||
@@ -222,7 +222,7 @@ class YuthonOnboardApproval(models.Model):
|
||||
vacation_date = self.duration_employment.replace(day=1)
|
||||
self.env['yuthon.vacation.reports'].search([('employee_id', '=', employee_id.id), ('vacation_date', '=', vacation_date)])
|
||||
if not vacation_date:
|
||||
self.env['yuthon.vacation.reports'].create({
|
||||
self.env['yuthon.vacation.reports'].sudo().create({
|
||||
'employee_id': employee_id.id,
|
||||
'vacation_date': vacation_date,
|
||||
})
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
</group>
|
||||
<group>
|
||||
<field name="current_address"/>
|
||||
<field name="phone"/>
|
||||
<field name="phone" required="1"/>
|
||||
<field name="email"/>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
<field name="salary_level" invisible="contract_type != 'internship'"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="phone"/>
|
||||
<field name="phone" required="1"/>
|
||||
<field name="card"/>
|
||||
<field name="job_id" readonly="0"/>
|
||||
<field name="structure_type_id" domain="[('company_id', '=', company_id)]"/>
|
||||
|
||||
Reference in New Issue
Block a user