Skip to content

Commit

Permalink
[16.0][MIG] crm_lead_product: migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Loregs2 committed Mar 1, 2024
1 parent 0cefd4c commit d7743f8
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 56 deletions.
12 changes: 6 additions & 6 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:e329f5a385e7f3371baeccb7831a37fb163dd62362c2b8ad0d99b6a75a311fc6
!! source digest: sha256:f9edc1580999285c8e5fdd6beb4f3cb49674a14f458cded18588854baea361fc
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand All @@ -17,13 +17,13 @@ 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/16.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-16-0/crm-16-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=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -63,7 +63,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/crm/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 <https://github.com/OCA/crm/issues/new?body=module:%20crm_lead_product%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/crm/issues/new?body=module:%20crm_lead_product%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Expand Down Expand Up @@ -94,6 +94,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 <https://github.com/OCA/crm/tree/13.0/crm_lead_product>`_ project on GitHub.
This module is part of the `OCA/crm <https://github.com/OCA/crm/tree/16.0/crm_lead_product>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
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": "13.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
16 changes: 8 additions & 8 deletions crm_lead_product/models/crm_lead.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ 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
if lead_line.expected_revenue != 0:
expected_revenue += lead_line.expected_revenue
self.expected_revenue = expected_revenue

Check warning on line 20 in crm_lead_product/models/crm_lead.py

View check run for this annotation

Codecov / codecov/patch

crm_lead_product/models/crm_lead.py#L19-L20

Added lines #L19 - L20 were not covered by tests

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
# Update expected_revenue
expected_revenue = 0
for lead_line in self.lead_line_ids:
planned_revenue += lead_line.planned_revenue
expected_revenue += lead_line.expected_revenue

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

return res
4 changes: 1 addition & 3 deletions crm_lead_product/models/crm_lead_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,14 @@ 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")
price_unit = fields.Float()
planned_revenue = fields.Float(
compute="_compute_planned_revenue",
string="Planned revenue",
compute_sudo=True,
store=True,
)
expected_revenue = fields.Float(
compute="_compute_expected_revenue",
string="Expected revenue",
compute_sudo=True,
store=True,
)
Expand Down
21 changes: 10 additions & 11 deletions crm_lead_product/report/crm_product_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,31 @@ class ActivityReport(models.Model):
_description = "CRM Pipeline by Product Analysis"
_rec_name = "id"

active = fields.Boolean("Active", readonly=True)
active = fields.Boolean(readonly=True)
campaign_id = fields.Many2one("utm.campaign", "Campaing", readonly=True)
country_id = fields.Many2one("res.country", "Country", readonly=True)
company_id = fields.Many2one("res.company", "Company", readonly=True)
create_date = fields.Datetime("Create Date", readonly=True)
create_date = fields.Datetime(readonly=True)
date_closed = fields.Datetime("Closed Date", readonly=True)
date_conversion = fields.Datetime("Conversion Date", readonly=True)
date_deadline = fields.Datetime("Deadline Date", readonly=True)
date_open = fields.Datetime("Open Date", readonly=True)
lost_reason = fields.Many2one("crm.lost.reason", "Lost Reason", readonly=True)
lost_reason = fields.Many2one("crm.lost.reason", readonly=True)
name = fields.Char("Lead Name", readonly=True)
partner_id = fields.Many2one("res.partner", "Partner/Customer", readonly=True)
partner_name = fields.Char("Contact Name", readonly=True)
probability = fields.Float("Probability", group_operator="avg", readonly=True)
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(
string="Type",
selection=[("lead", "Lead"), ("opportunity", "Opportunity")],
type = fields.Selection(
[("lead", "Lead"), ("opportunity", "Opportunity")],
help="Type is used to separate Leads and Opportunities",
)
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)
product_id = fields.Many2one("product.product", "Product", readonly=True)
expected_revenue = fields.Float(readonly=True)
planned_revenue = fields.Float(readonly=True)
product_id = fields.Many2one("product.product", readonly=True)
product_qty = fields.Integer("Product Quantity", readonly=True)
product_tmpl_id = fields.Many2one(
"product.template", "Product Template", readonly=True
Expand All @@ -59,7 +58,7 @@ def _select(self):
l.date_conversion,
l.date_deadline,
l.date_open,
l.lost_reason,
l.lost_reason_id,
l.name,
l.partner_id,
l.partner_name,
Expand Down
2 changes: 1 addition & 1 deletion crm_lead_product/report/crm_product_report_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<field name="name">crm.opportunity.report.list</field>
<field name="model">crm.product.report</field>
<field name="arch" type="xml">
<tree string="Pipeline Analysis">
<tree>
<field name="create_date" />
<field name="product_id" />
<field name="product_qty" />
Expand Down
8 changes: 4 additions & 4 deletions crm_lead_product/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,9 @@ <h1 class="title">Lead Line Product</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:e329f5a385e7f3371baeccb7831a37fb163dd62362c2b8ad0d99b6a75a311fc6
!! source digest: sha256:f9edc1580999285c8e5fdd6beb4f3cb49674a14f458cded18588854baea361fc
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/13.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-13-0/crm-13-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=13.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<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
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
Expand Down Expand Up @@ -408,7 +408,7 @@ <h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/crm/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/crm/issues/new?body=module:%20crm_lead_product%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/crm/issues/new?body=module:%20crm_lead_product%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -432,7 +432,7 @@ <h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/crm/tree/13.0/crm_lead_product">OCA/crm</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/crm/tree/16.0/crm_lead_product">OCA/crm</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
41 changes: 20 additions & 21 deletions crm_lead_product/tests/test_crm_lead_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,45 @@
from odoo.tests import common


@common.at_install(False)
@common.post_install(True)
class TestCrmLeadLine(common.TransactionCase):
def setUp(self):
super(TestCrmLeadLine, self).setUp()
self.product_obj = self.env["product.product"]
self.lead_line_obj = self.env["crm.lead.line"]
self.lead = self.env["crm.lead"].create(
@classmethod
def setUpClass(cls):
super(TestCrmLeadLine, cls).setUpClass()
cls.product_obj = cls.env["product.product"]
cls.lead_line_obj = cls.env["crm.lead.line"]
cls.lead = cls.env["crm.lead"].create(
{
"type": "lead",
"name": "Test lead new",
"partner_id": self.env.ref("base.res_partner_1").id,
"partner_id": cls.env.ref("base.res_partner_1").id,
"description": "This is the description of the test new lead.",
"team_id": self.env.ref("sales_team.team_sales_department").id,
"team_id": cls.env.ref("sales_team.team_sales_department").id,
}
)

# Products
self.product_1 = self.product_obj.create(
cls.product_1 = cls.product_obj.create(
{
"name": "Product 1",
"categ_id": self.env.ref("product.product_category_1").id,
"price": 142.0,
"categ_id": cls.env.ref("product.product_category_1").id,
"lst_price": 142.0,
}
)
self.product_2 = self.product_obj.create(
cls.product_2 = cls.product_obj.create(
{
"name": "Product 2",
"categ_id": self.env.ref("product.product_category_2").id,
"price": 1420.0,
"categ_id": cls.env.ref("product.product_category_2").id,
"lst_price": 1420.0,
}
)
self.product_3 = self.product_obj.create(
cls.product_3 = cls.product_obj.create(
{
"name": "Product 3",
"categ_id": self.env.ref("product.product_category_3").id,
"price": 14200.0,
"categ_id": cls.env.ref("product.product_category_3").id,
"lst_price": 14200.0,
}
)
self.product_4 = self.env.ref("product.product_product_25")
cls.product_4 = cls.env.ref("product.product_product_25")

def test_01_lead_lines(self):
"""Tests for Crm Lead Line"""
Expand All @@ -55,7 +54,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.lst_price,
}
)
# Create new lead line with category id
Expand Down Expand Up @@ -149,7 +148,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
2 changes: 1 addition & 1 deletion crm_lead_product/views/crm_lead_line_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<field name="name">crm.lead.form.lead</field>
<field name="model">crm.lead.line</field>
<field name="arch" type="xml">
<tree string="Products" editable="bottom">
<tree editable="bottom">
<field name="product_id" />
<field name="category_id" />
<field name="product_tmpl_id" />
Expand Down

0 comments on commit d7743f8

Please sign in to comment.