Skip to content
Extraits de code Groupes Projets
Valider 756d739e rédigé par Rémi - Le Filament's avatar Rémi - Le Filament
Parcourir les fichiers

[ADD] round timesheets

parent 66f23f0a
Branches 14.0-modifsSept22
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
from . import account_analytic_line
from . import account_move from . import account_move
from . import ecozimut_project_perf from . import ecozimut_project_perf
from . import project from . import project
......
# © 2022 Le Filament (https://le-filament.com)
# © Odoo (see https://github.com/odoo/odoo/blob/14.0/LICENSE)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from math import ceil
from odoo import models
class AccountAnalyticLine(models.Model):
_inherit = "account.analytic.line"
def _timesheet_preprocess(self, vals):
"""
Update timesheet duration with rounding defined in timesheet configuration
"""
vals = super()._timesheet_preprocess(vals)
if vals.get("unit_amount"):
minimum_duration = int(
self.env["ir.config_parameter"]
.sudo()
.get_param("hr_timesheet.timesheet_min_duration", 0)
)
rounding = int(
self.env["ir.config_parameter"]
.sudo()
.get_param("hr_timesheet.timesheet_rounding", 0)
)
minutes_spent = max(minimum_duration, vals.get("unit_amount") * 60)
if rounding and ceil(minutes_spent % rounding) != 0:
minutes_spent = ceil(minutes_spent / rounding) * rounding
vals["unit_amount"] = minutes_spent / 60
return vals
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter