hr payslip days
This commit is contained in:
parent
e28c02a469
commit
c1b7d5f07f
|
|
@ -7,9 +7,10 @@ import pytz
|
||||||
|
|
||||||
from collections import defaultdict, Counter
|
from collections import defaultdict, Counter
|
||||||
from datetime import date, datetime, time
|
from datetime import date, datetime, time
|
||||||
|
from datetime import timedelta
|
||||||
|
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
|
||||||
from odoo import api, Command, fields, models, _
|
from odoo import api, Command, fields, models, _
|
||||||
from odoo.exceptions import UserError, ValidationError
|
from odoo.exceptions import UserError, ValidationError
|
||||||
from odoo.tools import float_round, date_utils, convert_file, format_amount
|
from odoo.tools import float_round, date_utils, convert_file, format_amount
|
||||||
|
|
@ -1378,6 +1379,29 @@ class HrPayslip(models.Model):
|
||||||
for file_to_update in files_to_update:
|
for file_to_update in files_to_update:
|
||||||
convert_file(self.env, module_name, file_to_update, idref)
|
convert_file(self.env, module_name, file_to_update, idref)
|
||||||
|
|
||||||
|
|
||||||
|
def days_count(self):
|
||||||
|
joining_date = self.contract_id.date_start
|
||||||
|
date_from = min(joining_date, self.date_from)
|
||||||
|
if joining_date > date_from:
|
||||||
|
|
||||||
|
# Define weekend days (Saturday and Sunday)
|
||||||
|
weekend_days = [5, 6] # 5 = Saturday, 6 = Sunday
|
||||||
|
|
||||||
|
# Count weekends between date_from and date_to
|
||||||
|
weekend_count = 0
|
||||||
|
current_date = date_from
|
||||||
|
while current_date <= joining_date:
|
||||||
|
if current_date.weekday() in weekend_days:
|
||||||
|
weekend_count += 1
|
||||||
|
current_date += timedelta(days=1)
|
||||||
|
|
||||||
|
# Output: number of weekly offs since joining
|
||||||
|
weekend_days_count = weekend_count
|
||||||
|
else:
|
||||||
|
weekend_days_count = 0
|
||||||
|
return weekend_days_count
|
||||||
|
|
||||||
def action_edit_payslip_lines(self):
|
def action_edit_payslip_lines(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
if not self.env.user.has_group('hr_payroll.group_hr_payroll_manager'):
|
if not self.env.user.has_group('hr_payroll.group_hr_payroll_manager'):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue