[IMP] mail_plugin: hide the create button if we do not have access right
Purpose ======= Hide the "Create Partner" button if we do not have the "create" access right. Do not offer to create a project if the current user can't. Do not try to enrich if we can't create a partner. The write access on the partner is checked on the record itself because of access rules. Task-2826471 X-original-commit: b678a9bc1298e9a1973074740a8c8a1d471b6848 Part-of: odoo/odoo#93058
This commit is contained in:
@@ -111,3 +111,17 @@ msgstr ""
|
||||
#, python-format
|
||||
msgid "Save Contact to create new Opportunities."
|
||||
msgstr ""
|
||||
|
||||
#. module: crm_mail_plugin
|
||||
#. openerp-web
|
||||
#: code:addons/crm_mail_plugin/static/src/to_translate/translations_outlook.xml:0
|
||||
#, python-format
|
||||
msgid "The Contact needs to exist to create Opportunity."
|
||||
msgstr ""
|
||||
|
||||
#. module: crm_mail_plugin
|
||||
#. openerp-web
|
||||
#: code:addons/crm_mail_plugin/static/src/to_translate/translations_gmail.xml:0
|
||||
#, python-format
|
||||
msgid "You can only create opportunities for existing customers."
|
||||
msgstr ""
|
||||
|
||||
@@ -10,4 +10,5 @@
|
||||
<string>%(expected_revenue)s at %(probability)s%</string>
|
||||
<string>%(expected_revenue)s + %(recurring_revenue)s %(recurring_plan)s at %(probability)s%</string>
|
||||
<string>Save Contact to create new Opportunities.</string>
|
||||
<string>You can only create opportunities for existing customers.</string>
|
||||
</ressources>
|
||||
|
||||
@@ -8,4 +8,5 @@
|
||||
<string>%(expected_revenue)s + %(recurring_revenue)s %(recurring_plan)s at %(probability)s%</string>
|
||||
<string>Save Contact to create new Opportunities.</string>
|
||||
<string>No opportunities found for this contact.</string>
|
||||
<string>The Contact needs to exist to create Opportunity.</string>
|
||||
</ressources>
|
||||
|
||||
@@ -9,6 +9,7 @@ from werkzeug.exceptions import Forbidden
|
||||
|
||||
from odoo import http, tools, _
|
||||
from odoo.addons.iap.tools import iap_tools
|
||||
from odoo.exceptions import AccessError
|
||||
from odoo.http import request
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
@@ -168,7 +169,10 @@ class MailPluginController(http.Controller):
|
||||
'enrichment_info': None,
|
||||
}
|
||||
company = self._find_existing_company(normalized_email)
|
||||
if not company: # create and enrich company
|
||||
|
||||
can_create_partner = request.env['res.partner'].check_access_rights('create', raise_exception=False)
|
||||
|
||||
if not company and can_create_partner: # create and enrich company
|
||||
company, enrichment_info = self._create_company_from_iap(normalized_email)
|
||||
response['partner']['enrichment_info'] = enrichment_info
|
||||
response['partner']['company'] = self._get_company_data(company)
|
||||
@@ -366,8 +370,14 @@ class MailPluginController(http.Controller):
|
||||
partner_values['title'] = partner.function
|
||||
partner_values['enrichment_info'] = None
|
||||
|
||||
return partner_values
|
||||
try:
|
||||
partner.check_access_rights('write')
|
||||
partner.check_access_rule('write')
|
||||
partner_values['can_write_on_partner'] = True
|
||||
except AccessError:
|
||||
partner_values['can_write_on_partner'] = False
|
||||
|
||||
return partner_values
|
||||
|
||||
def _get_contact_data(self, partner):
|
||||
"""
|
||||
@@ -387,7 +397,9 @@ class MailPluginController(http.Controller):
|
||||
|
||||
return {
|
||||
'partner': partner_response,
|
||||
'user_companies': request.env['res.users'].browse(request.uid).company_ids.ids
|
||||
'user_companies': request.env.user.company_ids.ids,
|
||||
'can_create_partner': request.env['res.partner'].check_access_rights(
|
||||
'create', raise_exception=False),
|
||||
}
|
||||
|
||||
def _mail_content_logging_models_whitelist(self):
|
||||
|
||||
@@ -44,6 +44,8 @@ class MailPluginController(mail_plugin.MailPluginController):
|
||||
} for task in partner_tasks if task.project_id.id in accessible_projects]
|
||||
|
||||
contact_values['tasks'] = tasks_values
|
||||
contact_values['can_create_project'] = request.env['project.project'].check_access_rights(
|
||||
'create', raise_exception=False)
|
||||
|
||||
return contact_values
|
||||
|
||||
|
||||
@@ -85,6 +85,13 @@ msgstr ""
|
||||
msgid "Log the email on the task"
|
||||
msgstr ""
|
||||
|
||||
#. module: project_mail_plugin
|
||||
#. openerp-web
|
||||
#: code:addons/project_mail_plugin/static/src/to_translate/translations_gmail.xml:0
|
||||
#, python-format
|
||||
msgid "No project"
|
||||
msgstr ""
|
||||
|
||||
#. module: project_mail_plugin
|
||||
#. openerp-web
|
||||
#: code:addons/project_mail_plugin/static/src/to_translate/translations_gmail.xml:0
|
||||
@@ -188,9 +195,26 @@ msgstr ""
|
||||
msgid "Tasks (%s)"
|
||||
msgstr ""
|
||||
|
||||
#. module: project_mail_plugin
|
||||
#. openerp-web
|
||||
#: code:addons/project_mail_plugin/static/src/to_translate/translations_gmail.xml:0
|
||||
#: code:addons/project_mail_plugin/static/src/to_translate/translations_outlook.xml:0
|
||||
#, python-format
|
||||
msgid "The Contact needs to exist to create Task."
|
||||
msgstr ""
|
||||
|
||||
#. module: project_mail_plugin
|
||||
#. openerp-web
|
||||
#: code:addons/project_mail_plugin/static/src/to_translate/translations_gmail.xml:0
|
||||
#, python-format
|
||||
msgid "The project name is required"
|
||||
msgstr ""
|
||||
|
||||
#. module: project_mail_plugin
|
||||
#. openerp-web
|
||||
#: code:addons/project_mail_plugin/static/src/to_translate/translations_gmail.xml:0
|
||||
#, python-format
|
||||
msgid ""
|
||||
"There are no project in your database. Please ask your project manager to "
|
||||
"create one."
|
||||
msgstr ""
|
||||
|
||||
@@ -20,4 +20,7 @@
|
||||
<string>Save the contact to create new tasks.</string>
|
||||
<string>The project name is required</string>
|
||||
<string>No project found.</string>
|
||||
<string>The Contact needs to exist to create Task.</string>
|
||||
<string>No project</string>
|
||||
<string>There are no project in your database. Please ask your project manager to create one.</string>
|
||||
</ressources>
|
||||
|
||||
@@ -9,4 +9,7 @@
|
||||
<string>Create %(name)s</string>
|
||||
<string>Search Projects...</string>
|
||||
<string>Log Email Into Task</string>
|
||||
<string>The Contact needs to exist to create Task.</string>
|
||||
<string>No Project Found</string>
|
||||
<string>No project</string>
|
||||
</ressources>
|
||||
|
||||
Reference in New Issue
Block a user