login by identity + attendance zone + date required
This commit is contained in:
parent
923c4293a2
commit
e8c12d7635
|
|
@ -49,6 +49,7 @@
|
||||||
"views/employee_iqama_document_view.xml",
|
"views/employee_iqama_document_view.xml",
|
||||||
"views/res_users_views.xml",
|
"views/res_users_views.xml",
|
||||||
"views/menus_view.xml",
|
"views/menus_view.xml",
|
||||||
|
# "views/res_config_settings.xml",
|
||||||
'report/hr_layout.xml',
|
'report/hr_layout.xml',
|
||||||
"report/employee_dependents_report_template.xml",
|
"report/employee_dependents_report_template.xml",
|
||||||
"report/salary_confirmation_report_template.xml",
|
"report/salary_confirmation_report_template.xml",
|
||||||
|
|
|
||||||
|
|
@ -4760,3 +4760,24 @@ msgstr "<span class=\"fa fa-circle-o text-success\" role=\"img\" aria-label=\"Pr
|
||||||
" </span>"
|
" </span>"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#. module: hr_base
|
||||||
|
#: model:ir.model.fields,field_description:hr_base.field_hr_employee__attendance_zone_id
|
||||||
|
msgid "Attendance Zone"
|
||||||
|
msgstr "منطقة الحضور"
|
||||||
|
|
||||||
|
#. module: hr_base
|
||||||
|
#: model:ir.model.fields,field_description:hr_base.field_res_config_settings__employee_login
|
||||||
|
msgid "Login Option"
|
||||||
|
msgstr "تسجيل الدخول الافتراضي"
|
||||||
|
|
||||||
|
#. module: hr_base
|
||||||
|
#: model:ir.model.fields.selection,name:hr_base.selection__res_config_settings__employee_login__email
|
||||||
|
msgid "By Email"
|
||||||
|
msgstr "الايميل"
|
||||||
|
|
||||||
|
#. module: hr_base
|
||||||
|
#: model:ir.model.fields.selection,name:hr_base.selection__res_config_settings__employee_login__identity
|
||||||
|
msgid "By dentity"
|
||||||
|
msgstr "الهوية"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,3 +30,4 @@ from . import assets_document
|
||||||
from . import hr_department
|
from . import hr_department
|
||||||
from . import res_partner
|
from . import res_partner
|
||||||
from . import res_users
|
from . import res_users
|
||||||
|
from . import res_config_settings
|
||||||
|
|
|
||||||
|
|
@ -243,6 +243,8 @@ class HrEmployee(models.Model):
|
||||||
], 'Certificate Level', default='other', groups="base.group_user", tracking=True)
|
], 'Certificate Level', default='other', groups="base.group_user", tracking=True)
|
||||||
children = fields.Integer(string='Number of Children', groups="base.group_user", tracking=True)
|
children = fields.Integer(string='Number of Children', groups="base.group_user", tracking=True)
|
||||||
branch_name = fields.Many2one(related='department_id.branch_name', store=True, string="Branch Name")
|
branch_name = fields.Many2one(related='department_id.branch_name', store=True, string="Branch Name")
|
||||||
|
attendance_zone_id = fields.Many2one('attendance.zone', string='Attendance Zone')
|
||||||
|
|
||||||
|
|
||||||
'''employee_cars_count = fields.Integer(compute="_compute_employee_cars_count", string="Cars",
|
'''employee_cars_count = fields.Integer(compute="_compute_employee_cars_count", string="Cars",
|
||||||
groups="base.group_user")
|
groups="base.group_user")
|
||||||
|
|
@ -591,6 +593,15 @@ class HrEmployee(models.Model):
|
||||||
|
|
||||||
def action_create_user(self):
|
def action_create_user(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
|
config = self.env['ir.config_parameter'].sudo()
|
||||||
|
login_option = config.get_param('hr_base.employee_login')
|
||||||
|
if login_option == 'identity':
|
||||||
|
login = self.iqama_number.iqama_id or self.saudi_number.saudi_id
|
||||||
|
else:
|
||||||
|
login = self.work_email
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if self.user_id:
|
if self.user_id:
|
||||||
raise ValidationError(_("This employee already has an user."))
|
raise ValidationError(_("This employee already has an user."))
|
||||||
return {
|
return {
|
||||||
|
|
@ -605,8 +616,7 @@ class HrEmployee(models.Model):
|
||||||
'default_name': self.name,
|
'default_name': self.name,
|
||||||
'default_phone': self.work_phone,
|
'default_phone': self.work_phone,
|
||||||
'default_mobile': self.mobile_phone,
|
'default_mobile': self.mobile_phone,
|
||||||
'default_login': self.work_email,
|
'default_login': login,
|
||||||
'default_password': self.work_email,
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class ResConfigSettings(models.TransientModel):
|
||||||
|
_inherit = 'res.config.settings'
|
||||||
|
|
||||||
|
employee_login = fields.Selection([('email', 'By Email'), ('identity', 'By dentity')], 'Login Option', default='email', config_parameter='hr_base.employee_login')
|
||||||
|
|
||||||
|
|
@ -11,9 +11,11 @@ class ResUsers(models.Model):
|
||||||
|
|
||||||
@api.model_create_multi
|
@api.model_create_multi
|
||||||
def create(self, vals_list):
|
def create(self, vals_list):
|
||||||
print("Current Context:", self.env.context)
|
|
||||||
res = super().create(vals_list)
|
res = super().create(vals_list)
|
||||||
employee_create_vals = []
|
employee_create_vals = []
|
||||||
|
config = self.env['ir.config_parameter'].sudo()
|
||||||
|
login_option = config.get_param('hr_base.employee_login')
|
||||||
|
|
||||||
for user, vals in zip(res, vals_list):
|
for user, vals in zip(res, vals_list):
|
||||||
if not vals.get('create_employee') and not vals.get('create_employee_id'):
|
if not vals.get('create_employee') and not vals.get('create_employee_id'):
|
||||||
continue
|
continue
|
||||||
|
|
@ -27,5 +29,11 @@ class ResUsers(models.Model):
|
||||||
))
|
))
|
||||||
if employee_create_vals:
|
if employee_create_vals:
|
||||||
self.env['hr.employee'].with_context(clean_context(self.env.context)).create(employee_create_vals)
|
self.env['hr.employee'].with_context(clean_context(self.env.context)).create(employee_create_vals)
|
||||||
|
employee_id = self.env['hr.employee'].browse(self.env.context.get('default_create_employee_id'))
|
||||||
|
|
||||||
|
if login_option == 'identity':
|
||||||
|
res.login = employee_id.saudi_number.saudi_id or employee_id.iqama_number.iqama_id
|
||||||
|
|
||||||
|
|
||||||
res.password = res.login
|
res.password = res.login
|
||||||
return res
|
return res
|
||||||
|
|
@ -293,6 +293,7 @@
|
||||||
attrs="{'readonly':[('state','!=','draft')]}"/>
|
attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||||
<!-- <field name="barcode" string="Attendance ID" attrs="{'readonly':[('state','!=','draft')]}"/> -->
|
<!-- <field name="barcode" string="Attendance ID" attrs="{'readonly':[('state','!=','draft')]}"/> -->
|
||||||
<field name="resource_calendar_id" attrs="{'readonly':[('state','!=','draft')]}"/>
|
<field name="resource_calendar_id" attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||||
|
<field name="attendance_zone_id"/>
|
||||||
<field name="active" string="Active" attrs="{'readonly':[('state','!=','draft')]}"/>
|
<field name="active" string="Active" attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||||
</group>
|
</group>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,21 @@
|
||||||
<field name="model">res.config.settings</field>
|
<field name="model">res.config.settings</field>
|
||||||
<field name="inherit_id" ref="hr.res_config_settings_view_form"/>
|
<field name="inherit_id" ref="hr.res_config_settings_view_form"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//div[@name='employee_rights_setting_container']" position="before">
|
||||||
|
|
||||||
|
<div class="row mt16 o_settings_container" name="employee_login_option_container">
|
||||||
|
|
||||||
|
|
||||||
|
<div class="col-12 col-lg-6 o_setting_box" title="Choose how employees log in.">
|
||||||
|
<div class="o_setting_left_pane">
|
||||||
|
<field name="employee_login" widget="radio"/>
|
||||||
|
</div>
|
||||||
|
<div class="o_setting_right_pane">
|
||||||
|
<label for="employee_login"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</xpath>
|
||||||
<xpath expr="//field[@name='resource_calendar_id']" position="after">
|
<xpath expr="//field[@name='resource_calendar_id']" position="after">
|
||||||
<h2>Saudi Percentage %</h2>
|
<h2>Saudi Percentage %</h2>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
|
||||||
|
|
@ -46,9 +46,9 @@
|
||||||
attrs="{'invisible':[('document_type','!=','Iqama')]}"/>
|
attrs="{'invisible':[('document_type','!=','Iqama')]}"/>
|
||||||
<field name="file_examination" string="File Examination Name"
|
<field name="file_examination" string="File Examination Name"
|
||||||
attrs="{'invisible':[('document_type','!=','medical_Examination')], 'required': [('document_type','=','medical_Examination')]}"/>
|
attrs="{'invisible':[('document_type','!=','medical_Examination')], 'required': [('document_type','=','medical_Examination')]}"/>
|
||||||
<field name="issue_date" required="1"/>
|
<field name="issue_date" attrs="{'required': [('document_type','!=','saudi')]}"/>
|
||||||
<field name="place_issue_id"/>
|
<field name="place_issue_id"/>
|
||||||
<field name="expiry_date" required="1"/>
|
<field name="expiry_date" attrs="{'required': [('document_type','!=','saudi')]}"/>
|
||||||
<field name="reminder_before"/>
|
<field name="reminder_before"/>
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ def daterange(start_date, end_date):
|
||||||
|
|
||||||
class HRHolidays(models.Model):
|
class HRHolidays(models.Model):
|
||||||
_inherit = 'hr.holidays'
|
_inherit = 'hr.holidays'
|
||||||
|
_order = "create_date desc"
|
||||||
|
|
||||||
|
|
||||||
replace_by = fields.Many2one(comodel_name='hr.employee', string="Replace By")
|
replace_by = fields.Many2one(comodel_name='hr.employee', string="Replace By")
|
||||||
emp_id = fields.Integer(string="id")
|
emp_id = fields.Integer(string="id")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue