diff --git a/models/project.py b/models/project.py index b5e00bc5d5ed5a49ff67b710d0f51ea839735a12..3f15c05fcc268b87fb3bada2e57876fa82378455 100644 --- a/models/project.py +++ b/models/project.py @@ -11,10 +11,12 @@ from odoo import models, fields, api, osv class FilamentProjet(models.Model): _inherit = 'project.project' + use_prospection = fields.Boolean("Inclure Prospection", default=False) lf_total_budget = fields.Float('Budget Projet',) lf_heures_budget = fields.Float('Budget Heures', compute='_budget_heures') lf_tarif_jour = fields.Float('Tarif Jour',) lf_taux_horaire = fields.Float('Taux Horaire', compute='_taux_horaire') + lf_heures_prospection = fields.Float('Prospection (h)', compute='_total_heures_prospection') lf_heures_projet = fields.Float('Allouées (h)', compute='_total_heures') lf_heures_passees = fields.Float('Heures passées', compute='_total_heures_passees') lf_heures_restantes = fields.Float('Restant (h)', compute='_total_heures_restantes') @@ -36,6 +38,18 @@ class FilamentProjet(models.Model): lf_heures_jour = self.env['ir.values'].get_default('project.config.settings', 'lf_heures_jour') self.lf_taux_horaire = self.lf_tarif_jour / lf_heures_jour + @api.one + def _total_heures_prospection(self): + res = 0.0 + project = self.id + ## Calcul heures + self.env.cr.execute("select sum(aal.unit_amount) from account_analytic_line aal, project_task pt where aal.project_id=%s and pt.name='Prospection' and pt.id=aal.task_id;", (project, ) ) + heures_prospection = self.env.cr.fetchone()[0] + if heures_prospection: + self.lf_heures_prospection = heures_prospection + else: + self.lf_heures_prospection = 0.0 + @api.one def _total_heures_passees(self): res = 0.0 diff --git a/views/lefilament_projets_view.xml b/views/lefilament_projets_view.xml index 26c0435c9b7403204f25a274ac61cf759a8d60f4..c317713f887f2a81c8d0247e224354ca5422e418 100644 --- a/views/lefilament_projets_view.xml +++ b/views/lefilament_projets_view.xml @@ -13,7 +13,13 @@ <header> <button string="Voir le Cash Flow" type="object" name="open_cash_flow" class="oe_highlight"/> </header> - </xpath> + </xpath> + <xpath expr="//field[@name='use_tasks']" position="before"> + <div> + <field name="use_prospection" class="oe_inline"/> + <label for="use_prospection" class="oe_inline"/> + </div> + </xpath> <xpath expr="//notebook" position="before"> <group> <group> @@ -32,7 +38,7 @@ <field name="lf_balance" widget="monetary" options="{'currency_field': 'company_currency'}" /> </group> <group> - <field name="lf_delay" /> + <field name="lf_delay" /> <field name="lf_advance" widget="monetary" options="{'currency_field': 'company_currency'}" /> </group> </group> @@ -60,6 +66,7 @@ <field name="arch" type="xml"> <xpath expr="//field[@name='partner_id']" position="after"> <field name="lf_total_budget" /> + <field name="lf_heures_prospection"/> <field name="lf_heures_budget" /> <field name="lf_heures_projet" /> <field name="lf_heures_planifiees" /> @@ -76,10 +83,14 @@ <field name="model">project.project</field> <field name="inherit_id" ref="project.view_project_kanban"/> <field name="arch" type="xml"> + <xpath expr="//templates" position="before"> + <field name="use_prospection"/> + </xpath> <xpath expr="//div[@class='o_kanban_primary_left']" position="after"> <table class="table table-condensed" style="margin-bottom: 0;"> <thead style="background: transparent; border-bottom: 1px solid #555;"> <tr> + <td attrs="{'invisible':[('use_prospection', '=', False)]}">prospection</td> <td>vendues</td> <td>passées</td> <td>restantes</td> @@ -87,6 +98,7 @@ </thead> <tbody> <tr> + <td class="lf_cell" attrs="{'invisible': [('use_prospection', '=', False)]}"><field name="lf_heures_prospection" >h</field></td> <td class="lf_cell"><field name="lf_heures_projet" >h</field></td> <td class="lf_cell"><field name="lf_heures_passees" >h</field></td> <td class="lf_cell"><field name="lf_heures_restantes" >h</field></td>