Skip to content
Extraits de code Groupes Projets
project_task.py 1,87 ko
Newer Older
  • Learn to ignore specific revisions
  • # Copyright 2022 Le Filament (https://le-filament.com)
    # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
    
    from odoo import models
    
    
    class ProjectTask(models.Model):
        _inherit = "project.task"
    
        # ------------------------------------------------------
        # Fields declaration
        # ------------------------------------------------------
    
        # ------------------------------------------------------
        # SQL Constraints
        # ------------------------------------------------------
    
        # ------------------------------------------------------
        # Default methods
        # ------------------------------------------------------
    
        # ------------------------------------------------------
        # Computed fields / Search Fields
        # ------------------------------------------------------
        def _compute_progress_hours(self):
            """
            Inherit parent function to allow progress > 100
            """
            super()._compute_progress_hours
            for task in self:
                if task.planned_hours > 0.0:
                    task_total_hours = task.effective_hours + task.subtask_effective_hours
                    if task_total_hours > task.planned_hours:
                        task.progress = round(
                            100.0 * task_total_hours / task.planned_hours, 2
                        )
    
        # ------------------------------------------------------
        # Onchange / Constraints
        # ------------------------------------------------------
    
        # ------------------------------------------------------
        # CRUD methods (ORM overrides)
        # ------------------------------------------------------
    
        # ------------------------------------------------------
        # Actions
        # ------------------------------------------------------
    
        # ------------------------------------------------------
        # Business methods
        # ------------------------------------------------------