Skip to content

Commit 33e6383

Browse files
committedMar 18, 2020
[FIX] unit tests in crm_lead_firstname, linting errors, minor review changes
1 parent 10c1a06 commit 33e6383

File tree

9 files changed

+31
-28
lines changed

9 files changed

+31
-28
lines changed
 

‎crm_lead_firstname/__manifest__.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
# © 2016 Antiun Ingeniería S.L. - Jairo Llopis
1+
# Copyright 2016 Antiun Ingeniería S.L. - Jairo Llopis
22
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
33
{
44
"name": "Firstname and Lastname in Leads",
55
"summary": "Specify split names for contacts in leads",
66
"version": "13.0.1.0.0",
77
"category": "Customer Relationship Management",
8-
"website": "http://www.github.com/OCA/crm",
8+
"website": "http://github.com/OCA/crm",
99
"author": "Tecnativa, Odoo Community Association (OCA)",
1010
"license": "AGPL-3",
1111
"application": False,
1212
"installable": True,
13-
"depends": ["crm", "partner_firstname",],
14-
"data": ["views/crm_lead_view.xml",],
13+
"depends": ["crm", "partner_firstname"],
14+
"data": ["views/crm_lead_view.xml"],
1515
}

‎crm_lead_firstname/models/crm_lead.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# © 2016 Antiun Ingeniería S.L. - Jairo Llopis
1+
# Copyright 2016 Antiun Ingeniería S.L. - Jairo Llopis
22
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
33

44
from odoo import fields, models
@@ -17,15 +17,11 @@ def _create_lead_partner_data(self, name, is_company, parent_id=False):
1717
)
1818
if not is_company:
1919
if self.contact_name:
20-
lead_partner_data.update(
21-
{"firstname": self.contact_name,}
22-
)
20+
lead_partner_data.update({"firstname": self.contact_name})
2321
if "name" in lead_partner_data:
2422
del lead_partner_data["name"]
2523
if self.contact_lastname:
26-
lead_partner_data.update(
27-
{"lastname": self.contact_lastname,}
28-
)
24+
lead_partner_data.update({"lastname": self.contact_lastname})
2925
if "name" in lead_partner_data:
3026
del lead_partner_data["name"]
3127
return lead_partner_data
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
* Rafael Blasco
22
* Jairo Llopis
33
* Raf Ven <raf.ven@dynapps.be>
4+
* Nikos Tsirintanis <ntsirintanis@therp.nl>
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
This module extends the functionality of CRM leads to support split first and
22
last name fields for contacts and allow you to port that information to and
33
from partners.
4+
Since leads are expected to create partners only when needed and after
5+
information is correctly set up, in leads there is no inverse logic to
6+
transform the old single name in the new split names automatically. The old
7+
single name will simply be the firstname now.

‎crm_lead_firstname/readme/INSTALL.rst

-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
Since leads are expected to create partners only when needed and after
2-
information is correctly set up, in leads there is no inverse logic to
3-
transform the old single name in the new split names automatically. The old
4-
single name will simply be the firstname now.
5-
61
To install this module, you need to:
72

83
* Install `OCA/partner-contact <https://github.com/OCA/partner-contact>`_ repo.
+11-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
# © 2016 Antiun Ingeniería S.L. - Jairo Llopis
1+
# Copyright 2016 Antiun Ingeniería S.L. - Jairo Llopis
22
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
33

4-
from odoo.tests.common import SavepointCase
4+
from odoo.tests.common import Form, SavepointCase
55

66

77
class FirstNameCase(SavepointCase):
88
@classmethod
99
def setUpClass(cls):
1010
super(FirstNameCase, cls).setUpClass()
11+
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
1112
cls.lead_model = cls.env["crm.lead"]
1213
cls.partner_model = cls.env["res.partner"]
1314
cls.lead = cls.lead_model.create(
@@ -19,7 +20,7 @@ def setUpClass(cls):
1920
}
2021
)
2122
cls.partner = cls.partner_model.create(
22-
{"firstname": "Firçt name", "lastname": "Laçt name",}
23+
{"firstname": "Firçt name", "lastname": "Laçt name"}
2324
)
2425

2526
def test_create_contact(self):
@@ -31,15 +32,14 @@ def test_create_contact(self):
3132

3233
def test_create_contact_empty(self):
3334
"""No problems creating a contact without names."""
34-
self.lead.write(
35-
{"contact_name": False, "contact_lastname": False,}
36-
)
35+
self.lead.write({"contact_name": False, "contact_lastname": False})
3736
self.lead.handle_partner_assignation()
3837

3938
def test_onchange_partner(self):
4039
"""When changing partner, fields get correctly updated."""
41-
with self.env.do_in_onchange():
42-
self.lead.partner_id = self.partner
43-
value = self.lead._onchange_partner_id_values(self.partner.id)
44-
self.assertEqual(self.partner.firstname, value["contact_name"])
45-
self.assertEqual(self.partner.lastname, value["contact_lastname"])
40+
with Form(self.env["crm.lead"], view="crm.crm_lead_view_form") as lead_form:
41+
lead_form.partner_id = self.partner
42+
lead_form.name = self.partner.name
43+
lead_form.save()
44+
self.assertEqual(self.partner.firstname, lead_form.contact_name)
45+
self.assertEqual(self.partner.lastname, lead_form.contact_lastname)

‎crm_lead_firstname/views/crm_lead_view.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8" ?>
2-
<!-- © 2016 Antiun Ingeniería S.L. - Jairo Llopis
2+
<!-- Copyright 2016 Antiun Ingeniería S.L. - Jairo Llopis
33
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
44
<odoo>
55
<record id="crm_lead_view_form" model="ir.ui.view">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../crm_lead_firstname

‎setup/crm_lead_firstname/setup.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=['setuptools-odoo'],
5+
odoo_addon=True,
6+
)

0 commit comments

Comments
 (0)