Skip to content
Extraits de code Groupes Projets

Ajout d'une notion de temps estimé vs temps réalisé sur les projet...

2 files
+ 195
0
Comparer les modifications
  • Côte à côte
  • En ligne

Fichiers

+ 54
0
@@ -66,6 +66,27 @@ class ScopPartner(models.Model):
comodel_name="scop.liasse.fiscale", string="Liasse fiscale adhésion"
)
# Temps estimé/Réalisé
estimated_time = fields.Float("Durée estimée")
invoiced_creation = fields.Float("Durée facturée (création)")
invoiced_followup = fields.Float("Durée facturée (suivi)")
realized_time = fields.Float(
string="Durée réelle",
compute="_compute_real_time",
)
realized_creation = fields.Float(
string="Durée réelle (création)",
compute="_compute_real_time",
)
realized_followup = fields.Float(
string="Durée réelle (suivi)",
compute="_compute_real_time",
)
is_estimated_time_ok = fields.Boolean(
string="Estimation ok",
compute="_compute_real_time",
)
# Changement de statuts
list_logs = fields.Text("Liste des erreurs")
@@ -78,6 +99,39 @@ class ScopPartner(models.Model):
if partner.date_first_rdv:
partner.year_project = str(partner.date_first_rdv.year)
@api.depends("estimated_time")
def _compute_real_time(self):
"""
Champs calculés temps réels
"""
for rec in self:
# Liste des lignes de temps pour ce partner
ldts = self.env["account.analytic.line"].sudo().search(
[
("partner_id", "=", rec.id),
]
)
rec.realized_time = 0
rec.realized_creation = 0
rec.realized_followup = 0
for ldt in ldts:
# On totalise les heures de développement
if (ldt.project_id.cgscop_timesheet_code_id != False and
ldt.project_id.cgscop_timesheet_code_id.domain == 'D'):
rec.realized_time = rec.realized_time + ldt.unit_amount
# On totalise les heures facturés
if ldt.project_id.creation_invoiced == True:
if (ldt.project_id.cgscop_timesheet_code_id != False and
ldt.project_id.cgscop_timesheet_code_id.domain == 'A'):
rec.realized_followup = rec.realized_followup + ldt.unit_amount
if (ldt.project_id.cgscop_timesheet_code_id != False and
ldt.project_id.cgscop_timesheet_code_id.domain == 'D'):
rec.realized_creation = rec.realized_creation + ldt.unit_amount
# On ajoute les heures de suivi facturées au titre du dev
rec.realized_time = rec.realized_time + rec.realized_followup
rec.is_estimated_time_ok = rec.realized_time <= rec.estimated_time
# ------------------------------------------------------
# Onchange function
# ------------------------------------------------------
Chargement en cours