Skip to content
Extraits de code Groupes Projets
Valider c026959c rédigé par Théo - Le Filament's avatar Théo - Le Filament
Parcourir les fichiers

[IMP] add expected revenue incl tax on crm lead

parent 115ea579
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
from . import models
......@@ -7,6 +7,6 @@
"license": "AGPL-3",
"depends": ["crm"],
"data": [
"security/crm_security.xml",
"views/crm_lead_views.xml",
],
}
from . import crm_lead
# Copyright 2024- Le Filament (https://le-filament.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from odoo import api, fields, models
class Lead(models.Model):
_inherit = "crm.lead"
DEFAULT_EXPECTED_REVENUE_VAT = 0.2
# ------------------------------------------------------
# Fields declaration
# ------------------------------------------------------
expected_revenue = fields.Monetary("Revenu espéré HT")
expected_revenue_incl_tax = fields.Monetary(
"Revenu espéré TTC",
currency_field="company_currency",
compute="_compute_expected_revenue_incl_tax",
store=False,
)
# ------------------------------------------------------
# SQL Constraints
# ------------------------------------------------------
# ------------------------------------------------------
# Default methods
# ------------------------------------------------------
# ------------------------------------------------------
# Computed fields / Search Fields
# ------------------------------------------------------
@api.depends("expected_revenue")
def _compute_expected_revenue_incl_tax(self):
for lead in self:
lead.expected_revenue_incl_tax = (
(lead.expected_revenue * (1 + Lead.DEFAULT_EXPECTED_REVENUE_VAT))
if lead.expected_revenue
else 0
)
# ------------------------------------------------------
# Onchange / Constraints
# ------------------------------------------------------
@api.onchange("expected_revenue_incl_tax")
def _onchange_expected_revenue_incl_tax(self):
for lead in self:
lead.expected_revenue = (
(
lead.expected_revenue_incl_tax
/ (1 + Lead.DEFAULT_EXPECTED_REVENUE_VAT)
)
if lead.expected_revenue_incl_tax
else 0
)
# ------------------------------------------------------
# CRUD methods (ORM overrides)
# ------------------------------------------------------
# ------------------------------------------------------
# Actions
# ------------------------------------------------------
# ------------------------------------------------------
# Business methods
# ------------------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- Add CRM group category -->
<record model="ir.module.category" id="3a_crm_module_category">
<field name="name">CRM</field>
<field name="parent_id" ref="base.module_category_sales" />
</record>
<!-- Add CRM groups -->
<record id="group_3a_crm_user" model="res.groups">
<field name="name">CRM : Mes opportunités seulement</field>
<field name="category_id" ref="3a_crm_module_category" />
<field name="implied_ids" eval="[(4, ref('base.group_user'))]" />
</record>
<record id="group_3a_crm_admin" model="res.groups">
<field name="name">CRM : Toutes les opportunités</field>
<field name="category_id" ref="3a_crm_module_category" />
<field name="implied_ids" eval="[(6, 0, [ref('group_3a_crm_user')])]" />
</record>
<!-- Update crm rules -->
<record id="crm.crm_rule_personal_lead" model="ir.rule">
<field name="groups" eval="[(6, 0, [ref('group_3a_crm_user')])]" />
</record>
<record id="crm.crm_rule_all_lead" model="ir.rule">
<field name="groups" eval="[(6, 0, [ref('group_3a_crm_admin')])]" />
</record>
</odoo>
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2024- Le Filament (https://le-filament.com)
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="crm_lead_view_form" model="ir.ui.view">
<field name="name">crm.3a.lead.form</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_lead_view_form" />
<field name="arch" type="xml">
<xpath expr="//h2[1]" position="after">
<h2 class="d-flex gap-2 g-0 align-items-end pb-3">
<div attrs="{'invisible': [('type', '=', 'lead')]}">
<label
for="expected_revenue_incl_tax"
class="oe_edit_only pb-1"
/>
<div class="d-flex align-items-end">
<field
name="expected_revenue_incl_tax"
class="oe_inline o_input_13ch"
widget='monetary'
options="{'currency_field': 'company_currency'}"
readonly="0"
/>
</div>
</div>
</h2>
</xpath>
</field>
</record>
</odoo>
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