From 028e7053860ae1342ac4c90cf7144eb1598e388f Mon Sep 17 00:00:00 2001 From: GuillemCForgeFlow Date: Thu, 7 Mar 2024 16:25:44 +0100 Subject: [PATCH] [MIG]crm_lead_product: Migration to 14.0 --- crm_lead_product/README.rst | 32 +++++----- crm_lead_product/__init__.py | 4 +- crm_lead_product/__manifest__.py | 11 ++-- .../migrations/14.0.1.0.0/pre-migration.py | 59 +++++++++++++++++++ crm_lead_product/models/__init__.py | 4 +- crm_lead_product/models/crm_lead.py | 21 +++---- crm_lead_product/models/crm_lead_line.py | 49 ++++++++------- crm_lead_product/readme/CONFIGURE.rst | 1 - crm_lead_product/readme/CONTRIBUTORS.rst | 2 +- crm_lead_product/readme/DESCRIPTION.rst | 10 ++-- crm_lead_product/readme/USAGE.rst | 3 +- crm_lead_product/report/__init__.py | 4 +- crm_lead_product/report/crm_product_report.py | 9 ++- .../report/crm_product_report_views.xml | 6 +- .../static/description/index.html | 24 ++++---- crm_lead_product/tests/__init__.py | 4 +- crm_lead_product/tests/test_crm_lead_line.py | 19 +++--- .../views/crm_lead_line_views.xml | 6 +- crm_lead_product/views/crm_lead_views.xml | 2 +- 19 files changed, 157 insertions(+), 113 deletions(-) create mode 100644 crm_lead_product/migrations/14.0.1.0.0/pre-migration.py diff --git a/crm_lead_product/README.rst b/crm_lead_product/README.rst index 68b527a49fe..fe08a5c05bf 100644 --- a/crm_lead_product/README.rst +++ b/crm_lead_product/README.rst @@ -1,6 +1,6 @@ -================= -Lead Line Product -================= +================ +CRM Lead Product +================ .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -17,26 +17,26 @@ Lead Line Product :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :alt: License: LGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcrm-lightgray.png?logo=github - :target: https://github.com/OCA/crm/tree/13.0/crm_lead_product + :target: https://github.com/OCA/crm/tree/14.0/crm_lead_product :alt: OCA/crm .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/crm-13-0/crm-13-0-crm_lead_product + :target: https://translation.odoo-community.org/projects/crm-14-0/crm-14-0-crm_lead_product :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/crm&target_branch=13.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/crm&target_branch=14.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| - This module allows the user to link multiple products, product categories or product templates to a lead or an opportunity -in order to be able to do a product demand forecasting taking into account the leads and opportunities defined in odoo. -Included in the product line there are two computed fields, the planned revenue and expected revenue. On one hand, the -planned revenue is computed as the selling price times the quantity. On the other hand, the expected revenue takes into account +in order to be able to do a product demand forecasting taking into account the leads and opportunities defined in Odoo. + +Included in the product line there are two computed fields, the expected revenue and prorated revenue. On one hand, the +expected revenue is computed as the selling price times the quantity. On the other hand, the prorated revenue takes into account the probability of the opportunity and is computed as the planned revenue times the probability. The module also includes a reporting section where the user can easily see in a pivot and graph view the relationship -between products, stage of the lead/opportunity and the planned or expected revenue for that product. +between products, stage of the lead/opportunity and the expected or prorated revenue for that product. **Table of contents** @@ -46,16 +46,14 @@ between products, stage of the lead/opportunity and the planned or expected reve Configuration ============= - To configure this module to be available for the Leads the user needs to activate the Leads option in CRM settings Usage ===== - * Go to menu **CRM > Lead** and create or edit a Lead adding all the products associated to it. * Go to menu **CRM > My Pipeline** and create or edit an Opportunity adding all the products associated to it. -* Go to menu **CRM > Reporting > Pipeline by Product** to run the report that relates product to planned and expected revenue per stage +* Go to menu **CRM > Reporting > Pipeline by Product** to run the report that relates product to expected and prorated revenue per stage Bug Tracker =========== @@ -63,7 +61,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -78,8 +76,8 @@ Authors Contributors ~~~~~~~~~~~~ - * Adria Gil Sorribes +* Guillem Casassas Maintainers ~~~~~~~~~~~ @@ -94,6 +92,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/crm `_ project on GitHub. +This module is part of the `OCA/crm `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/crm_lead_product/__init__.py b/crm_lead_product/__init__.py index 91fd52a41ba..c03f6afd667 100644 --- a/crm_lead_product/__init__.py +++ b/crm_lead_product/__init__.py @@ -1,4 +1,4 @@ -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). - +# Copyright (C) 2017-2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from . import models from . import report diff --git a/crm_lead_product/__manifest__.py b/crm_lead_product/__manifest__.py index e2c2abc0c3a..aa64c1ff950 100644 --- a/crm_lead_product/__manifest__.py +++ b/crm_lead_product/__manifest__.py @@ -1,12 +1,11 @@ -# Copyright (C) 2017-19 ForgeFlow S.L. (https://www.forgeflow.com). -# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). - +# Copyright (C) 2017-2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) { - "name": "Lead Line Product", - "version": "13.0.1.0.1", + "name": "CRM Lead Product", + "version": "14.0.1.0.0", "category": "Customer Relationship Management", "license": "LGPL-3", - "summary": "Adds a lead line in the lead/opportunity model " "in odoo", + "summary": "Adds a lead line in the lead/opportunity model in odoo", "author": "ForgeFlow, Odoo Community Association (OCA)", "website": "https://github.com/OCA/crm", "depends": ["crm", "product"], diff --git a/crm_lead_product/migrations/14.0.1.0.0/pre-migration.py b/crm_lead_product/migrations/14.0.1.0.0/pre-migration.py new file mode 100644 index 00000000000..02f741a92f1 --- /dev/null +++ b/crm_lead_product/migrations/14.0.1.0.0/pre-migration.py @@ -0,0 +1,59 @@ +# Copyright (C) 2017-2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + if openupgrade.column_exists( + env.cr, "crm_lead_line", "expected_revenue" + ) and not openupgrade.column_exists(env.cr, "crm_lead_line", "prorated_revenue"): + env.cr.execute( + """ + ALTER TABLE crm_lead_line + ADD COLUMN prorated_revenue NUMERIC; + COMMENT ON COLUMN crm_lead_line.prorated_revenue + IS 'Prorated Revenue'; + """ + ) + # PostgreSQL already automatically truncates from `double_precision` type to + # `numeric` type, this is needed as we are converting from Float Odoo field + # to Monetary Odoo field + env.cr.execute( + """ + UPDATE crm_lead_line + SET prorated_revenue = expected_revenue; + """ + ) + env.cr.execute( + """ + ALTER TABLE crm_lead_line + DROP COLUMN expected_revenue; + """ + ) + if openupgrade.column_exists( + env.cr, "crm_lead_line", "planned_revenue" + ) and not openupgrade.column_exists(env.cr, "crm_lead_line", "expected_revenue"): + env.cr.execute( + """ + ALTER TABLE crm_lead_line + ADD COLUMN expected_revenue NUMERIC; + COMMENT ON COLUMN crm_lead_line.expected_revenue + IS 'Expected Revenue'; + """ + ) + # PostgreSQL already automatically truncates from `double_precision` type to + # `numeric` type, this is needed as we are converting from Float Odoo field + # to Monetary Odoo field + env.cr.execute( + """ + UPDATE crm_lead_line + SET expected_revenue = planned_revenue; + """ + ) + env.cr.execute( + """ + ALTER TABLE crm_lead_line + DROP COLUMN planned_revenue; + """ + ) diff --git a/crm_lead_product/models/__init__.py b/crm_lead_product/models/__init__.py index 817c1655ca2..33ceeefdb72 100644 --- a/crm_lead_product/models/__init__.py +++ b/crm_lead_product/models/__init__.py @@ -1,4 +1,4 @@ -# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). - +# Copyright (C) 2017-2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from . import crm_lead_line from . import crm_lead diff --git a/crm_lead_product/models/crm_lead.py b/crm_lead_product/models/crm_lead.py index 6317de3bd03..005a125dd07 100644 --- a/crm_lead_product/models/crm_lead.py +++ b/crm_lead_product/models/crm_lead.py @@ -1,5 +1,5 @@ -# Copyright (C) 2017-19 ForgeFlow S.L. (https://www.forgeflow.com) -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +# Copyright (C) 2017-2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from odoo import api, fields, models @@ -13,20 +13,15 @@ class CrmLead(models.Model): @api.onchange("lead_line_ids") def _onchange_lead_line_ids(self): - planned_revenue = 0 + expected_revenue = 0 for lead_line in self.lead_line_ids: - if lead_line.planned_revenue != 0: - planned_revenue += lead_line.planned_revenue - self.planned_revenue = planned_revenue + expected_revenue += lead_line.expected_revenue + self.expected_revenue = expected_revenue def _convert_opportunity_data(self, customer, team_id=False): res = super(CrmLead, self)._convert_opportunity_data(customer, team_id) - - # Update planned_revenue - planned_revenue = 0 + expected_revenue = 0 for lead_line in self.lead_line_ids: - planned_revenue += lead_line.planned_revenue - - res["planned_revenue"] = planned_revenue - + expected_revenue += lead_line.expected_revenue + res["expected_revenue"] = expected_revenue return res diff --git a/crm_lead_product/models/crm_lead_line.py b/crm_lead_product/models/crm_lead_line.py index 0c84b18ce80..12177631c6e 100644 --- a/crm_lead_product/models/crm_lead_line.py +++ b/crm_lead_product/models/crm_lead_line.py @@ -1,5 +1,5 @@ -# Copyright (C) 2017-19 ForgeFlow S.L. (https://www.forgeflow.com) -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +# Copyright (C) 2017-2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from odoo import api, fields, models @@ -9,16 +9,16 @@ class CrmLeadLine(models.Model): _description = "Line in CRM Lead" @api.depends("price_unit", "product_qty") - def _compute_planned_revenue(self): + def _compute_expected_revenue(self): for rec in self: - rec.planned_revenue = rec.product_qty * rec.price_unit + rec.expected_revenue = rec.product_qty * rec.price_unit - @api.depends("lead_id.probability", "planned_revenue") - def _compute_expected_revenue(self): + @api.depends("lead_id.probability", "expected_revenue") + def _compute_prorated_revenue(self): for rec in self: if rec.lead_id and rec.lead_id.type != "lead": - rec.expected_revenue = ( - rec.planned_revenue * rec.lead_id.probability * (1 / 100) + rec.prorated_revenue = ( + rec.expected_revenue * rec.lead_id.probability * (1 / 100) ) lead_id = fields.Many2one("crm.lead", string="Lead") @@ -32,16 +32,24 @@ def _compute_expected_revenue(self): ) product_qty = fields.Integer(string="Product Quantity", default=1, required=True) uom_id = fields.Many2one("uom.uom", string="Unit of Measure", readonly=True) - price_unit = fields.Float(string="Price Unit") - planned_revenue = fields.Float( - compute="_compute_planned_revenue", - string="Planned revenue", - compute_sudo=True, - store=True, + price_unit = fields.Float(string="Price Unit", digits="Product Price") + company_currency = fields.Many2one( + "res.currency", + string="Currency", + related="lead_id.company_currency", + readonly=True, ) - expected_revenue = fields.Float( + expected_revenue = fields.Monetary( compute="_compute_expected_revenue", string="Expected revenue", + currency_field="company_currency", + compute_sudo=True, + store=True, + ) + prorated_revenue = fields.Monetary( + compute="_compute_prorated_revenue", + string="Prorated revenue", + currency_field="company_currency", compute_sudo=True, store=True, ) @@ -51,7 +59,6 @@ def _onchange_product_id(self): domain = {} if not self.lead_id: return - if not self.product_id: self.price_unit = 0.0 domain["uom_id"] = [] @@ -62,22 +69,18 @@ def _onchange_product_id(self): self.category_id = product.categ_id.id self.product_tmpl_id = product.product_tmpl_id.id self.price_unit = product.list_price - if product.name: self.name = product.name - if ( not self.uom_id or product.uom_id.category_id.id != self.uom_id.category_id.id ): self.uom_id = product.uom_id.id domain["uom_id"] = [("category_id", "=", product.uom_id.category_id.id)] - if self.uom_id and self.uom_id.id != product.uom_id.id: self.price_unit = product.uom_id._compute_price( self.price_unit, self.uom_id ) - return {"domain": domain} @api.onchange("category_id") @@ -89,7 +92,6 @@ def _onchange_category_id(self): categ_id = self.category_id if categ_id.name and not self.name: self.name = categ_id.name - # Check if there are already defined product and product template # and remove them if categories do not match if self.product_id and self.product_id.categ_id != categ_id: @@ -97,7 +99,6 @@ def _onchange_category_id(self): self.name = categ_id.name if self.product_tmpl_id and self.product_tmpl_id.categ_id != categ_id: self.product_tmpl_id = None - return {"domain": domain} @api.onchange("product_tmpl_id") @@ -110,14 +111,12 @@ def _onchange_product_tmpl_id(self): if product_tmpl.name and not self.name: self.name = product_tmpl.name self.category_id = product_tmpl.categ_id - if self.product_id: # Check if there are already defined product and remove # if it does not match if self.product_id.product_tmpl_id != product_tmpl: self.product_id = None self.name = product_tmpl.name - return {"domain": domain} @api.onchange("uom_id") @@ -125,11 +124,9 @@ def _onchange_uom_id(self): result = {} if not self.uom_id: self.price_unit = 0.0 - if self.product_id and self.uom_id: price_unit = self.product_id.list_price self.price_unit = self.product_id.uom_id._compute_price( price_unit, self.uom_id ) - return result diff --git a/crm_lead_product/readme/CONFIGURE.rst b/crm_lead_product/readme/CONFIGURE.rst index f62459d620f..8b4d020ccdf 100644 --- a/crm_lead_product/readme/CONFIGURE.rst +++ b/crm_lead_product/readme/CONFIGURE.rst @@ -1,2 +1 @@ - To configure this module to be available for the Leads the user needs to activate the Leads option in CRM settings diff --git a/crm_lead_product/readme/CONTRIBUTORS.rst b/crm_lead_product/readme/CONTRIBUTORS.rst index f7e812f3bb3..9925ec25580 100644 --- a/crm_lead_product/readme/CONTRIBUTORS.rst +++ b/crm_lead_product/readme/CONTRIBUTORS.rst @@ -1,2 +1,2 @@ - * Adria Gil Sorribes +* Guillem Casassas diff --git a/crm_lead_product/readme/DESCRIPTION.rst b/crm_lead_product/readme/DESCRIPTION.rst index f249dfb756a..a0850605d71 100644 --- a/crm_lead_product/readme/DESCRIPTION.rst +++ b/crm_lead_product/readme/DESCRIPTION.rst @@ -1,9 +1,9 @@ - This module allows the user to link multiple products, product categories or product templates to a lead or an opportunity -in order to be able to do a product demand forecasting taking into account the leads and opportunities defined in odoo. -Included in the product line there are two computed fields, the planned revenue and expected revenue. On one hand, the -planned revenue is computed as the selling price times the quantity. On the other hand, the expected revenue takes into account +in order to be able to do a product demand forecasting taking into account the leads and opportunities defined in Odoo. + +Included in the product line there are two computed fields, the expected revenue and prorated revenue. On one hand, the +expected revenue is computed as the selling price times the quantity. On the other hand, the prorated revenue takes into account the probability of the opportunity and is computed as the planned revenue times the probability. The module also includes a reporting section where the user can easily see in a pivot and graph view the relationship -between products, stage of the lead/opportunity and the planned or expected revenue for that product. +between products, stage of the lead/opportunity and the expected or prorated revenue for that product. diff --git a/crm_lead_product/readme/USAGE.rst b/crm_lead_product/readme/USAGE.rst index 3a3ada4eb18..12ba600dd6c 100644 --- a/crm_lead_product/readme/USAGE.rst +++ b/crm_lead_product/readme/USAGE.rst @@ -1,4 +1,3 @@ - * Go to menu **CRM > Lead** and create or edit a Lead adding all the products associated to it. * Go to menu **CRM > My Pipeline** and create or edit an Opportunity adding all the products associated to it. -* Go to menu **CRM > Reporting > Pipeline by Product** to run the report that relates product to planned and expected revenue per stage +* Go to menu **CRM > Reporting > Pipeline by Product** to run the report that relates product to expected and prorated revenue per stage diff --git a/crm_lead_product/report/__init__.py b/crm_lead_product/report/__init__.py index a83cf49fcf9..87e010fae84 100644 --- a/crm_lead_product/report/__init__.py +++ b/crm_lead_product/report/__init__.py @@ -1,3 +1,3 @@ -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). - +# Copyright (C) 2017-2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from . import crm_product_report diff --git a/crm_lead_product/report/crm_product_report.py b/crm_lead_product/report/crm_product_report.py index d3af3074e48..4bc3c19c7c2 100644 --- a/crm_lead_product/report/crm_product_report.py +++ b/crm_lead_product/report/crm_product_report.py @@ -1,6 +1,5 @@ -# Copyright (C) 2017-19 ForgeFlow S.L. (https://www.forgeflow.com) -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). - +# Copyright (C) 2017-2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from psycopg2.extensions import AsIs from odoo import fields, models, tools @@ -38,7 +37,7 @@ class ActivityReport(models.Model): user_id = fields.Many2one("res.users", "Salesperson", readonly=True) category_id = fields.Many2one("product.category", "Category", readonly=True) expected_revenue = fields.Float("Expected Revenue", readonly=True) - planned_revenue = fields.Float("Planned Revenue", readonly=True) + prorated_revenue = fields.Float("Prorated Revenue", readonly=True) product_id = fields.Many2one("product.product", "Product", readonly=True) product_qty = fields.Integer("Product Quantity", readonly=True) product_tmpl_id = fields.Many2one( @@ -70,7 +69,7 @@ def _select(self): l.user_id, ll.category_id, ll.expected_revenue, - ll.planned_revenue, + ll.prorated_revenue, ll.product_id, ll.product_qty, ll.product_tmpl_id diff --git a/crm_lead_product/report/crm_product_report_views.xml b/crm_lead_product/report/crm_product_report_views.xml index c65b03f6b30..440b292b635 100644 --- a/crm_lead_product/report/crm_product_report_views.xml +++ b/crm_lead_product/report/crm_product_report_views.xml @@ -9,7 +9,7 @@ - + @@ -21,7 +21,7 @@ - + @@ -40,7 +40,7 @@ - + diff --git a/crm_lead_product/static/description/index.html b/crm_lead_product/static/description/index.html index 0bbaa7a28d5..9c22830baff 100644 --- a/crm_lead_product/static/description/index.html +++ b/crm_lead_product/static/description/index.html @@ -1,10 +1,9 @@ - -Lead Line Product +CRM Lead Product -
-

