Skip to content
Snippets Groups Projects
Commit 2e7fd843 authored by Hervé Silvant - CGScop's avatar Hervé Silvant - CGScop
Browse files

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

Ajout d'une notion de temps estimé vs temps réalisé sur les projet d'accompagnement + détails temps facturé spécifique AURA
parent 13f2c47f
Branches
No related tags found
1 merge request!7Ajout d'une notion de temps estimé vs temps réalisé sur les projet...
...@@ -66,6 +66,27 @@ class ScopPartner(models.Model): ...@@ -66,6 +66,27 @@ class ScopPartner(models.Model):
comodel_name="scop.liasse.fiscale", string="Liasse fiscale adhésion" 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 # Changement de statuts
list_logs = fields.Text("Liste des erreurs") list_logs = fields.Text("Liste des erreurs")
...@@ -78,6 +99,39 @@ class ScopPartner(models.Model): ...@@ -78,6 +99,39 @@ class ScopPartner(models.Model):
if partner.date_first_rdv: if partner.date_first_rdv:
partner.year_project = str(partner.date_first_rdv.year) 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 # Onchange function
# ------------------------------------------------------ # ------------------------------------------------------
......
...@@ -28,6 +28,38 @@ ...@@ -28,6 +28,38 @@
readonly="1" readonly="1"
/> />
</div> </div>
<field name="estimated_time" invisible="1"/>
<field name="is_estimated_time_ok" invisible="1"/>
<field name="project_status" invisible="1"/>
<div
class="alert alert-danger"
role="alert"
attrs="{'invisible':['|', '|',
('estimated_time','&lt;=',0),
('is_estimated_time_ok','!=',False),
('project_status','in',('1_information','2_pre-diagnostic'))]}"
>
Heures passées :
<field
name="realized_time"
readonly="1"
/>
</div>
<div
class="alert alert-success"
role="alert"
attrs="{'invisible':[ '|','|',
('estimated_time','&lt;=',0),
('is_estimated_time_ok','=',False),
('project_status','in',('1_information','2_pre-diagnostic'))]}"
>
Heures passées :
<field
name="realized_time"
readonly="1"
/>
</div>
</xpath> </xpath>
</field> </field>
</record> </record>
...@@ -215,6 +247,57 @@ ...@@ -215,6 +247,57 @@
<field name="date_convention" /> <field name="date_convention" />
<field name="amount_convention" widget="monetary" /> <field name="amount_convention" widget="monetary" />
</group> </group>
<group
string="Estimation des temps"
attrs="{'invisible':[('project_status','in',('1_information','2_pre-diagnostic'))]}"
>
<table class="table table-bordered">
<thead>
<tr>
<th />
<th>(heures) </th>
<th>Réel</th>
</tr>
</thead>
<tbody>
<tr>
<th>
<label for="estimated_time"/>
</th>
<td>
<field name="estimated_time" />
</td>
<td>
<field name="realized_time" />
</td>
</tr>
<tr attrs="{'invisible':[('ur_id','!=',%(cgscop_partner.riga_14353)d)]}">
<th>
<label for="invoiced_creation"/>
</th>
<td>
<field name="invoiced_creation" />
</td>
<td>
<field name="realized_creation" />
</td>
</tr>
<tr attrs="{'invisible':[('ur_id','!=',%(cgscop_partner.riga_14353)d)]}">
<th>
<label for="invoiced_followup"/>
</th>
<td>
<field name="invoiced_followup" />
</td>
<td>
<field name="realized_followup" />
</td>
</tr>
</tbody>
</table>
</group>
</group> </group>
</page> </page>
...@@ -329,6 +412,58 @@ ...@@ -329,6 +412,58 @@
<field name="date_convention" /> <field name="date_convention" />
<field name="amount_convention" widget="monetary" /> <field name="amount_convention" widget="monetary" />
</group> </group>
<group
string="Estimation des temps"
attrs="{'invisible':[('project_status','in',('1_information','2_pre-diagnostic'))]}"
>
<table class="table table-bordered">
<thead>
<tr>
<th />
<th>(heures) </th>
<th>Réel</th>
</tr>
</thead>
<tbody>
<tr>
<th>
<label for="estimated_time"/>
</th>
<td>
<field name="estimated_time" />
</td>
<td>
<field name="realized_time" />
</td>
</tr>
<tr attrs="{'invisible':[('ur_id','!=',%(cgscop_partner.riga_14353)d)]}">
<th>
<label for="invoiced_creation"/>
</th>
<td>
<field name="invoiced_creation" />
</td>
<td>
<field name="realized_creation" />
</td>
</tr>
<tr attrs="{'invisible':[('ur_id','!=',%(cgscop_partner.riga_14353)d)]}">
<th>
<label for="invoiced_followup"/>
</th>
<td>
<field name="invoiced_followup" />
</td>
<td>
<field name="realized_followup" />
</td>
</tr>
</tbody>
</table>
</group>
</group> </group>
</page> </page>
</page> </page>
...@@ -370,6 +505,12 @@ ...@@ -370,6 +505,12 @@
<field name="date_prediag" optional="hide" /> <field name="date_prediag" optional="hide" />
<field name="date_convention" optional="hide" /> <field name="date_convention" optional="hide" />
<field name="date_transmission_cg" optional="hide" /> <field name="date_transmission_cg" optional="hide" />
<field name="estimated_time" optional="hide" />
<field name="realized_time" optional="hide" />
<field name="invoiced_creation" optional="hide" />
<field name="realized_creation" optional="hide" />
<field name="invoiced_followup" optional="hide" />
<field name="realized_followup" optional="hide" />
</field> </field>
</field> </field>
</record> </record>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment