Skip to content
Extraits de code Groupes Projets
Valider 8e09fdef rédigé par Hugo Trentesaux's avatar Hugo Trentesaux
Parcourir les fichiers

move partner lead counter to crm

parent 7dfd6dde
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
# Copyright 2024- Le Filament (https://le-filament.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from odoo import models, fields
from odoo import models, fields, api
class ResPartner(models.Model):
......@@ -16,6 +16,13 @@ class ResPartner(models.Model):
comodel_name="crm.lead",
inverse_name="partner_id",
)
lead_count = fields.Integer("Nombre d'opportunités",
compute="_compute_lead_count", store=True)
proposition_count = fields.Integer("Nombre de propositions",
compute="_compute_lead_count",
store=True)
amendment_count = fields.Integer("Nombre d'avenants",
compute="_compute_lead_count", store=True)
# ------------------------------------------------------
# SQL Constraints
......@@ -29,6 +36,15 @@ class ResPartner(models.Model):
# Computed fields / Search Fields
# ------------------------------------------------------
@api.depends("lead_ids")
def _compute_lead_count(self):
for i in self:
i.lead_count = len(i.lead_ids)
i.proposition_count = i.lead_ids.filtered(
lambda x: x.mucs_type == 'proposition')
i.amendment_count = i.lead_ids.filtered(
lambda x: x.mucs_type == 'avenant')
# ------------------------------------------------------
# Onchange / Constraints
# ------------------------------------------------------
......
......@@ -10,6 +10,13 @@
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="priority">111</field>
<field name="arch" type="xml">
<xpath expr="//field[@name='meeting_count']" position="before">
<!-- wip -->
<field name="lead_count"/>
<field name="proposition_count"/>
<field name="amendment_count"/>
</xpath>
<!-- opportunités -->
<xpath expr="//page[@name='suivi_gestion']" position="after">
<!-- leads -->
......
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