From 3de63c2a82f155e6fa1291dc6b9a36ab20036eb7 Mon Sep 17 00:00:00 2001 From: Bakry Date: Wed, 11 Sep 2024 11:06:12 +0300 Subject: [PATCH] fix --- odex25_hr/hr_base_reports/i18n/ar_001.po | 12 ++--- .../report/overtime_report.xml | 32 ++++++++++---- .../hr_base_reports/wizard/overtime_report.py | 44 ++++++++++++++----- .../hr_holidays_public/models/hr_holidays.py | 3 +- .../views/leaves_balance.xml | 4 ++ 5 files changed, 70 insertions(+), 25 deletions(-) diff --git a/odex25_hr/hr_base_reports/i18n/ar_001.po b/odex25_hr/hr_base_reports/i18n/ar_001.po index be26efbfc..11157d0ff 100644 --- a/odex25_hr/hr_base_reports/i18n/ar_001.po +++ b/odex25_hr/hr_base_reports/i18n/ar_001.po @@ -1126,10 +1126,6 @@ msgstr "رقم الموظف" msgid "Identification Number" msgstr "رقم الهوية" -#. module: hr_base_reports -#: model:ir.model.fields.selection,name:hr_base_reports.selection__employee_cost_report__report_type__iqama -msgid "Identity" -msgstr "" #. module: hr_base_reports #: code:addons/hr_base_reports/report/iqama_report.py:0 @@ -1162,11 +1158,17 @@ msgstr "مبلغ القسط" #. module: hr_base_reports #: code:addons/hr_base_reports/wizard/overtime_report.py:0 -#: model_terms:ir.ui.view,arch_db:hr_base_reports.overtime_report #, python-format msgid "Iqama" msgstr "الهوية" +#. module: hr_base_reports +#: model:ir.model.fields.selection,name:hr_base_reports.selection__employee_cost_report__report_type__iqama +#: model_terms:ir.ui.view,arch_db:hr_base_reports.overtime_report +#, python-format +msgid "Identity" +msgstr "الهوية" + #. module: hr_base_reports #: code:addons/hr_base_reports/wizard/overtime_report.py:0 #: model:ir.model.fields,field_description:hr_base_reports.field_hr_leave_reports_wizard__job_id diff --git a/odex25_hr/hr_base_reports/report/overtime_report.xml b/odex25_hr/hr_base_reports/report/overtime_report.xml index b8a873f23..3b88ee650 100644 --- a/odex25_hr/hr_base_reports/report/overtime_report.xml +++ b/odex25_hr/hr_base_reports/report/overtime_report.xml @@ -52,7 +52,7 @@ Sequence - Iqama + Identity Name Job Salary @@ -83,21 +83,37 @@ - + - + + + + + - - - - + + + + + + + + + + + + + diff --git a/odex25_hr/hr_base_reports/wizard/overtime_report.py b/odex25_hr/hr_base_reports/wizard/overtime_report.py index ec307691e..d13f66278 100644 --- a/odex25_hr/hr_base_reports/wizard/overtime_report.py +++ b/odex25_hr/hr_base_reports/wizard/overtime_report.py @@ -3,6 +3,7 @@ from datetime import datetime, date from odoo import api, fields, models, _ from odoo.exceptions import ValidationError +from dateutil.relativedelta import relativedelta class OvertimeReport(models.TransientModel): @@ -17,6 +18,11 @@ class OvertimeReport(models.TransientModel): date_from = fields.Date() date_to = fields.Date() + @api.onchange('date_from') + def check_date_from(self): + if self.date_from : + self.date_to = fields.Date.from_string(self.date_from)+relativedelta(months=+1, day=1, days=-1) + @api.onchange('department_ids') def _onchange_department_ids(self): if self.department_ids: @@ -79,12 +85,15 @@ class OvertimeReportView(models.AbstractModel): overtime_place = data['overtime_place'] overtime_domain = [('date_from', '>=', date_from), ('date_from', '<=', date_to), ('date_to', '<=', date_to), ('date_to', '>=', date_from), - ('state', 'not in', ['draft', 'cancel']), + ('state', 'not in', ['draft', 'refused']), ('overtime_plase', '=', overtime_place)] for employee in employee_ids: employee_lines = [] over_time_workdays_hours = 0 over_time_vacation_hours = 0 + price_hour = 0 + daily_amount = 0 + vacation_amount = 0 for record in self.env['employee.overtime.request'].search(overtime_domain): for line in record.line_ids_over_time.filtered(lambda l: l.employee_id.id == employee): @@ -95,14 +104,21 @@ class OvertimeReportView(models.AbstractModel): holiday_hourly_rate = l[0].holiday_hourly_rate over_time_workdays_hours += l.over_time_workdays_hours over_time_vacation_hours += l.over_time_vacation_hours + + daily_amount += l.over_time_workdays_hours*l.daily_hourly_rate + vacation_amount += l.over_time_vacation_hours*l.holiday_hourly_rate + price_hour += l.price_hour report_values.append({ 'employee_id': self.env['hr.employee'].browse(employee), 'daily_hourly_rate': daily_hourly_rate, 'holiday_hourly_rate': holiday_hourly_rate, 'over_time_workdays_hours': over_time_workdays_hours, 'over_time_vacation_hours': over_time_vacation_hours, - }) + 'daily_amount': daily_amount, + 'vacation_amount': vacation_amount, + 'price_hour': price_hour, + }) if len(report_values) == 0: raise ValidationError(_("There is no Data")) @@ -177,19 +193,27 @@ class OvertimeReportXls(models.AbstractModel): sheet.write(row, 1, line['employee_id'].iqama_number.iqama_id, format2) sheet.write(row, 2, line['employee_id'].name, format2) sheet.write(row, 3, line['employee_id'].job_id.name, format2) - sheet.write(row, 4, line['employee_id'].contract_id.total_allowance, format2) + sheet.write(row, 4, "{0:.2f}".format(line['employee_id'].contract_id.total_allowance), format2) sheet.write(row, 5, "{0:.2f}".format(line['daily_hourly_rate']), format2) sheet.write(row, 6, "{0:.2f}".format(line['holiday_hourly_rate']), format2) sheet.write(row, 7, line['over_time_workdays_hours'], format2) sheet.write(row, 8, line['over_time_vacation_hours'], format2) - sheet.write(row, 9, line['over_time_workdays_hours'] * line['daily_hourly_rate'], format2) - sheet.write(row, 10, line['over_time_vacation_hours'] * line['holiday_hourly_rate'], format2) - sheet.write(row, 11, line['over_time_workdays_hours'] * line['daily_hourly_rate'] + - line['over_time_vacation_hours'] * line['holiday_hourly_rate'], format2) + #sheet.write(row, 9, line['over_time_workdays_hours'] * line['daily_hourly_rate'], format2) + #sheet.write(row, 10, line['over_time_vacation_hours'] * line['holiday_hourly_rate'], format2) + #sheet.write(row, 11, line['over_time_workdays_hours'] * line['daily_hourly_rate'] + + # line['over_time_vacation_hours'] * line['holiday_hourly_rate'], format2) + #total_daily_hours += line['over_time_workdays_hours'] * line['daily_hourly_rate'] + #total_holiday_hours += line['over_time_vacation_hours'] * line['holiday_hourly_rate'] + #total += line['over_time_workdays_hours'] * line['daily_hourly_rate'] + line['over_time_vacation_hours'] * line['holiday_hourly_rate'] + + sheet.write(row, 9, line['daily_amount'], format2) + sheet.write(row, 10, line['vacation_amount'], format2) + sheet.write(row, 11, line['price_hour'], format2) sequence += 1 - total_daily_hours += line['over_time_workdays_hours'] * line['daily_hourly_rate'] - total_holiday_hours += line['over_time_vacation_hours'] * line['holiday_hourly_rate'] - total += line['over_time_workdays_hours'] * line['daily_hourly_rate'] + line['over_time_vacation_hours'] * line['holiday_hourly_rate'] + + total_daily_hours += line['daily_amount'] + total_holiday_hours += line['vacation_amount'] + total += line['price_hour'] row += 1 sheet.merge_range(row, 0, row, 8, _("Total"), format2) diff --git a/odex25_hr/hr_holidays_public/models/hr_holidays.py b/odex25_hr/hr_holidays_public/models/hr_holidays.py index c9545bde3..268f5684a 100644 --- a/odex25_hr/hr_holidays_public/models/hr_holidays.py +++ b/odex25_hr/hr_holidays_public/models/hr_holidays.py @@ -1839,7 +1839,6 @@ class HRHolidays(models.Model): def delegate_access(self): for rec in self: - print("entered hereeeeeee") if not rec.employee_id.user_id: raise exceptions.Warning( _('Kindly set a user for employee %s') % (rec.employee_id.name)) if not rec.replace_by.user_id: raise exceptions.Warning( @@ -1890,7 +1889,7 @@ class HRHolidays(models.Model): end_day_holiday = holiday.search([('delegate_acc', '=', True), ('date_to', '=', fields.Date.today()), ('state', '=', 'validate1')]) - print("start_day_holiday",start_day_holiday) + if start_day_holiday: start_day_holiday.delegate_access() if end_day_holiday: diff --git a/odex25_hr/hr_holidays_public/views/leaves_balance.xml b/odex25_hr/hr_holidays_public/views/leaves_balance.xml index af1df08e0..841da7faa 100644 --- a/odex25_hr/hr_holidays_public/views/leaves_balance.xml +++ b/odex25_hr/hr_holidays_public/views/leaves_balance.xml @@ -45,6 +45,10 @@ +
+ + +