Lead Line Product

+
+

CRM Lead Product

-

Beta License: LGPL-3 OCA/crm Translate me on Weblate Try me on Runboat

+

Beta License: LGPL-3 OCA/crm Translate me on Weblate Try me on Runboat

This module allows the user to link multiple products, product categories or product templates to a lead or an opportunity -in order to be able to do a product demand forecasting taking into account the leads and opportunities defined in odoo. -Included in the product line there are two computed fields, the planned revenue and expected revenue. On one hand, the -planned revenue is computed as the selling price times the quantity. On the other hand, the expected revenue takes into account +in order to be able to do a product demand forecasting taking into account the leads and opportunities defined in Odoo.

+

Included in the product line there are two computed fields, the expected revenue and prorated revenue. On one hand, the +expected revenue is computed as the selling price times the quantity. On the other hand, the prorated revenue takes into account the probability of the opportunity and is computed as the planned revenue times the probability.

The module also includes a reporting section where the user can easily see in a pivot and graph view the relationship -between products, stage of the lead/opportunity and the planned or expected revenue for that product.

+between products, stage of the lead/opportunity and the expected or prorated revenue for that product.

Table of contents

    @@ -400,7 +399,7 @@

    Usage

    • Go to menu CRM > Lead and create or edit a Lead adding all the products associated to it.
    • Go to menu CRM > My Pipeline and create or edit an Opportunity adding all the products associated to it.
    • -
    • Go to menu CRM > Reporting > Pipeline by Product to run the report that relates product to planned and expected revenue per stage
    • +
    • Go to menu CRM > Reporting > Pipeline by Product to run the report that relates product to expected and prorated revenue per stage
