department in attendance report + create_uid in holiday

This commit is contained in:
Esraa-Exp 2025-04-23 15:29:04 +02:00
parent 9ad2d896b5
commit 923c4293a2
5 changed files with 17 additions and 0 deletions

View File

@ -2260,3 +2260,8 @@ msgstr "متواجـد"
msgid "Not Present"
msgstr "غير متواجـد"
#. module: attendances
#: model:ir.model.fields,field_description:attendances.field_hr_attendance_report__department_ids
msgid "Departments"
msgstr "الأقسام"

View File

@ -25,6 +25,8 @@ class HrAttendanceReport(models.Model):
deduct_date_from = fields.Date()
deduct_date_to = fields.Date()
company_id = fields.Many2one('res.company', string="Company", default=lambda self: self.env.user.company_id)
department_ids = fields.Many2many('hr.department', string='Departments')
def unlink(self):
for rec in self:
@ -104,6 +106,8 @@ class HrAttendanceReport(models.Model):
transaction_pool = self.env['hr.attendance.transaction']
reason_pool = self.env['hr.reasons.lateness']
domain = self._context.get('emp_id', False) and [('id', '=', self._context.get('emp_id'))] or []
if self.department_ids:
domain += [('department_id', 'in', self.department_ids.ids)]
emps = self.env['hr.employee'].search(domain)
trans_domain = [('date', '>=', self.date_from), ('date', '<=', self.date_to), ('attending_type', '=', 'in_cal')]
if self.calendar_ids: trans_domain += [('calendar_id', 'in', self.calendar_ids.ids)]

View File

@ -47,6 +47,8 @@
</group>
<group>
<field name="calendar_ids" widget="many2many_tags" attrs="{'readonly':[('state','!=','draft')]}"/>
<field name="department_ids" widget="many2many_tags" attrs="{'readonly':[('state','!=','draft')]}"/>
</group>
<separator string="Report Details"/>
<field name="line_ids" nolabel="1" attrs="{'readonly':[('state','!=','generated')]}">
@ -106,6 +108,7 @@
<tree decoration-success="state=='approved'" decoration-danger="state == 'refused'" decoration-info="state == 'draft'" >
<field name="date_from"/>
<field name="date_to"/>
<field name="department_ids"/>
<field name="state"/>
</tree>
</field>

View File

@ -36,6 +36,7 @@
<attribute name="attrs">{'readonly':[('state','!=','draft')]}</attribute>
</xpath>
<xpath expr="//field[@name='department_id']" position="after">
<field name="create_date" readonly="1"/>
<field name="company_id" groups="base.group_multi_company" readonly="1"/>
<field name="emp_id" invisible="1" attrs="{'readonly':[('state','!=','draft')]}"/>
<field name="last_employee_contract" string="Last Employee Contract"/>
@ -61,6 +62,7 @@
attrs="{'invisible':['|',('check_unlimit','=',False),('type','!=','remove')],'readonly':[('state','!=','draft')]}"/>
<!--<field name="number_days" string="number of days"/>-->
<!--<field name="number_of_days_temp" force_save="1" />-->
</xpath>
<xpath expr="//div[2]" position="before">
<div attrs="{'invisible':[('official_holiday_days', '&lt;=', 0.0)]}">
@ -226,6 +228,9 @@
<xpath expr="//field[@name='name']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='date_to']" position="after">
<field name="create_date"/>
</xpath>
<xpath expr="//field[@name='payslip_status']" position="attributes">
<attribute name="invisible">1</attribute>