From c8b9325423f66273abb4a5b8aa7af14d9835f4f7 Mon Sep 17 00:00:00 2001 From: Wesley Oliveira Date: Fri, 25 Sep 2026 17:54:44 -0300 Subject: [PATCH] [ADD] crm_lead_mobile: add new module --- crm_lead_mobile/README.rst | 76 +++ crm_lead_mobile/__init__.py | 0 crm_lead_mobile/__manifest__.py | 17 + crm_lead_mobile/readme/CONTRIBUTORS.rst | 3 + crm_lead_mobile/readme/DESCRIPTION.rst | 7 + crm_lead_mobile/readme/USAGE.rst | 4 + crm_lead_mobile/static/description/icon.png | Bin 0 -> 2873 bytes crm_lead_mobile/static/description/index.html | 434 ++++++++++++++++++ crm_lead_mobile/tests/__init__.py | 1 + crm_lead_mobile/tests/test_crm_lead_mobile.py | 121 +++++ crm_lead_mobile/views/crm_lead_views.xml | 28 ++ .../odoo/addons/crm_lead_mobile | 1 + setup/crm_lead_mobile/setup.py | 6 + 13 files changed, 698 insertions(+) create mode 100644 crm_lead_mobile/README.rst create mode 100644 crm_lead_mobile/__init__.py create mode 100644 crm_lead_mobile/__manifest__.py create mode 100644 crm_lead_mobile/readme/CONTRIBUTORS.rst create mode 100644 crm_lead_mobile/readme/DESCRIPTION.rst create mode 100644 crm_lead_mobile/readme/USAGE.rst create mode 100644 crm_lead_mobile/static/description/icon.png create mode 100644 crm_lead_mobile/static/description/index.html create mode 100644 crm_lead_mobile/tests/__init__.py create mode 100644 crm_lead_mobile/tests/test_crm_lead_mobile.py create mode 100644 crm_lead_mobile/views/crm_lead_views.xml create mode 120000 setup/crm_lead_mobile/odoo/addons/crm_lead_mobile create mode 100644 setup/crm_lead_mobile/setup.py diff --git a/crm_lead_mobile/README.rst b/crm_lead_mobile/README.rst new file mode 100644 index 0000000..8499e4e --- /dev/null +++ b/crm_lead_mobile/README.rst @@ -0,0 +1,76 @@ +=============== +CRM Lead Mobile +=============== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:223cd732059db2f32192d69f15104d6017d3085fd183658057893d17cf6f255c + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-Escodoo%2Fcrm--addons-lightgray.png?logo=github + :target: https://github.com/Escodoo/crm-addons/tree/16.0/crm_lead_mobile + :alt: Escodoo/crm-addons + +|badge1| |badge2| |badge3| + +This module shows the **Mobile** field of CRM opportunities next to the phone +number, both on the opportunity form and on the kanban quick create form. + +When the contact (``partner_id``) of an opportunity is set or changed, the +mobile is filled from the contact's mobile, as Odoo already does for leads. If +the contact has no mobile, the opportunity keeps the mobile it already had. The +value is stored on the opportunity, and editing it does not change the contact. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +#. Go to *CRM > Sales > My Pipeline* and create an opportunity, either with the + quick create form of the kanban or with the full form. +#. Select a contact: the *Mobile* field takes the contact's mobile. +#. Edit the *Mobile* field if needed: the contact keeps its own mobile. + +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Escodoo + +Contributors +~~~~~~~~~~~~ + +* `Escodoo `_: + + * Wesley Oliveira + +Maintainers +~~~~~~~~~~~ + +This module is part of the `Escodoo/crm-addons `_ project on GitHub. + +You are welcome to contribute. diff --git a/crm_lead_mobile/__init__.py b/crm_lead_mobile/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/crm_lead_mobile/__manifest__.py b/crm_lead_mobile/__manifest__.py new file mode 100644 index 0000000..e40e3f5 --- /dev/null +++ b/crm_lead_mobile/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2026 - TODAY, Wesley Oliveira +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "CRM Lead Mobile", + "summary": """ + Show the mobile number on opportunities and fill it from the contact""", + "version": "16.0.1.0.0", + "category": "Customer Relationship Management", + "license": "AGPL-3", + "author": "Escodoo", + "website": "https://github.com/Escodoo/crm-addons", + "depends": ["crm"], + "data": [ + "views/crm_lead_views.xml", + ], +} diff --git a/crm_lead_mobile/readme/CONTRIBUTORS.rst b/crm_lead_mobile/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..2f9bd6d --- /dev/null +++ b/crm_lead_mobile/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Escodoo `_: + + * Wesley Oliveira diff --git a/crm_lead_mobile/readme/DESCRIPTION.rst b/crm_lead_mobile/readme/DESCRIPTION.rst new file mode 100644 index 0000000..1955271 --- /dev/null +++ b/crm_lead_mobile/readme/DESCRIPTION.rst @@ -0,0 +1,7 @@ +This module shows the **Mobile** field of CRM opportunities next to the phone +number, both on the opportunity form and on the kanban quick create form. + +When the contact (``partner_id``) of an opportunity is set or changed, the +mobile is filled from the contact's mobile, as Odoo already does for leads. If +the contact has no mobile, the opportunity keeps the mobile it already had. The +value is stored on the opportunity, and editing it does not change the contact. diff --git a/crm_lead_mobile/readme/USAGE.rst b/crm_lead_mobile/readme/USAGE.rst new file mode 100644 index 0000000..598bc48 --- /dev/null +++ b/crm_lead_mobile/readme/USAGE.rst @@ -0,0 +1,4 @@ +#. Go to *CRM > Sales > My Pipeline* and create an opportunity, either with the + quick create form of the kanban or with the full form. +#. Select a contact: the *Mobile* field takes the contact's mobile. +#. Edit the *Mobile* field if needed: the contact keeps its own mobile. diff --git a/crm_lead_mobile/static/description/icon.png b/crm_lead_mobile/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..12ab0051e3b9ac413f0f0016b7cff54f02fc763e GIT binary patch literal 2873 zcmV-93&!+`P)`uGecH7++*a9tqf=D4K3Mya}O@tpzNQ@yQCf@Kr zF!+nnKqBHT7^8%kXfz5&3vvk;1t}w7Z?N*D?A{ zHrd_G%z4iDJn#2;p6~mP`2CNcJjDNjrs?X8sbe)Nav^9t4K(ppCb-d2d)&lZ>k%SMT{9YBg-a+&W{!hd#wDr8Wl{eXS z*$7*96lqpl{PUr=s8^hIiDg}g*f5f1&&S6&>%w7_k{mf$=0jJV!9`c@;PA^Op1%JL zjvcP7X-sQIgb*+?KF9@EjIw?AMgZbC#&KNql%Q6tlgni}^ZZSmdHyEeJ2=g=55CEv zmnMkgHHh!qH~xB6FC&#;=S7>@bLA+-%~=4VD8ltxIF5^^DFQzvj6#%BWV03ng*-|r z04k*>&p&>cm!5nFzZI@poU2BJnbtV_!&|uU$}y~h2|yTz*p5r9WG&z2} zgzMT!DN#yCDn%xfCZEq?8U_G%-Q$HP-sbto4&yXiD<1EPFO7UL&G{c2<=nkn(2e#} z^@9M%@$h}0bjoDo#v;0Q@};9FB8of+1YzLQY&J2?6oo>LOfJpk*PX*9*NpSZGe>#u zk%LT6G*&F`6(eG3TaNRu7-jszVWetTW!G!rx-L-^kx8c+94Mev4;4F(2?8GipD+k; zT^B>w$>nooEsH%@Z0CZHj&bnk*sdZMTrtMhorAOY5aYNW zj^iMu#L8sIWYP#BmUN9U4B9_|Ps?vnt=7opvgGFp>%@^N2Od4dtIr-Kik7z0m!uI& z6O3QDnTtL##=x*O8*qf7`Rm>4UQp;#P5$@Lpq;;yjH>WJ5(YUt#1IdZuydp@>#C#ExmKro8|zO=gyYw6f?D@) zO;dA3C`t5Rlo9o%65&TKb${xF|7l7xRh|Jrss7IhDMeQ!8kOD#v=fMk38}gh#3yucyF^u$%5|2^EB4zY-za^N18QYBnvew`D8=+@OK&R~LPuuFnak z5RxG1S0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Vp$EGw>VPtfOo4@{f#?KuE zm=)7@Wf>^snVg))^Bj~m+Y<~Fx~KLIzHyYhe((pviouqF5t7bEy+Yh_!)>t_tPT+X zVH7c4t5LNZeDuma+<5b+$>lS|aZJ;8a9xi$0wKY&=FV+48xFs@`$6_U{3>S+??hM0 zOJWkNYDUb5+iFpssh|wS7r%TpS6zECLJ0gIpfpio$BvQi5#pyFe}Q{`wvQom8v~ia zRgVooTS{lS6r>D;ZNrHuU^O2v0>bXk7=45J37f-Kl}rwLv_YC zo`+ar9as$FmK$!5y&##tw_F5a$W*n8-E#TlXD;F5OLueVjrVxyzGpb2xRbQ8a@C+$ zh;Q9+d+e?;5gjxghjO)oP?FJsF}4hhu1g#MTFduVONdVkE1hOTc8IJ|M9GsIt+j&Z z+sJbD{dKvxCUuJG5elhI>q(I({QN z2z?sv45gWOvE4eFE>qZUjkoRBK+sicvFHdR7XOOU0%|W1q%;d9)-MBq*+VWTdKUiy XXqTGI$C0NT00000NkvXXu0mjf?G|(} literal 0 HcmV?d00001 diff --git a/crm_lead_mobile/static/description/index.html b/crm_lead_mobile/static/description/index.html new file mode 100644 index 0000000..6acf42b --- /dev/null +++ b/crm_lead_mobile/static/description/index.html @@ -0,0 +1,434 @@ + + + + + +CRM Lead Mobile + + + +
+

