87 lines
3.3 KiB
XML
87 lines
3.3 KiB
XML
<?xml version="1.0" encoding="utf-8" ?>
|
|
<odoo>
|
|
<record id="TIME" model="hr.salary.rule.category">
|
|
<field name="name">Calcul des heures</field>
|
|
<field name="code">TIME</field>
|
|
</record>
|
|
<record id="HOURS" model="hr.salary.rule">
|
|
<field name="name">Heures rémunérées</field>
|
|
<field name="code">HOURS</field>
|
|
<field name="sequence" eval="100" />
|
|
<field name="category_id" ref="gn_payroll.TIME" />
|
|
<field name="condition_select">none</field>
|
|
<field name="amount_select">code</field>
|
|
<field name="amount_python_compute">
|
|
day = 0
|
|
hours = 0
|
|
hours_month = 0
|
|
hours_std = sum([(x.hour_to - x.hour_from) for x in contract.resource_calendar_id.attendance_ids]) * 52 /12
|
|
|
|
# calculation for Service civique
|
|
if contract.struct_id.code == "VOLSERVCIV":
|
|
if payslip.date_from.day > 1:
|
|
result = hours_std * (31 - payslip.date_from.day) / 30
|
|
elif JOURSMOIS > payslip.date_to.day:
|
|
result = hours_std * payslip.date_to.day / 30
|
|
else:
|
|
result = hours_std
|
|
|
|
# other calculations
|
|
else:
|
|
dic_days = {0: 0, 1:0, 2: 0, 3: 0, 4:0}
|
|
for x in contract.resource_calendar_id.attendance_ids:
|
|
if ((not x.date_from) or ( payslip.date_from >= x.date_from )) and \
|
|
((not x.date_to) or ( x.date_to >= payslip.date_to )):
|
|
dic_days[int(x.dayofweek)] += (x.hour_to - x.hour_from)
|
|
|
|
# Calculating missed hours when payslip doesn't start / end at the beginning/ end of the month
|
|
|
|
if payslip.date_from.day > 1:
|
|
for x in range(payslip.date_from.day, 1, -1):
|
|
day = payslip.date_from.replace(day = x).weekday()
|
|
if day in dic_days:
|
|
hours += dic_days[day]
|
|
|
|
if JOURSMOIS > payslip.date_to.day:
|
|
for x in range(payslip.date_to.day + 1, int(JOURSMOIS)):
|
|
day = payslip.date_to.replace(day = x).weekday()
|
|
if day in dic_days:
|
|
hours += dic_days[day]
|
|
|
|
hours_missed = hours
|
|
|
|
# Calculating missed hours when absence or sickday
|
|
|
|
maladie = inputs.MALADIE.amount if inputs.MALADIE and inputs.MALADIE.amount > 0.0 else 0
|
|
absences = inputs.ABSENCE.amount if inputs.ABSENCE and inputs.ABSENCE.amount > 0.0 else 0
|
|
calendaires = inputs.CALENDAIRE.amount if inputs.CALENDAIRE and inputs.CALENDAIRE.amount > 0.0 else 0
|
|
|
|
if ( maladie != 0 or absences != 0):
|
|
if calendaires + absences == JOURSMOIS:
|
|
hours_std = 0
|
|
|
|
else:
|
|
days_off = absences + maladie
|
|
hours_off = days_off * contract.resource_calendar_id.hours_per_day
|
|
hours_missed += hours_off
|
|
|
|
# Final calculations
|
|
|
|
if worked_days.WORK100 and worked_days.WORK100.number_of_hours:
|
|
hours_done = worked_days.WORK100.number_of_hours
|
|
else:
|
|
hours_done = hours_std
|
|
|
|
####result = hours_done - hours_missed
|
|
#result = hours_done * hours_std / (hours_missed + hours_done)
|
|
#result = hours_std * (hours_done - hours_missed) / hours_done
|
|
result = hours_done - hours_missed
|
|
####result = hours_std - hours_missed
|
|
</field>
|
|
</record>
|
|
<record id="ABSENCE" model="hr.rule.input">
|
|
<field name="name">Absences non rémunérées ( hors arrêt maladie)</field>
|
|
<field name="code">ABSENCE</field>
|
|
<field name="input_id" ref="gn_payroll.HOURS" />
|
|
</record>
|
|
</odoo> |