Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
5420 Visualizzazioni

Hello All,

i am working on leave management for Odoo11. And i am stuck at one point where leave duration avail in quarantined(4 Parts) but my requirement related to value should be show for half day or full day leave. For eg. duration avail in (4, 4.25, 4.5,4.75,5) instead i needed(4, 4.5,5). So, anyone can help me? I found this is related with below odoo python code.

def _get_number_of_days(self, date_from, date_to, employee_id):
        """ Returns a float equals to the timedelta between two dates given as string."""
        from_dt = fields.Datetime.from_string(date_from)
        to_dt = fields.Datetime.from_string(date_to)
        if employee_id:
            employee = self.env['hr.employee'].browse(employee_id)
            return employee.get_work_days_count(from_dt, to_dt)
        time_delta = to_dt - from_dt
        return math.ceil(time_delta.days + float(time_delta.seconds) / 86400)

    @api.onchange('date_from')
    def _onchange_date_from(self):
        """ If there are no date set for date_to, automatically set one 8 hours later than
            the date_from. Also update the number_of_days.
        """
        date_from = self.date_from
        date_to = self.date_to
        # No date_to set so far: automatically compute one 8 hours later
        if date_from and not date_to:
            date_to_with_delta = fields.Datetime.from_string(date_from) + timedelta(hours=HOURS_PER_DAY)
            self.date_to = str(date_to_with_delta)
        # Compute and update the number of days
        if (date_to and date_from) and (date_from <= date_to):
            self.number_of_days_temp = self._get_number_of_days(date_from, date_to, self.employee_id.id)
        else:
            self.number_of_days_temp = 0

    @api.onchange('date_to')
    def _onchange_date_to(self):
        """ Update the number_of_days. """
        date_from = self.date_from
        date_to = self.date_to
        # Compute and update the number of days
        if (date_to and date_from) and (date_from <= date_to):
            self.number_of_days_temp = self._get_number_of_days(date_from, date_to, self.employee_id.id)
        else:
            self.number_of_days_temp = 0

Also attaching requirement screenshots 

PFA

Thanks in advance

 

Avatar
Abbandona

how you can say this is a problem? set the time accordingly.

Autore

This is problem for me. Is this related to configuration or comes from else?

Post correlati Risposte Visualizzazioni Attività
0
giu 19
2904
1
nov 22
3341
2
ago 22
7682
1
gen 25
9374
1
set 21
6689