Skip to content

Commit

Permalink
[MIG] crm_lead_product: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrià Pallejà committed Jul 8, 2024
1 parent d78904a commit b748b5b
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 20 deletions.
4 changes: 2 additions & 2 deletions crm_lead_product/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Lead Line Product
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:b633f77ecc5743ac9ec2b765d721a2d982d1ebe2fc3c3f475f8744a2721b4570
!! source digest: sha256:0acabe42671b77fe09c6f4e64af8c57501f23332ffdae4e51746dd9701d740f3
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down Expand Up @@ -79,7 +79,7 @@ Contributors
~~~~~~~~~~~~


* Adria Gil Sorribes <adria.gil@forgeflow.com>
* Adria Palleja Bove <adria.palleja@coopdevs.org>

Maintainers
~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion crm_lead_product/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "Lead Line Product",
"version": "16.0.1.0.1",
"version": "16.0.1.0.0",
"category": "Customer Relationship Management",
"license": "LGPL-3",
"summary": "Adds a lead line in the lead/opportunity model " "in odoo",
Expand Down
4 changes: 2 additions & 2 deletions crm_lead_product/models/crm_lead.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def _onchange_lead_line_ids(self):
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
self.expected_revenue = planned_revenue

def _convert_opportunity_data(self, customer, team_id=False):
res = super(CrmLead, self)._convert_opportunity_data(customer, team_id)
Expand All @@ -27,6 +27,6 @@ def _convert_opportunity_data(self, customer, team_id=False):
for lead_line in self.lead_line_ids:
planned_revenue += lead_line.planned_revenue

res["planned_revenue"] = planned_revenue
res["expected_revenue"] = planned_revenue

return res
2 changes: 1 addition & 1 deletion crm_lead_product/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

* Adria Gil Sorribes <adria.gil@forgeflow.com>
* Adria Palleja Bove <adria.palleja@coopdevs.org>
5 changes: 2 additions & 3 deletions crm_lead_product/report/crm_product_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ActivityReport(models.Model):
probability = fields.Float(group_operator="avg", readonly=True)
stage_id = fields.Many2one("crm.stage", "Stage", readonly=True)
team_id = fields.Many2one("crm.team", "Sales Team", readonly=True)
type = fields.Char(
type = fields.Selection(
selection=[("lead", "Lead"), ("opportunity", "Opportunity")],
help="Type is used to separate Leads and Opportunities",
)
Expand All @@ -49,7 +49,6 @@ def _select(self):
SELECT
l.id,
l.active,
l.id as lead_id,
l.campaign_id,
l.country_id,
l.company_id,
Expand All @@ -58,7 +57,7 @@ def _select(self):
l.date_conversion,
l.date_deadline,
l.date_open,
l.lost_reason,
l.lost_reason_id as lost_reason,
l.name,
l.partner_id,
l.partner_name,
Expand Down
4 changes: 2 additions & 2 deletions crm_lead_product/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Lead Line Product</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:b633f77ecc5743ac9ec2b765d721a2d982d1ebe2fc3c3f475f8744a2721b4570
!! source digest: sha256:0acabe42671b77fe09c6f4e64af8c57501f23332ffdae4e51746dd9701d740f3
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/crm/tree/16.0/crm_lead_product"><img alt="OCA/crm" src="https://img.shields.io/badge/github-OCA%2Fcrm-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/crm-16-0/crm-16-0-crm_lead_product"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/crm&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows the user to link multiple products, product categories or product templates to a lead or an opportunity
Expand Down Expand Up @@ -422,7 +422,7 @@ <h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<ul class="simple">
<li>Adria Gil Sorribes &lt;<a class="reference external" href="mailto:adria.gil&#64;forgeflow.com">adria.gil&#64;forgeflow.com</a>&gt;</li>
<li>Adria Palleja Bove &lt;<a class="reference external" href="mailto:adria.palleja&#64;coopdevs.org">adria.palleja&#64;coopdevs.org</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
64 changes: 55 additions & 9 deletions crm_lead_product/tests/test_crm_lead_line.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Copyright 2017-19 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 import TransactionCase, tagged


@common.at_install(False)
@common.post_install(True)
class TestCrmLeadLine(common.TransactionCase):
@tagged("-at_install", "post_install")
class TestCrmLeadLine(TransactionCase):
def setUp(self):
super(TestCrmLeadLine, self).setUp()
self.product_obj = self.env["product.product"]
Expand All @@ -26,21 +25,18 @@ def setUp(self):
{
"name": "Product 1",
"categ_id": self.env.ref("product.product_category_1").id,
"price": 142.0,
}
)
self.product_2 = self.product_obj.create(
{
"name": "Product 2",
"categ_id": self.env.ref("product.product_category_2").id,
"price": 1420.0,
}
)
self.product_3 = self.product_obj.create(
{
"name": "Product 3",
"categ_id": self.env.ref("product.product_category_3").id,
"price": 14200.0,
}
)
self.product_4 = self.env.ref("product.product_product_25")
Expand All @@ -55,7 +51,7 @@ def test_01_lead_lines(self):
"name": self.product_1.name,
"product_id": self.product_1.id,
"uom_id": self.product_1.uom_id.id,
"price_unit": self.product_1.price,
"price_unit": self.product_1.get_contextual_price(),
}
)
# Create new lead line with category id
Expand Down Expand Up @@ -121,6 +117,56 @@ def test_01_lead_lines(self):
"Lead line product template should be equal " "to None",
)

# Don't define lead id and shouldn't be defined product template neither
lead_line_5 = self.lead_line_obj.create(
{
"name": self.product_1.name,
"product_id": self.product_1.id,
"uom_id": self.product_1.uom_id.id,
}
)

lead_line_5._onchange_product_id()
lead_line_5._onchange_product_tmpl_id()
lead_line_5._onchange_category_id()
lead_line_5._onchange_uom_id()

self.assertNotEqual(
lead_line_5.product_tmpl_id,
self.product_1.product_tmpl_id,
"Lead line product template should be equal to None",
)

# Computes lead line price unit
computed_price = self.product_1.uom_id._compute_price(
self.product_1.list_price, self.product_1.uom_id
)

self.assertEqual(
lead_line_5.price_unit,
computed_price,
"Lead line price unit should be equal to computed price",
)

lead_line_6 = self.lead_line_obj.create(
{
"lead_id": self.lead.id,
"name": "",
"category_id": self.product_3.categ_id.id,
"product_id": self.product_2.id,
"product_tmpl_id": self.product_3.product_tmpl_id.id,
}
)

lead_line_6._onchange_product_tmpl_id()

# Check if there are already defined product and remove if it does not match
self.assertNotEqual(
lead_line_6.product_id,
self.product_2.id,
"Lead line product id should be equal to None",
)

def test_02_lead_to_opportunity(self):
# Write one lead line to CRM Lead
self.lead.write(
Expand Down Expand Up @@ -149,7 +195,7 @@ def test_02_lead_to_opportunity(self):
"Planned revenue should be equal " "to the product standard price",
)

self.lead.convert_opportunity(self.env.ref("base.res_partner_1").id)
self.lead.convert_opportunity(self.env.ref("base.res_partner_1"))

lead_line_1 = self.lead.lead_line_ids[0]

Expand Down

0 comments on commit b748b5b

Please sign in to comment.