fix attendance
This commit is contained in:
parent
201c52068c
commit
e8039d22ab
|
|
@ -689,6 +689,17 @@ msgstr "من تاريخ"
|
|||
msgid "Another Employee"
|
||||
msgstr "من موظف آخر"
|
||||
|
||||
#. module: attendances
|
||||
#: model:ir.model.fields,field_description:attendances.field_hr_attendance_register__all_employees
|
||||
#: model_terms:ir.ui.view,arch_db:attendances.hr_attendance_register_form_view
|
||||
msgid "All Employees"
|
||||
msgstr "لكل الموظفين"
|
||||
|
||||
#. module: attendances
|
||||
#: model_terms:ir.ui.view,arch_db:attendances.hr_attendance_register_form_view
|
||||
msgid "Employees"
|
||||
msgstr "الموظفين"
|
||||
|
||||
#. module: attendances
|
||||
#: code:addons/attendances/wizard/attendances_report_wiz.py:0
|
||||
#: code:addons/attendances/wizard/attendances_report_wiz.py:0
|
||||
|
|
@ -2215,3 +2226,9 @@ msgstr "للأسف، لموافقة المدير المباشر '%s' فقط او
|
|||
msgid "Sorry, The Refuse For The Direct Manager '%s' Only OR HR Manager!"
|
||||
msgstr "للأسف، لرفض المدير المباشر '%s' فقط او مدير الموارد البشرية !"
|
||||
|
||||
#. module: attendances
|
||||
#: code:addons/attendances/models/hr_attendance_register.py:0
|
||||
#, python-format
|
||||
msgid "Sorry,You must enter the Names Of Employees!"
|
||||
msgstr "للأسف، يجب ادخال اسماء الموظفين!"
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,15 @@ class HrAttendanceRegister(models.Model):
|
|||
|
||||
is_branch = fields.Many2one(related='department_id.branch_name', store=True, readonly=True)
|
||||
|
||||
all_employees = fields.Boolean(string='All Employees',default=False)
|
||||
|
||||
employee_ids = fields.Many2many('hr.employee', string='Employees')
|
||||
|
||||
@api.onchange('all_employees')
|
||||
def chick_all_employees(self):
|
||||
if self.all_employees==False:
|
||||
self.employee_ids=False
|
||||
|
||||
def unlink(self):
|
||||
for rec in self:
|
||||
if rec.state != 'draft':
|
||||
|
|
@ -74,12 +83,17 @@ class HrAttendanceRegister(models.Model):
|
|||
self.state = "draft"
|
||||
|
||||
def button_submit(self):
|
||||
if self.all_employees == True and not self.employee_ids:
|
||||
raise exceptions.Warning(_("Sorry,You must enter the Names Of Employees!"))
|
||||
self.state = "send"
|
||||
|
||||
def direct_manager(self):
|
||||
for rec in self:
|
||||
manager = rec.sudo().employee_id.parent_id
|
||||
hr_manager = rec.sudo().employee_id.company_id.hr_manager_id
|
||||
if rec.all_employees == True and not rec.employee_ids:
|
||||
raise exceptions.Warning(_("Sorry,You must enter the Names Of Employees!"))
|
||||
|
||||
if manager:
|
||||
if (manager.user_id.id == rec.env.uid or hr_manager.user_id.id == rec.env.uid):
|
||||
rec.write({'state': 'direct_manager'})
|
||||
|
|
@ -102,28 +116,53 @@ class HrAttendanceRegister(models.Model):
|
|||
rec.refused()
|
||||
|
||||
def hr_manager(self):
|
||||
extract_date = datetime.strptime(str(self.action_date), "%Y-%m-%d %H:%M:%S").date()
|
||||
self.env['attendance.attendance'].create({
|
||||
'employee_id': self.employee_id.id,
|
||||
'name': self.action_date,
|
||||
'action': self.action_type,
|
||||
'action_date': self.action_date.date(),
|
||||
'action_type': 'manual',
|
||||
})
|
||||
for rec in self:
|
||||
extract_date = datetime.strptime(str(rec.action_date), "%Y-%m-%d %H:%M:%S").date()
|
||||
if rec.all_employees== False:
|
||||
rec.env['attendance.attendance'].create({
|
||||
'employee_id': rec.employee_id.id,
|
||||
'name': rec.action_date,
|
||||
'action': rec.action_type,
|
||||
'action_date': rec.action_date.date(),
|
||||
'action_type': 'manual',
|
||||
})
|
||||
|
||||
rec.state = "hr_manager"
|
||||
rec.call_cron_function()
|
||||
else:
|
||||
for emp in rec.employee_ids:
|
||||
rec.env['attendance.attendance'].create({
|
||||
'employee_id': emp.id,
|
||||
'name': rec.action_date,
|
||||
'action': rec.action_type,
|
||||
'action_date': rec.action_date.date(),
|
||||
'action_type': 'manual',
|
||||
})
|
||||
rec.call_cron_function()
|
||||
rec.state = "hr_manager"
|
||||
|
||||
self.state = "hr_manager"
|
||||
self.call_cron_function()
|
||||
|
||||
def set_to_draft(self):
|
||||
for item in self:
|
||||
attendances = self.env['attendance.attendance'].search([('action_date', '=', item.action_date),
|
||||
('employee_id', '=', item.employee_id.id)],
|
||||
order="name asc")
|
||||
for attendance in attendances:
|
||||
if attendance.name == item.action_date:
|
||||
attendance.unlink()
|
||||
self.state = "draft"
|
||||
self.call_cron_function()
|
||||
if item.all_employees== False:
|
||||
attendances = self.env['attendance.attendance'].search([('action_date', '=', item.action_date),
|
||||
('employee_id', '=', item.employee_id.id)],order="name asc")
|
||||
for attendance in attendances:
|
||||
if attendance.name == item.action_date:
|
||||
attendance.unlink()
|
||||
item.state = "draft"
|
||||
item.call_cron_function()
|
||||
else:
|
||||
for emp in item.employee_ids:
|
||||
attendances = self.env['attendance.attendance'].search([('action_date', '=', item.action_date),
|
||||
('employee_id', '=', emp.id)],order="name asc")
|
||||
|
||||
for attendance in attendances:
|
||||
if attendance.name == item.action_date:
|
||||
attendance.unlink()
|
||||
item.call_cron_function()
|
||||
item.state = "draft"
|
||||
|
||||
|
||||
def call_cron_function(self):
|
||||
date = datetime.strptime(str(self.action_date), "%Y-%m-%d %H:%M:%S")
|
||||
|
|
|
|||
|
|
@ -25,6 +25,13 @@
|
|||
<field name="groups" eval="[(4, ref('hr_attendance.group_hr_attendance_manager'))]"/>
|
||||
</record>
|
||||
|
||||
<record id="hr_attendance_register_all_emp_rule" model="ir.rule">
|
||||
<field name="name">Manager: views attendance registers all employee</field>
|
||||
<field name="model_id" ref="model_hr_attendance_register"/>
|
||||
<field name="domain_force">[('all_employees' ,'=', True)]</field>
|
||||
<field name="groups" eval="[(4, ref('hr_attendance.group_hr_attendance_manager'))]"/>
|
||||
</record>
|
||||
|
||||
<record id="hr_attendance_register_comp_rule" model="ir.rule">
|
||||
<field name="name">attendance register company rule</field>
|
||||
<field name="model_id" ref="model_hr_attendance_register"/>
|
||||
|
|
|
|||
|
|
@ -53,24 +53,36 @@
|
|||
<sheet>
|
||||
<group>
|
||||
<group>
|
||||
<field name="all_employees" string="All Employees" attrs="{'readonly':[('state','!=','draft')]}"
|
||||
groups="hr.group_hr_user"/>
|
||||
<field name="action_type" required="1" attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||
<field name="action_date" required="1" attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||
<field name="date" invisible="1"/>
|
||||
<field name="company_id" groups="base.group_multi_company" readonly="1"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="from_hr_depart" string="Another Employee" attrs="{'readonly':[('state','!=','draft')]}"
|
||||
groups="hr.group_hr_user,hr_base.group_division_manager"/>
|
||||
<field name="from_hr_depart" string="Another Employee" groups="hr.group_hr_user,hr_base.group_division_manager"
|
||||
attrs="{'readonly':[('state','!=','draft')],'invisible':[('all_employees','=',True)]}" />
|
||||
<field name="employee_id" string="Employee" domain="[('state','=','open')]"
|
||||
attrs="{'readonly': ['|',('from_hr_depart','=',False),('state','!=','draft')],'required':True}"/>
|
||||
<field name="employee_no" string="Employee Number" readonly="1"/>
|
||||
<field name="department_id" string="Department" required="1" readonly="1"/>
|
||||
<field name="job_id" string="Job" required="1" readonly="1"/>
|
||||
attrs="{'readonly': ['|',('from_hr_depart','=',False),('state','!=','draft')],
|
||||
'required':[('all_employees','=',False)]}"/>
|
||||
<field name="employee_no" string="Employee Number" readonly="1" attrs="{'invisible':[('all_employees','=',True)]}"/>
|
||||
<field name="department_id" string="Department" readonly="1" />
|
||||
<field name="job_id" string="Job" readonly="1" attrs="{'invisible':[('all_employees','=',True)]}"/>
|
||||
<field name="register_date" required="1" attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||
</group>
|
||||
</group>
|
||||
<separator string="Notes"/>
|
||||
<field name="note_text" nolabel="1" attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||
|
||||
<group>
|
||||
<notebook>
|
||||
<page string="Employees" attrs="{'readonly':[('state','!=','draft')],'invisible':[('all_employees','=',False)]}">
|
||||
<field name="employee_ids" domain="[('state','=','open')]"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</group>
|
||||
|
||||
</sheet>
|
||||
<div class="oe_chatter">
|
||||
<field name="message_follower_ids" widget="mail_followers"/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue