fix group by branch

This commit is contained in:
Bakry 2024-09-18 13:06:30 +03:00
parent 590b6d7b62
commit 3b3bf62d83
12 changed files with 69 additions and 8 deletions

View File

@ -441,6 +441,7 @@ msgstr "التاخيرات"
#: 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
#, python-format
msgid "Department"
msgstr "الهيكل الإداري"
@ -517,6 +518,7 @@ msgstr ""
#: model_terms:ir.ui.view,arch_db:attendances.employee_lateness_reasons_form_view
#: 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
msgid "Employee"
msgstr "الموظف"
@ -674,7 +676,7 @@ msgstr "من تاريخ"
#. module: attendances
#: model:ir.model.fields,field_description:attendances.field_hr_attendance_register__from_hr_depart
#: model:ir.model.fields,field_description:attendances.field_hr_reasons_lateness__from_hr_depart
msgid "From Hr Depart"
msgid "Another Employee"
msgstr "من موظف آخر"
#. module: attendances
@ -2166,3 +2168,16 @@ msgstr "الحد الأقصى لعدد الأيام لطلب تسجيل بصمة
msgid "Please select Employees Name"
msgstr "الرجاء إختيار أسماء الموظفين"
#. module: attendances
#: model:ir.model.fields,field_description:attendances.field_hr_attendance_register__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
msgid "Employee Number"
msgstr "رقم الموظف"
#. module: attendances
#: model_terms:ir.ui.view,arch_db:attendances.hr_attendance_register_filter
#, python-format
msgid "Branch"
msgstr "الفروع"

View File

@ -13,10 +13,11 @@ class HrAttendanceRegister(models.Model):
action_type = fields.Selection(selection=[('sign_in', _('Sign In')),
('sign_out', _('Sign Out'))], string='Action Type')
action_date = fields.Datetime(string='Attendance Date')
from_hr_depart = fields.Boolean()
department_id = fields.Many2one(related="employee_id.department_id", readonly=True)
from_hr_depart = fields.Boolean(string='Another Employee')
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', index=True, default=lambda item: item.get_user_id())
employee_no = fields.Char(related='employee_id.emp_no', readonly=True,string='Employee Number', store=True)
note_text = fields.Text()
register_date = fields.Date(string='Register Date', default=lambda self: fields.Date.today())
@ -30,6 +31,8 @@ class HrAttendanceRegister(models.Model):
company_id = fields.Many2one(related='employee_id.company_id')
is_branch = fields.Boolean(related='department_id.his_branch', store=True)
def unlink(self):
for rec in self:
if rec.state != 'draft':

View File

@ -12,7 +12,7 @@ class HrReasonsLateness(models.Model):
request_date = fields.Date(default=lambda self: fields.Date.today())
latest_date = fields.Date()
reasons = fields.Text()
from_hr_depart = fields.Boolean()
from_hr_depart = fields.Boolean(string='Another Employee')
department_id = fields.Many2one(related="employee_id.department_id", readonly=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())

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"/>
@ -61,6 +62,7 @@
<field name="from_hr_depart" string="Another Employee" attrs="{'readonly':[('state','!=','draft')]}"/>
<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"/>
<field name="register_date" required="1" attrs="{'readonly':[('state','!=','draft')]}"/>
@ -78,5 +80,27 @@
</field>
</record>
<!-- Attendance_Register_filter -->
<record id="hr_attendance_register_filter" model="ir.ui.view">
<field name="name">Attendance Register</field>
<field name="model">hr.attendance.register</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'}"/>
</group>
<!--separator/>
<filter string="My Attendance" name="my_attendance" domain="[('employee_id.user_id', '=', uid)]"/>
<separator/-->
</search>
</field>
</record>
</data>
</odoo>

View File

@ -49,7 +49,7 @@ class employee_overtime_request(models.Model):
company_id = fields.Many2one('res.company',string="Company", default=lambda self: self.env.user.company_id)
is_branch = fields.Boolean(related='employee_id.department_id.is_branch', store=True)
is_branch = fields.Boolean(related='employee_id.department_id.his_branch', store=True)
def get_user_id(self):
employee_id = self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)

