fix some bugs

This commit is contained in:
Mostafa 2025-12-03 12:28:13 -08:00
parent ffd9da8577
commit df76cf96cf
6 changed files with 727 additions and 667 deletions

View File

@ -265,7 +265,7 @@ class EmployeesAppraisal(models.Model):
item.totals_great_level = 0
item.totals_level_achieved = 0
item.totals_level_achieved_percentage = 0
item.totals_appraisal_result = 0
item.totals_appraisal_result = False
for element in item.appraisal_id:
count_elment = 0
appraisal_result_list = []

View File

@ -162,6 +162,8 @@ class Employee(models.Model):
employee.leave_date_to = leave_data.get(employee.id, {}).get('leave_date_to')
employee.current_leave_state = leave_data.get(employee.id, {}).get('current_leave_state')
employee.current_leave_id = leave_data.get(employee.id, {}).get('current_leave_id')
# Assign is_absent for compatibility with standard hr_holidays module
employee.is_absent = leave_data.get(employee.id) and leave_data.get(employee.id).get('current_leave_state') == 'validate'
def _compute_leaves_count(self):
leaves = self.env['hr.holidays'].read_group([

View File

@ -52,7 +52,8 @@
<filter name="group_employee" string="Employee" context="{'group_by':'employee_id'}"/>
<filter name="group_category" string="Category" context="{'group_by':'category_id'}"/>
<filter name="group_manager" string="Manager" context="{'group_by':'manager_id'}"/>
<filter name="group_second_approver_id" string="Validator" context="{'group_by':'second_approver_id'}"/>
<filter name="group_second_approver_id" string="Validator"
context="{'group_by':'second_approver_id'}"/>
<filter name="group_type" string="Type" context="{'group_by':'holiday_status_id'}"/>
<separator/>
<filter name="group_date_from" string="Start Month" context="{'group_by':'date_from'}"/>
@ -67,7 +68,8 @@
<field name="name">Leave Request</field>
<field name="model">hr.holidays</field>
<field name="arch" type="xml">
<calendar string="Leave Request" date_start="date_from" date_stop="date_to" mode="month" quick_create="0" color="employee_id">
<calendar string="Leave Request" date_start="date_from" date_stop="date_to" mode="month" quick_create="0"
color="employee_id">
<field name="display_name"/>
</calendar>
</field>
@ -82,17 +84,24 @@
<field name="can_reset" invisible="1"/>
<field name="type" invisible="1"/>
<header>
<button string="Confirm" name="action_confirm" invisible="state != 'draft'" type="object" class="oe_highlight"/>
<button string="Approve" name="action_approve" invisible="state != 'confirm'" type="object" groups="hr_holidays_community.group_hr_holidays_user" class="oe_highlight"/>
<button string="Validate" name="action_validate" invisible="state != 'validate1'" type="object" groups="hr_holidays_community.group_hr_holidays_manager" class="oe_highlight"/>
<button string="Refuse" name="action_refuse" invisible="state not in ('confirm', 'validate', 'validate1')" type="object" groups="hr_holidays_community.group_hr_holidays_user"/>
<button string="Confirm" name="action_confirm" invisible="state != 'draft'" type="object"
class="oe_highlight"/>
<button string="Approve" name="action_approve" invisible="state != 'confirm'" type="object"
groups="hr_holidays_community.group_hr_holidays_user" class="oe_highlight"/>
<button string="Validate" name="action_validate" invisible="state != 'validate1'" type="object"
groups="hr_holidays_community.group_hr_holidays_manager" class="oe_highlight"/>
<button string="Refuse" name="action_refuse"
invisible="state not in ('confirm', 'validate', 'validate1')" type="object"
groups="hr_holidays_community.group_hr_holidays_user"/>
<button string="Reset to Draft" name="action_draft" type="object"
invisible="not can_reset or state not in ('confirm', 'refuse')"/>
<field name="state" widget="statusbar" statusbar_visible="draft,confirm,validate"/>
</header>
<sheet>
<div class="oe_title">
<h1><field name="display_name"/></h1>
<h1>
<field name="display_name"/>
</h1>
</div>
<group>
<group>
@ -106,18 +115,29 @@
<field name="date_to" required="type == 'remove'" class="oe_inline"/>
</div>
<div>
<field name="number_of_days_temp" class="oe_inline"/> days
<field name="number_of_days_temp" class="oe_inline"/>
days
</div>
</div>
</group>
<group>
<field name="holiday_type" readonly="type == 'remove' or state != 'draft'" string="Mode" groups="hr_holidays_community.group_hr_holidays_user" context="{'employee_id':employee_id}" />
<field name="employee_id" required="holiday_type == 'employee'" invisible="holiday_type == 'category'" groups="hr_holidays_community.group_hr_holidays_user"/>
<field name="category_id" required="holiday_type == 'category'" readonly="type == 'remove' or state not in ('draft', 'confirm')" invisible="holiday_type == 'employee'"/>
<field name="department_id" groups="hr_holidays_community.group_hr_holidays_user" readonly="type == 'add' or holiday_type == 'category' or state == 'validate'" invisible="holiday_type == 'category'"/>
<field name="payslip_status" groups="hr_holidays_community.group_hr_holidays_manager" invisible="type == 'add'" widget="toggle_button"/>
<field name="holiday_type" readonly="type == 'remove' or state != 'draft'" string="Mode"
groups="hr_holidays_community.group_hr_holidays_user"
context="{'employee_id':employee_id}"/>
<field name="employee_id" required="holiday_type == 'employee'"
invisible="holiday_type == 'category'"
groups="hr_holidays_community.group_hr_holidays_user"/>
<field name="category_id" required="holiday_type == 'category'"
readonly="type == 'remove' or state not in ('draft', 'confirm')"
invisible="holiday_type == 'employee'"/>
<field name="department_id" groups="hr_holidays_community.group_hr_holidays_user"
readonly="type == 'add' or holiday_type == 'category' or state == 'validate'"
invisible="holiday_type == 'category'"/>
<field name="payslip_status" groups="hr_holidays_community.group_hr_holidays_manager"
invisible="type == 'add'" widget="toggle_button"/>
</group>
<field name="notes" nolabel="1" colspan="4" placeholder="Add a reason..." invisible="type == 'remove'"/>
<field name="notes" nolabel="1" colspan="4" placeholder="Add a reason..."
invisible="type == 'remove'"/>
<div groups="hr_holidays_community.group_hr_holidays_manager" invisible="type == 'add'">
<separator string="Comment by Manager"/>
<field name="report_note" placeholder="e.g. Report to the next month..."/>
@ -136,7 +156,7 @@
<list decoration-danger="state == 'refuse'" decoration-info="state == 'draft'" string="Allocation Requests"
decoration-bf="message_needaction == True">
<field name="employee_id"/>
<field name="department_id" />
<field name="department_id"/>
<field name="holiday_status_id"/>
<field name="number_of_days" string="Allocated Days" sum="Remaining Days"/>
<field name="state"/>
@ -166,7 +186,9 @@
<field name="date_to" required="1"/>
<field name="number_of_days_temp" string="Allocated Days" sum="Remaining Days"/>
<field name="state"/>
<field name="payslip_status" widget="toggle_button" options='{"active": "Reported in last payslips", "inactive": "To Report in Payslip"}' groups="hr_holidays_community.group_hr_holidays_manager"/>
<field name="payslip_status" widget="toggle_button"
options='{"active": "Reported in last payslips", "inactive": "To Report in Payslip"}'
groups="hr_holidays_community.group_hr_holidays_manager"/>
<field name="report_note" groups="hr_holidays_community.group_hr_holidays_manager"/>
</list>
</field>
@ -209,13 +231,18 @@
<div t-attf-class="oe_kanban_global_click">
<div>
<span>
<img t-att-src="kanban_image('hr.employee', 'image_small', record.employee_id.raw_value)" t-att-title="record.employee_id.value" t-att-alt="record.employee_id.value" width="40" height="40" class="oe_kanban_avatar pull-left mr4"/>
<img t-att-src="kanban_image('hr.employee', 'image_small', record.employee_id.raw_value)"
t-att-title="record.employee_id.value" t-att-alt="record.employee_id.value"
width="40" height="40" class="oe_kanban_avatar pull-left mr4"/>
</span>
<span>
<div>
<strong class="o_kanban_record_title"><t t-esc="record.employee_id.value"/></strong>
<strong class="o_kanban_record_title">
<t t-esc="record.employee_id.value"/>
</strong>
<span class="pull-right">
<field name="state" widget="label_selection" options="{'classes': {'draft': 'default', 'validate': 'success','confirm': 'default', 'cancel': 'danger'}}"/>
<field name="state" widget="label_selection"
options="{'classes': {'draft': 'default', 'validate': 'success','confirm': 'default', 'cancel': 'danger'}}"/>
</span>
</div>
<div class="text-muted o_kanban_record_subtitle">
@ -228,17 +255,28 @@
<div t-attf-class="oe_kanban_bottom_left #{record.date_from.value ? 'mt8 mb4': ''}">
<table class="text-right" t-if="record.date_from.value">
<tr>
<td style="padding-bottom:4px"><small class="text-muted">from</small></td>
<td style="padding:0 0 4px 4px"><t t-esc="record.date_from.value"/></td>
<td style="padding-bottom:4px">
<small class="text-muted">from</small>
</td>
<td style="padding:0 0 4px 4px">
<t t-esc="record.date_from.value"/>
</td>
</tr>
<tr>
<td><small class="text-muted">to</small></td>
<td style="padding-left:4px"><t t-esc="record.date_to.value"/></td>
<td>
<small class="text-muted">to</small>
</td>
<td style="padding-left:4px">
<t t-esc="record.date_to.value"/>
</td>
</tr>
</table>
</div>
<div t-attf-class="oe_kanban_bottom_right #{record.date_from.value ? 'mt8': ''}">
<span class="badge"><t t-esc="record.number_of_days.value"/> days</span>
<span class="badge">
<t t-esc="record.number_of_days.value"/>
days
</span>
</div>
</div>
</div>
@ -262,7 +300,9 @@
<field name="date_to"/>
<field name="holiday_status_id"/>
<field name="state"/>
<field name="payslip_status" widget="toggle_button" options='{"active": "Reported in last payslips", "inactive": "To Report in Payslip"}' groups="hr_holidays_community.group_hr_holidays_manager"/>
<field name="payslip_status" widget="toggle_button"
options='{"active": "Reported in last payslips", "inactive": "To Report in Payslip"}'
groups="hr_holidays_community.group_hr_holidays_manager"/>
<field name="report_note"/>
</list>
</field>
@ -282,7 +322,9 @@
<field name="date_to"/>
<field name="number_of_days" string="Number of Days" sum="Remaining Days"/>
<field name="state"/>
<field name="payslip_status" widget="toggle_button" options='{"active": "Reported in last payslips", "inactive": "To Report in Payslip"}' groups="hr_holidays_community.group_hr_holidays_manager"/>
<field name="payslip_status" widget="toggle_button"
options='{"active": "Reported in last payslips", "inactive": "To Report in Payslip"}'
groups="hr_holidays_community.group_hr_holidays_manager"/>
<field name="category_id" invisible="1"/>
<field name="department_id" invisible="not context.get('set_visible' and False)"/>
<field name="manager_id" invisible="1"/>
@ -297,7 +339,8 @@
<field name="res_model">hr.holidays</field>
<field name="view_mode">calendar</field>
<field name="context">{'search_default_year': 1, 'search_default_group_employee': 1}</field>
<field name="domain">[('holiday_type','=','employee'), ('type', '=', 'remove'), ('state', '!=', 'refuse')]</field>
<field name="domain">[('holiday_type','=','employee'), ('type', '=', 'remove'), ('state', '!=', 'refuse')]
</field>
<field name="search_view_id" ref="view_hr_holidays_filter"/>
</record>
@ -347,13 +390,15 @@
[
'hr_holidays_community.menu_open_company_allocation',
]
}</field>
}
</field>
<field name="domain">[('type','=','remove')]</field>
<field name="search_view_id" ref="view_hr_holidays_filter"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create a new leave request.
</p><p>
</p>
<p>
Once you have recorded your leave request, it will be sent
to a manager for validation. Be sure to set the right leave
type (recuperation, legal leaves, sickness) and the exact
@ -401,7 +446,8 @@
'hr_holidays_community.menu_open_company_allocation',
'hr_holidays_community.menu_open_employee_leave',
]
}</field>
}
</field>
<field name="domain">[('type','=','remove')]</field>
<field name="view_id" ref="edit_holiday_new"/>
<field name="search_view_id" ref="view_hr_holidays_filter"/>
@ -432,7 +478,8 @@
[
'hr_holidays_community.menu_open_company_allocation',
]
}</field>
}
</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click here to create a new leave allocation request.
@ -474,7 +521,8 @@
'hr_holidays_community.menu_open_allocation_holidays',
'hr_holidays_community.menu_open_company_allocation'
]
}</field>
}
</field>
<field name="domain">[('type','=','add')]</field>
<field name="view_id" ref="edit_holiday_new"/>
<field name="search_view_id" ref="view_hr_holidays_filter"/>
@ -510,7 +558,8 @@
'hr_holidays_community.menu_request_approve_allocation',
'hr_holidays_community.menu_open_employee_leave',
]
}</field>
}
</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click here to create a new leave request.
@ -579,7 +628,8 @@
</record>
<menuitem
id="menu_open_department_leave_allocation_approve" groups="hr_holidays_community.group_hr_holidays_manager,hr_holidays_community.group_hr_holidays_user"
id="menu_open_department_leave_allocation_approve"
groups="hr_holidays_community.group_hr_holidays_manager,hr_holidays_community.group_hr_holidays_user"
name="Leaves Allocation"
parent="menu_hr_holidays_approvals"
action="open_department_holidays_allocation_approve"
@ -656,11 +706,17 @@
<t t-name="card">
<div t-attf-class="oe_kanban_global_click">
<div>
<strong><field name="name"/></strong>
<strong>
<field name="name"/>
</strong>
</div>
<div>
<span>Max Leaves: <field name="max_leaves"/></span>
<span class="pull-right">Leaves Taken: <field name="leaves_taken"/></span>
<span>Max Leaves:
<field name="max_leaves"/>
</span>
<span class="pull-right">Leaves Taken:
<field name="leaves_taken"/>
</span>
</div>
</div>
</t>
@ -715,9 +771,13 @@
<field name="type">ir.actions.act_window</field>
<field name="res_model">hr.holidays</field>
<field name="view_mode">list,form</field>
<field name="context">{'search_default_employee_id': [active_id], 'default_employee_id': active_id, 'search_default_group_type': 1,
'search_default_year': 1}</field>
<field name="domain">[('holiday_type','=','employee'), ('holiday_status_id.limit', '=', False), ('state','!=', 'refuse')]</field>
<field name="context">{'search_default_employee_id': [active_id], 'default_employee_id': active_id,
'search_default_group_type': 1,
'search_default_year': 1}
</field>
<field name="domain">[('holiday_type','=','employee'), ('holiday_status_id.limit', '=', False), ('state','!=',
'refuse')]
</field>
<field name="search_view_id" ref="view_hr_holidays_filter"/>
</record>
@ -726,8 +786,12 @@
<field name="type">ir.actions.act_window</field>
<field name="res_model">hr.holidays</field>
<field name="view_mode">list,form</field>
<field name="context">{'search_default_employee_id': [active_id], 'search_default_validated': True, 'search_default_gray': True}</field>
<field name="domain">[('date_from','&gt;=', context_today().strftime("%Y-%m-1")), ('date_from','&lt;', ((context_today() + relativedelta(months=1)).strftime('%Y-%m-1')) )]</field>
<field name="context">{'search_default_employee_id': [active_id], 'search_default_validated': True,
'search_default_gray': True}
</field>
<field name="domain">[('date_from','&gt;=', context_today().strftime("%Y-%m-1")), ('date_from','&lt;',
((context_today() + relativedelta(months=1)).strftime('%Y-%m-1')) )]
</field>
<field name="view_id" eval="view_holiday_allocation_tree_customize"/>
</record>

View File

@ -9,7 +9,7 @@ from datetime import datetime, date, time
class HrSalaryAdvance(models.Model):
_name = 'hr.loan.salary.advance'
_rec_name = 'employee_id'
_rec_name = 'code'
_description = 'Employee Loan'
_inherit = ['mail.thread', 'mail.activity.mixin']
_order = 'date DESC'

View File

@ -122,11 +122,6 @@
</notebook>
</sheet>
<chatter reload_on_follower="True" />
</form>
</field>
</record>

View File

@ -54,8 +54,7 @@
</page>
</notebook>
</sheet>
<chatter reload_on_follower="True"/>
<!-- <chatter/>-->
<chatter />
</form>
</field>
</record>