CRM Lead Mobile

+ + +

Beta License: AGPL-3 Escodoo/crm-addons

+

This module shows the Mobile field of CRM opportunities next to the phone +number, both on the opportunity form and on the kanban quick create form.

+

When the contact (partner_id) of an opportunity is set or changed, the +mobile is filled from the contact’s mobile, as Odoo already does for leads. If +the contact has no mobile, the opportunity keeps the mobile it already had. The +value is stored on the opportunity, and editing it does not change the contact.

+

Table of contents

+ +
+

Usage

+
    +
  1. Go to CRM > Sales > My Pipeline and create an opportunity, either with the +quick create form of the kanban or with the full form.
  2. +
  3. Select a contact: the Mobile field takes the contact’s mobile.
  4. +
  5. Edit the Mobile field if needed: the contact keeps its own mobile.
  6. +
+
+
+

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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Escodoo
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is part of the Escodoo/crm-addons project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/crm_lead_mobile/tests/__init__.py b/crm_lead_mobile/tests/__init__.py new file mode 100644 index 0000000..4fbd922 --- /dev/null +++ b/crm_lead_mobile/tests/__init__.py @@ -0,0 +1 @@ +from . import test_crm_lead_mobile diff --git a/crm_lead_mobile/tests/test_crm_lead_mobile.py b/crm_lead_mobile/tests/test_crm_lead_mobile.py new file mode 100644 index 0000000..b18747c --- /dev/null +++ b/crm_lead_mobile/tests/test_crm_lead_mobile.py @@ -0,0 +1,121 @@ +# Copyright 2026 - TODAY, Wesley Oliveira +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests.common import Form, TransactionCase + + +class TestCrmLeadMobile(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.partner = cls.env["res.partner"].create( + {"name": "Mobile Partner", "mobile": "+55 11 99999-0001"} + ) + cls.partner_other = cls.env["res.partner"].create( + {"name": "Other Partner", "mobile": "+55 11 99999-0002"} + ) + cls.partner_no_mobile = cls.env["res.partner"].create( + {"name": "No Mobile Partner", "phone": "+55 11 3333-0000"} + ) + + def _create_opportunity(self, **vals): + lead = self.env["crm.lead"].create( + dict({"name": "Opportunity", "type": "opportunity"}, **vals) + ) + # Store the computed mobile now, as the end of a web request would + lead.flush_recordset() + return lead + + def test_create_fills_mobile_from_partner(self): + lead = self._create_opportunity(partner_id=self.partner.id) + self.assertEqual(lead.mobile, self.partner.mobile) + + def test_create_partner_without_mobile(self): + lead = self._create_opportunity(partner_id=self.partner_no_mobile.id) + self.assertFalse(lead.mobile) + + def test_create_explicit_mobile_is_kept(self): + lead = self._create_opportunity( + partner_id=self.partner.id, mobile="+55 21 98888-7777" + ) + self.assertEqual(lead.mobile, "+55 21 98888-7777") + + def test_write_partner_updates_mobile(self): + lead = self._create_opportunity(partner_id=self.partner.id) + lead.write({"partner_id": self.partner_other.id}) + self.assertEqual(lead.mobile, self.partner_other.mobile) + + def test_write_partner_without_mobile_keeps_mobile(self): + lead = self._create_opportunity(partner_id=self.partner.id) + lead.write({"partner_id": self.partner_no_mobile.id}) + self.assertEqual(lead.mobile, "+55 11 99999-0001") + + def test_convert_lead_to_partner_without_mobile_keeps_mobile(self): + lead = self.env["crm.lead"].create( + {"name": "Lead", "type": "lead", "mobile": "+55 21 98888-7777"} + ) + lead.flush_recordset() + wizard = ( + self.env["crm.lead2opportunity.partner"] + .with_context( + active_model="crm.lead", active_id=lead.id, active_ids=lead.ids + ) + .create( + { + "name": "convert", + "action": "exist", + "partner_id": self.partner_no_mobile.id, + } + ) + ) + wizard.action_apply() + self.assertEqual(lead.type, "opportunity") + self.assertEqual(lead.mobile, "+55 21 98888-7777") + + def test_remove_partner_keeps_mobile(self): + lead = self._create_opportunity(partner_id=self.partner.id) + lead.write({"partner_id": False}) + self.assertEqual(lead.mobile, "+55 11 99999-0001") + + def test_edit_mobile_does_not_change_partner(self): + lead = self._create_opportunity(partner_id=self.partner.id) + lead.write({"mobile": "+55 21 98888-7777"}) + self.assertEqual(lead.mobile, "+55 21 98888-7777") + self.assertEqual(self.partner.mobile, "+55 11 99999-0001") + + def test_partner_mobile_change_does_not_change_lead(self): + lead = self._create_opportunity(partner_id=self.partner.id) + self.partner.mobile = "+55 11 90000-0000" + self.assertEqual(lead.mobile, "+55 11 99999-0001") + + def test_form_onchange_partner(self): + form = Form( + self.env["crm.lead"].with_context(default_type="opportunity"), + view="crm.crm_lead_view_form", + ) + form.name = "Opportunity" + form.partner_id = self.partner + self.assertEqual(form.mobile, self.partner.mobile) + form.partner_id = self.partner_no_mobile + self.assertEqual(form.mobile, self.partner.mobile) + form.partner_id = self.partner_other + form.mobile = "+55 21 98888-7777" + lead = form.save() + self.assertEqual(lead.mobile, "+55 21 98888-7777") + self.assertEqual(self.partner_other.mobile, "+55 11 99999-0002") + + def test_quick_create_form_onchange_partner(self): + form = Form( + self.env["crm.lead"].with_context(default_type="opportunity"), + view="crm.quick_create_opportunity_form", + ) + form.name = "Quick Opportunity" + form.partner_id = self.partner + self.assertEqual(form.mobile, self.partner.mobile) + lead = form.save() + self.assertEqual(lead.mobile, self.partner.mobile) + + def test_views_show_mobile(self): + for xmlid in ("crm.crm_lead_view_form", "crm.quick_create_opportunity_form"): + arch = self.env["crm.lead"].get_view(self.env.ref(xmlid).id)["arch"] + self.assertIn('name="mobile"', arch, xmlid) diff --git a/crm_lead_mobile/views/crm_lead_views.xml b/crm_lead_mobile/views/crm_lead_views.xml new file mode 100644 index 0000000..d9da92d --- /dev/null +++ b/crm_lead_mobile/views/crm_lead_views.xml @@ -0,0 +1,28 @@ + + + + + + crm.lead.form (in crm_lead_mobile) + crm.lead + + + + + + + + + + crm.lead.form.quick_create (in crm_lead_mobile) + crm.lead + + + + + + + + + diff --git a/setup/crm_lead_mobile/odoo/addons/crm_lead_mobile b/setup/crm_lead_mobile/odoo/addons/crm_lead_mobile new file mode 120000 index 0000000..944deee --- /dev/null +++ b/setup/crm_lead_mobile/odoo/addons/crm_lead_mobile @@ -0,0 +1 @@ +../../../../crm_lead_mobile \ No newline at end of file diff --git a/setup/crm_lead_mobile/setup.py b/setup/crm_lead_mobile/setup.py new file mode 100644 index 0000000..28c57bb --- /dev/null +++ b/setup/crm_lead_mobile/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)