Merge pull request #1417 from expsa/bakry_hr

fix attendance
This commit is contained in:
bakry 2024-10-03 14:12:00 +03:00 committed by GitHub
commit d20bc8f488
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 48 additions and 2 deletions

View File

@ -438,10 +438,15 @@ msgstr "التاخيرات"
#. module: attendances
#: code:addons/attendances/wizard/attendances_report_wiz.py:0
#: model:ir.model.fields,field_description:attendances.field_attendance_attendance__department_id
#: model:ir.model.fields,field_description:attendances.field_hr_attendance_register__department_id
#: model:ir.model.fields,field_description:attendances.field_hr_reasons_lateness__department_id
#: model_terms:ir.ui.view,arch_db:attendances.hr_lateness_tree_view
#: model_terms:ir.ui.view,arch_db:attendances.hr_attendance_register_filter
#: model_terms:ir.ui.view,arch_db:attendances.hr_reasons_lateness_filter
#: model_terms:ir.ui.view,arch_db:attendances.attendance_custom_form
#: model_terms:ir.ui.view,arch_db:attendances.attendance_custom_tree
#: model_terms:ir.ui.view,arch_db:attendances.attendance_view_filter
#, python-format
msgid "Department"
msgstr "الهيكل الإداري"
@ -519,6 +524,7 @@ msgstr ""
#: model_terms:ir.ui.view,arch_db:attendances.hr_attendance_register_form_view
#: model_terms:ir.ui.view,arch_db:attendances.hr_lateness_tree_view
#: model_terms:ir.ui.view,arch_db:attendances.hr_attendance_register_filter
#: model_terms:ir.ui.view,arch_db:attendances.hr_reasons_lateness_filter
msgid "Employee"
msgstr "الموظف"
@ -721,6 +727,7 @@ msgstr "معالجة الحضور والانصراف"
#. module: attendances
#: model_terms:ir.ui.view,arch_db:attendances.attendance_view_filter
#: model_terms:ir.ui.view,arch_db:attendances.hr_reasons_lateness_filter
msgid "Group By"
msgstr "تجميع حسب"
@ -1427,6 +1434,7 @@ msgstr "اقل وقت خروج"
#: model:ir.model.fields,field_description:attendances.field_resource_calendar__state
#: model_terms:ir.ui.view,arch_db:attendances.hr_lateness_tree_view
#: model_terms:ir.ui.view,arch_db:attendances.hr_attendance_register_filter
#: model_terms:ir.ui.view,arch_db:attendances.hr_reasons_lateness_filter
msgid "State"
msgstr "الحالة"
@ -2171,14 +2179,19 @@ msgstr "الرجاء إختيار أسماء الموظفين"
#. module: attendances
#: model:ir.model.fields,field_description:attendances.field_hr_attendance_register__employee_no
#: model:ir.model.fields,field_description:attendances.field_hr_reasons_lateness__employee_no
#: model_terms:ir.ui.view,arch_db:attendances.hr_attendance_register_tree_view
#: model_terms:ir.ui.view,arch_db:attendances.hr_attendance_register_form_view
#: model_terms:ir.ui.view,arch_db:attendances.employee_lateness_reasons_form_view
#: model_terms:ir.ui.view,arch_db:attendances.hr_lateness_tree_view
msgid "Employee Number"
msgstr "رقم الموظف"
#. module: attendances
#: model_terms:ir.ui.view,arch_db:attendances.hr_attendance_register_filter
#: model_terms:ir.ui.view,arch_db:attendances.view_attendance_transaction_filter
#: model_terms:ir.ui.view,arch_db:attendances.hr_reasons_lateness_filter
#: model_terms:ir.ui.view,arch_db:attendances.attendance_view_filter
#, python-format
msgid "Branch"
msgstr "الفروع"

View File

@ -370,6 +370,7 @@ class Attendance(models.Model):
employee_id = fields.Many2one('hr.employee', string="Employee", domain="[('state', '=', 'open')]", required=True,
ondelete='cascade', index=True)
department_id = fields.Many2one(related="employee_id.department_id", readonly=True, store=True)
action = fields.Selection(selection=[('sign_in', ' Sign In'),
('sign_out', 'Sign Out'),
('action', 'Action')], string='Action', default='sign_in')
@ -383,6 +384,7 @@ class Attendance(models.Model):
employee_number = fields.Char(related='employee_id.emp_no', string='Employee Number',store=True)
company_id = fields.Many2one(related='employee_id.company_id', string='Company')
is_branch = fields.Many2one(related='department_id.branch_name', store=True, readonly=True)
@api.depends('name')
def compute_date(self):

