diff --git a/models/crm_lead.py b/models/crm_lead.py index fdfd2d4f7137f77294481a73b225626ec02714fe..4cbc90ad546577f104796221c220e1e34b7a570a 100644 --- a/models/crm_lead.py +++ b/models/crm_lead.py @@ -16,7 +16,8 @@ class Lead(models.Model): "Revenu espéré TTC", currency_field="company_currency", compute="_compute_expected_revenue_incl_tax", - store=False, + inverse="_inverse_expected_revenue", + store=True, ) # ------------------------------------------------------ @@ -39,11 +40,7 @@ class Lead(models.Model): else 0 ) - # ------------------------------------------------------ - # Onchange / Constraints - # ------------------------------------------------------ - @api.onchange("expected_revenue_incl_tax") - def _onchange_expected_revenue_incl_tax(self): + def _inverse_expected_revenue(self): for lead in self: lead.expected_revenue = ( ( @@ -54,6 +51,13 @@ class Lead(models.Model): else 0 ) + # ------------------------------------------------------ + # Onchange / Constraints + # ------------------------------------------------------ + @api.onchange("expected_revenue_incl_tax") + def _onchange_expected_revenue_incl_tax(self): + self._inverse_expected_revenue() + # ------------------------------------------------------ # CRUD methods (ORM overrides) # ------------------------------------------------------ diff --git a/views/crm_lead_views.xml b/views/crm_lead_views.xml index 78c1fac79ea784f3629eab7cc560839083642575..aca4dfd74a6c09b9f30a5e34be0392091b667e7b 100644 --- a/views/crm_lead_views.xml +++ b/views/crm_lead_views.xml @@ -28,4 +28,52 @@ </xpath> </field> </record> + + <record id="crm_lead_view_tree" model="ir.ui.view"> + <field name="name">crm.3a.lead.tree</field> + <field name="model">crm.lead</field> + <field name="inherit_id" ref="crm.crm_case_tree_view_oppor" /> + <field name="arch" type="xml"> + <field name="expected_revenue" position="after"> + <field + name="expected_revenue_incl_tax" + sum="Revenu espéré TTC" + optional="show" + widget="monetary" + options="{'currency_field': 'company_currency'}" + readonly="0" + /> + </field> + </field> + </record> + + <record id="crm_lead_view_kanban" model="ir.ui.view"> + <field name="name">crm.3a.lead.kanban</field> + <field name="model">crm.lead</field> + <field name="inherit_id" ref="crm.crm_case_kanban_view_leads" /> + <field name="arch" type="xml"> + <field name="expected_revenue" position="after"> + <field name="expected_revenue_incl_tax" /> + </field> + <xpath + expr="//field[@name='expected_revenue' and @widget='monetary']" + position="after" + > + <span> (HT)</span> + </xpath> + <xpath + expr="//div[@class='o_kanban_record_subtitle']" + position="after" + > + <div class="o_kanban_record_subtitle"> + <field + name="expected_revenue_incl_tax" + widget="monetary" + options="{'currency_field': 'company_currency'}" + /> + <span> (TTC)</span> + </div> + </xpath> + </field> + </record> </odoo>