[REF] [crm_]mail_client_extension, base_setup, crm[_iap_lead_enrich], iap: split mail specific and crm specific code

- split the mail_client_extension module onto two modules:
  1) module mail_client_extension having mail/contact specific code,
  depends on iap and contacts only
  2) module crm_mail_client_extension having crm specific code,
  depends on CRM and mail_client_extension.

  Purpose is to allow the user to use the mail_client_extension
  without needing to install CRM, this will also allow
  the usage of the mail connector in other modules without
  the need for CRM.

- add the module_mail_client_extension field to the
  res_config_settings model of the base_setup module
  in order to enable the user to install the
  mail_client_extension module directly from the settings

- move the crm_lead model from the mail_client_extension_module
  to the newly created crm_mail_client_extension_module, as this
  model is no longer needed by the mail_client_extension module
  because it no longer not implemants CRM functionality

- move the iap_enrich_api model from the crm_iap_lead_enrich
  module onto the iap module as it is only related to contacts
  and not to CRM, this way it can be used in other modules such
  as the mail_client_extension module without the need for CRM
  module

Task-2382870
UPG-PR: https://github.com/odoo/upgrade/pull/2156
COM-PR: https://github.com/odoo/odoo/pull/66139
This commit is contained in:
nounoubensebia
2021-03-29 11:59:11 +00:00
parent fa26aaaa07
commit 6c81ee556f
22 changed files with 110 additions and 59 deletions
@@ -22,6 +22,9 @@ class ResConfigSettings(models.TransientModel):
string='Allow the users to synchronize their calendar with Google Calendar')
module_microsoft_calendar = fields.Boolean(
string='Allow the users to synchronize their calendar with Outlook Calendar')
module_mail_client_extension = fields.Boolean(
string='Allow integration with the mail plugins'
)
module_google_drive = fields.Boolean("Attach Google documents to any record")
module_google_spreadsheet = fields.Boolean("Google Spreadsheet")
module_auth_oauth = fields.Boolean("Use external authentication providers (OAuth)")
@@ -210,17 +210,15 @@
<h2>Integrations</h2>
<div class="row mt16 o_settings_container" name="integration">
<div class="col-12 col-lg-6 o_setting_box" id="external_pads_setting">
<div class="col-12 col-lg-6 o_setting_box" id="mail_client_extension_setting">
<div class="o_setting_left_pane">
<field name="module_pad"/>
<field name="module_mail_client_extension" />
</div>
<div class="o_setting_right_pane">
<label for="module_pad"/>
<label string="Mail Client Extension" for="module_mail_client_extension"/>
<a href="https://www.odoo.com/documentation/user/crm/optimize/outlook_extension.html" title="Documentation" class="o_doc_link" target="_blank"></a>
<div class="text-muted">
Use external pads in Odoo Notes
</div>
<div class="content-group" attrs="{'invisible': [('module_pad','=',False)]}" id="msg_module_pad">
<div class="text-warning mt16"><strong>Save</strong> this page and come back here to set up the feature.</div>
Integrate with mail client plugins
</div>
</div>
</div>
@@ -239,6 +237,20 @@
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box" id="external_pads_setting">
<div class="o_setting_left_pane">
<field name="module_pad"/>
</div>
<div class="o_setting_right_pane">
<label for="module_pad"/>
<div class="text-muted">
Use external pads in Odoo Notes
</div>
<div class="content-group" attrs="{'invisible': [('module_pad','=',False)]}" id="msg_module_pad">
<div class="text-warning mt16"><strong>Save</strong> this page and come back here to set up the feature.</div>
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box" id="sync_google_calendar_setting">
<div class="o_setting_left_pane">
<field name="module_google_calendar" />
-1
View File
@@ -39,7 +39,6 @@ class ResConfigSettings(models.TransientModel):
module_crm_iap_lead = fields.Boolean("Generate new leads based on their country, industries, size, etc.")
module_crm_iap_lead_website = fields.Boolean("Create Leads/Opportunities from your website's traffic")
module_crm_iap_lead_enrich = fields.Boolean("Enrich your leads automatically with company data based on their email address.")
module_mail_client_extension = fields.Boolean("See and manage users, companies, and leads from our mail client extensions.")
lead_enrich_auto = fields.Selection([
('manual', 'Enrich leads on demand only'),
('auto', 'Enrich all leads automatically'),
@@ -119,19 +119,6 @@
<h2>Lead Generation</h2>
<div class="row mt16 o_settings_container" name="convert_visitor_setting_container">
<div class="col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="module_mail_client_extension"/>
</div>
<div class="o_setting_right_pane" id="mail_client_extension">
<label string="Outlook CRM Extension" for="module_mail_client_extension"/>
<a href="https://www.odoo.com/documentation/user/crm/optimize/outlook_extension.html" title="Documentation" class="o_doc_link" target="_blank"></a>
<div class="text-muted">
Turn emails received in your Outlook mailbox into leads and log their content as internal notes.
</div>
</div>
</div>
<div class="col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="module_crm_iap_lead_enrich"/>
@@ -2,5 +2,4 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import crm_lead
from . import iap_enrich_api
from . import res_config_settings
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import common
from . import test_lead_enrich
@@ -2,7 +2,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.crm.tests.common import TestCrmCommon
from odoo.addons.crm_iap_lead_enrich.tests.common import MockIAPEnrich
from odoo.addons.iap.tests.common import MockIAPEnrich
from odoo.tests.common import users
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import models
from . import controllers
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': 'CRM Mail Client Extension',
'version': '1.0',
'category': 'Sales/CRM',
'sequence': 5,
'summary': 'Turn emails received in your mailbox into leads and log their content as internal notes.',
'description': "Turn emails received in your mailbox into leads and log their content as internal notes.",
'website': 'https://www.odoo.com/page/crm',
'depends': [
'crm',
'mail_client_extension',
],
'data': [
'views/crm_mail_client_extension_lead.xml'
],
'installable': True,
'application': False,
'auto_install': True
}
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import mail_plugin
@@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import logging
import werkzeug
from odoo import http
from odoo.http import request
from odoo.tools.misc import formatLang
_logger = logging.getLogger(__name__)
class MailPluginController(http.Controller):
@http.route('/mail_client_extension/log_single_mail_content', type="json", auth="outlook", cors="*")
def log_single_mail_content(self, lead, message, **kw):
crm_lead = request.env['crm.lead'].browse(lead)
crm_lead.message_post(body=message)
@http.route('/mail_client_extension/lead/get_by_partner_id', type="json", auth="outlook", cors="*")
def crm_lead_get_by_partner_id(self, partner, limit, offset, **kwargs):
partner_leads = request.env['crm.lead'].search([('partner_id', '=', partner)], offset=offset, limit=limit)
leads = []
for lead in partner_leads:
leads.append({
'id': lead.id,
'name': lead.name,
'expected_revenue': formatLang(request.env, lead.expected_revenue, monetary=True, currency_obj=lead.company_currency),
})
return {'leads': leads}
@http.route('/mail_client_extension/lead/create_from_partner', type='http', auth='user', methods=['GET'])
def crm_lead_redirect_form_view(self, partner_id):
server_action = http.request.env.ref("crm_mail_client_extension.lead_creation_prefilled_action")
return werkzeug.utils.redirect('/web#action=%s&model=crm.lead&partner_id=%s' % (server_action.id, int(partner_id)))
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import crm_lead
+1
View File
@@ -3,3 +3,4 @@
from . import iap_account
from . import res_config_settings
from . import iap_enrich_api
+1
View File
@@ -2,3 +2,4 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import test_iap
from . import common
@@ -6,7 +6,7 @@ from unittest.mock import patch
from odoo import exceptions
from odoo.addons.iap.tools import iap_tools
from odoo.addons.crm_iap_lead_enrich.models.iap_enrich_api import IapEnrichAPI
from odoo.addons.iap.models.iap_enrich_api import IapEnrichAPI
from odoo.tests import common
+4 -1
View File
@@ -1,2 +1,5 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import models
from . import controllers
from . import controllers
+4 -6
View File
@@ -6,17 +6,15 @@
'version': '1.0',
'category': 'Sales/CRM',
'sequence': 5,
'summary': 'Turn emails received in your Outlook mailbox into leads and log their content as internal notes.',
'description': "Turn emails received in your Outlook mailbox into leads and log their content as internal notes.",
'website': 'https://www.odoo.com/page/crm',
'summary': 'Allows integration with mail plugins.',
'description': "Integrate Odoo with your mailbox, get information about contacts directly inside your mailbox, log content of emails as internal notes",
'depends': [
'web',
'crm',
'crm_iap_lead_enrich'
'contacts',
'iap'
],
'data': [
'views/mail_client_extension_login.xml',
'views/mail_client_extension_lead.xml',
],
'installable': True,
'application': False,
@@ -5,12 +5,10 @@ import base64
import json
import logging
import requests
import werkzeug
from odoo import http, tools
from odoo.addons.iap.tools import iap_tools
from odoo.http import request
from odoo.tools.misc import formatLang
_logger = logging.getLogger(__name__)
@@ -175,26 +173,3 @@ class MailPluginController(http.Controller):
response = {'id': partner.id}
return response
@http.route('/mail_client_extension/log_single_mail_content', type="json", auth="outlook", cors="*")
def log_single_mail_content(self, lead, message, **kw):
crm_lead = request.env['crm.lead'].browse(lead)
crm_lead.message_post(body=message)
@http.route('/mail_client_extension/lead/get_by_partner_id', type="json", auth="outlook", cors="*")
def crm_lead_get_by_partner_id(self, partner, limit, offset, **kwargs):
partner_leads = request.env['crm.lead'].search([('partner_id', '=', partner)], offset=offset, limit=limit)
leads = []
for lead in partner_leads:
leads.append({
'id': lead.id,
'name': lead.name,
'expected_revenue': formatLang(request.env, lead.expected_revenue, monetary=True, currency_obj=lead.company_currency),
})
return {'leads': leads}
@http.route('/mail_client_extension/lead/create_from_partner', type='http', auth='user', methods=['GET'])
def crm_lead_redirect_form_view(self, partner_id):
server_action = http.request.env.ref("mail_client_extension.lead_creation_prefilled_action")
return werkzeug.utils.redirect('/web#action=%s&model=crm.lead&partner_id=%s' % (server_action.id, int(partner_id)))
@@ -1,3 +1,5 @@
from . import crm_lead
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import ir_http
from . import res_partner
from . import ir_http