View File

@ -13,7 +13,7 @@ class HrReasonsLateness(models.Model):
latest_date = fields.Date()
reasons = fields.Text()
from_hr_depart = fields.Boolean(string='Another Employee')
department_id = fields.Many2one(related="employee_id.department_id", readonly=True)
department_id = fields.Many2one(related="employee_id.department_id", readonly=True, store=True)
job_id = fields.Many2one(related="employee_id.job_id", readonly=True)
employee_id = fields.Many2one('hr.employee', 'Employee Id', default=lambda item: item.get_user_id())
state = fields.Selection([('draft', _('Draft')),
@ -22,6 +22,8 @@ class HrReasonsLateness(models.Model):
('hr_manager', _('HR Manager')),
('refused', _('Refused'))], default="draft")
company_id = fields.Many2one(related='employee_id.company_id')
employee_no = fields.Char(related='employee_id.emp_no', string='Employee Number',store=True)
is_branch = fields.Many2one(related='department_id.branch_name', store=True, readonly=True)
def unlink(self):
for rec in self:

View File

@ -305,6 +305,7 @@
<group>
<field name="employee_id" readonly="1" force_save="1"/>
<field name="employee_number" readonly="1" force_save="1" store="1"/>
<field name="department_id" string="Department" required="1" readonly="1"/>
<field name="name" required="1" readonly="1" force_save="1"/>
<field name="action" readonly="1" force_save="1"/>
<field name="action_type" readonly="1" force_save="1"/>
@ -324,6 +325,7 @@
<tree>
<field name="employee_number"/>
<field name="employee_id"/>
<field name="department_id" string="Department"/>
<field name="name" required="1"/>
<field name="action"/>
<field name="action_type"/>
@ -339,9 +341,11 @@
<field name="employee_id"/>
<field name="employee_number"/>
<separator/>
<!-- <filter string="My Attendances" domain="[('employee_id.user_id', '=', uid)]"/>-->
<!--<filter string="My Attendances" domain="[('employee_id.user_id', '=', uid)]"/>-->
<group expand="0" string="Group By">
<filter name="employee" string="Employee" context="{'group_by':'employee_id'}"/>
<filter name="group_department" string="Department" domain="[]" context="{'group_by': 'department_id'}"/>
<filter name="group_branch" string="Branch" domain="[]" context="{'group_by': 'is_branch'}"/>
<separator/>
</group>
</search>

View File

@ -14,6 +14,7 @@
<field name="type">tree</field>
<field name="arch" type="xml">
<group>
<field name="employee_no" string="Employee Number"/>
<field name="employee_id" string="Employee"/>
<field name="department_id" string="Department"/>
<field name="job_id" string="Job"/>
@ -65,6 +66,7 @@
attrs="{'readonly':[('state','!=','draft')]}"/>
<field name="employee_id" string="Employee"
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"/>
</group>
@ -79,5 +81,28 @@
</field>
</record>
<!-- Attendance_Register_filter -->
<record id="hr_reasons_lateness_filter" model="ir.ui.view">
<field name="name">Lateness/Exit Reasons</field>
<field name="model">hr.reasons.lateness</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search>
<field name="employee_id"/>
<field name="employee_no"/>
<field name="department_id" />
<group expand="0" string="Group By">
<filter name="group_employee" string="Employee" domain="[]" context="{'group_by': 'employee_id'}"/>
<!--filter name="group_department" string="Department" domain="[]" context="{'group_by': 'department_id'}"/-->
<filter name="group_branch" string="Branch" domain="[]" context="{'group_by': 'is_branch'}"/>
<filter name="group_state" string="State" domain="[]" context="{'group_by': 'state'}"/>
</group>
<!--separator/>
<filter string="My Attendance" name="my_attendance" domain="[('employee_id.user_id', '=', uid)]"/>
<separator/-->
</search>
</field>
</record>
</data>
</odoo>