@@ -408,7 +407,7 @@

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -423,6 +422,7 @@

Authors

Contributors

@@ -432,7 +432,7 @@

Maintainers

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

-

This module is part of the OCA/crm project on GitHub.

+

This module is part of the OCA/crm project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/crm_lead_product/tests/__init__.py b/crm_lead_product/tests/__init__.py index ab2d5b2769b..d727a8c201f 100644 --- a/crm_lead_product/tests/__init__.py +++ b/crm_lead_product/tests/__init__.py @@ -1,3 +1,3 @@ -# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). - +# Copyright (C) 2017-2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from . import test_crm_lead_line diff --git a/crm_lead_product/tests/test_crm_lead_line.py b/crm_lead_product/tests/test_crm_lead_line.py index 048277430a8..c6da84702a9 100644 --- a/crm_lead_product/tests/test_crm_lead_line.py +++ b/crm_lead_product/tests/test_crm_lead_line.py @@ -1,12 +1,11 @@ -# Copyright 2017-19 ForgeFlow S.L. (https://www.forgeflow.com) +# Copyright 2017-2024 ForgeFlow S.L. (https://www.forgeflow.com) # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) -from odoo.tests import common +from odoo.tests.common import TransactionCase, tagged -@common.at_install(False) -@common.post_install(True) -class TestCrmLeadLine(common.TransactionCase): +@tagged("post_install", "-at_install") +class TestCrmLeadLine(TransactionCase): def setUp(self): super(TestCrmLeadLine, self).setUp() self.product_obj = self.env["product.product"] @@ -144,7 +143,7 @@ def test_02_lead_to_opportunity(self): # Check if planned revenue is correctly set for lead line 1 self.assertEqual( - self.lead.lead_line_ids[0].planned_revenue, + self.lead.lead_line_ids[0].expected_revenue, self.product_4.list_price, "Planned revenue should be equal " "to the product standard price", ) @@ -154,15 +153,15 @@ def test_02_lead_to_opportunity(self): lead_line_1 = self.lead.lead_line_ids[0] self.assertEqual( - lead_line_1.expected_revenue, - lead_line_1.planned_revenue * self.lead.probability * (1 / 100), + lead_line_1.prorated_revenue, + lead_line_1.expected_revenue * self.lead.probability * (1 / 100), "Expected revenue should be planned " "revenue times the probability", ) self.lead.write({"probability": 30}) self.assertEqual( - lead_line_1.expected_revenue, - round(lead_line_1.planned_revenue * self.lead.probability * (1 / 100), 5), + lead_line_1.prorated_revenue, + round(lead_line_1.expected_revenue * self.lead.probability * (1 / 100), 5), "Expected revenue should be planned " "revenue times the probability", ) diff --git a/crm_lead_product/views/crm_lead_line_views.xml b/crm_lead_product/views/crm_lead_line_views.xml index e4bddf3b79d..73d931734ff 100644 --- a/crm_lead_product/views/crm_lead_line_views.xml +++ b/crm_lead_product/views/crm_lead_line_views.xml @@ -1,7 +1,7 @@ - crm.lead.form.lead + crm.lead.line.tree - crm_lead_product crm.lead.line @@ -11,8 +11,8 @@ - - + + diff --git a/crm_lead_product/views/crm_lead_views.xml b/crm_lead_product/views/crm_lead_views.xml index 35f62aa245b..5273ebfe2a8 100644 --- a/crm_lead_product/views/crm_lead_views.xml +++ b/crm_lead_product/views/crm_lead_views.xml @@ -1,7 +1,7 @@ - crm.lead.form.lead + crm.lead.form - crm_lead_product crm.lead