View File

@ -38,7 +38,7 @@ class HrPersonalPermission(models.Model):
('approve', _('Approved')), ('refused', _('Refused'))], default="draft", tracking=True)
type_exit = fields.Selection([('early_exit', _('Early Exit')), ('late entry', _('Late Entry')), ('during work', _('During Work'))],default="early_exit")
company_id = fields.Many2one('res.company',string="Company", default=lambda self: self.env.user.company_id)
is_branch = fields.Boolean(related='department_id.is_branch', store=True)
is_branch = fields.Boolean(related='department_id.his_branch', store=True)
# time_permission_from = fields.Float(string="Permission From (24h format)", help="Time in 24-hour format (e.g., 13.5 for 1:30 PM)")
# time_permission_to = fields.Float(string="Permission To (24h format)", help="Time in 24-hour format (e.g., 15.75 for 3:45 PM)")

View File

@ -50,7 +50,7 @@ class EmployeeOtherRequest(models.Model):
company_id = fields.Many2one('res.company', string="Company", default=lambda self: self.env.user.company_id)
is_branch = fields.Boolean(related='department_id.is_branch', store=True)
is_branch = fields.Boolean(related='department_id.his_branch', store=True)
def print_with_details(self):
return self.env.ref('employee_requests.action_report_employee_identification').report_action(self)

View File

@ -90,7 +90,7 @@ class HrOfficialMission(models.Model):
ticket_request_id = fields.Many2one('hr.ticket.request', string="Ticket Request", readonly=True)
department_id2 = fields.Many2one(related='employee_id.department_id', readonly=True,store=True,string='Department')
is_branch = fields.Boolean(related='department_id2.is_branch', store=True)
is_branch = fields.Boolean(related='department_id2.his_branch', store=True)
'''@api.constrains('employee_ids')

View File

@ -19,6 +19,16 @@ class HrDepartment(models.Model):
is_branch = fields.Boolean(string='Is Branch?',tracking=True)
his_branch = fields.Boolean(compute='get_is_branch', default=False, store=True)
@api.depends('is_branch','parent_id')
def get_is_branch(self):
"""To know which unit or department belongs to a specific branch"""
for rec in self:
if rec.is_branch == True or rec.parent_id.is_branch == True or rec.parent_id.parent_id.is_branch == True:
rec.his_branch = True
@api.model
def create(self, vals):
new_record = super(HrDepartment, self).create(vals)

View File

@ -674,6 +674,7 @@ msgstr ""
#: model_terms:ir.ui.view,arch_db:hr_holidays_public.pubic_leave_report_wizard_view
#: model_terms:ir.ui.view,arch_db:hr_holidays_public.public_leave_cost_report
#: model_terms:ir.ui.view,arch_db:hr_holidays_public.specified_leave_report_template
#: model_terms:ir.ui.view,arch_db:hr_holidays_public.view_hr_holidays_filter2
#, python-format
msgid "Department"
msgstr "الهيكل الإداري"
@ -3639,3 +3640,8 @@ msgstr "سنوي"
#: model:ir.model.fields,field_description:hr_holidays_public.field_hr_holidays_status__balance_type
msgid "Type of leave balance"
msgstr "نوع رصيد الاجازة"
#. module: hr_holidays_public
#: model_terms:ir.ui.view,arch_db:hr_holidays_public.view_hr_holidays_filter2
msgid "Branch"
msgstr "الفرع"

View File

@ -92,6 +92,7 @@ class HRHolidays(models.Model):
emp_number = fields.Char(related='employee_id.emp_no',store=True)
request_done = fields.Boolean(default=False,readonly=True)
is_branch = fields.Boolean(related='department_id.his_branch', store=True)
def _check_state_access_right(self, vals):

View File

@ -247,6 +247,8 @@
<separator/>
<group expand="0" string="Group By">
<filter name="state" string="State" context="{'group_by':'state'}"/>
<filter name="group_department" string="Department" domain="[]" context="{'group_by': 'department_id'}"/>
<filter name="group_branch" string="Branch" domain="[]" context="{'group_by': 'is_branch'}"/>
</group>
</search>