[IMP] project_mail_plugin: add support for the gmail plugin
Purpose ======= Allow users to connect their tasks to their Gmail mailbox. Specifications ============== Show the tasks related to the current partner (the sender of the opened email) and allow to open them in Odoo. Allow the users to create a task from the current email. He could search the projects in which he want to create the task or even create a new project. Return the new of the newly created task. Return the customer and his image when searching a project. Task-2518668 See odoo/mail-client-extensions/pull/12
This commit is contained in:
@@ -32,6 +32,7 @@ class MailPluginController(mail_plugin.MailPluginController):
|
||||
{
|
||||
'task_id': task.id,
|
||||
'name': task.name,
|
||||
'project_name': task.project_id.name,
|
||||
} for task in partner_tasks if task.project_id.id in accessible_projects]
|
||||
|
||||
contact_values['tasks'] = tasks_values
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
from odoo import http
|
||||
from odoo import http, _
|
||||
from odoo.http import request
|
||||
|
||||
|
||||
@@ -16,14 +16,14 @@ class ProjectClient(http.Controller):
|
||||
{
|
||||
'project_id': project.id,
|
||||
'name': project.name,
|
||||
'partner_name': project.partner_id.name,
|
||||
'company_id': project.company_id.id
|
||||
}
|
||||
for project in projects
|
||||
for project in projects.sudo()
|
||||
]
|
||||
|
||||
@http.route('/mail_plugin/task/create', type='json', auth='outlook', cors="*")
|
||||
def task_create(self, email_subject, email_body, project_id, partner_id):
|
||||
|
||||
partner = request.env['res.partner'].browse(partner_id).exists()
|
||||
if not partner:
|
||||
return {'error': 'partner_not_found'}
|
||||
@@ -31,6 +31,9 @@ class ProjectClient(http.Controller):
|
||||
if not request.env['project.project'].browse(project_id).exists():
|
||||
return {'error': 'project_not_found'}
|
||||
|
||||
if not email_subject:
|
||||
email_subject = _('Task for %s', partner.name)
|
||||
|
||||
record = request.env['project.task'].create({
|
||||
'name': email_subject,
|
||||
'partner_id': partner_id,
|
||||
@@ -39,7 +42,7 @@ class ProjectClient(http.Controller):
|
||||
'user_id': request.env.uid,
|
||||
})
|
||||
|
||||
return {'task_id': record.id}
|
||||
return {'task_id': record.id, 'name': record.name}
|
||||
|
||||
@http.route('/mail_plugin/project/create', type='json', auth='outlook', cors="*")
|
||||
def project_create(self, name):
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Terms to translate for the Gmail plugin
|
||||
-->
|
||||
<ressources>
|
||||
<string>Task</string>
|
||||
<string>Could not create the project</string>
|
||||
<string>Could not create the task</string>
|
||||
<string>Search</string>
|
||||
<string>Search a Project</string>
|
||||
<string>Create a Task in a new Project</string>
|
||||
<string>Create a Task in an existing Project</string>
|
||||
<string>Project Name</string>
|
||||
<string>Create Project & Task</string>
|
||||
<string>Email already logged on the task</string>
|
||||
<string>Tasks (%s)</string>
|
||||
<string>Create</string>
|
||||
<string>OR</string>
|
||||
<string>Log the email on the task</string>
|
||||
<string>Save the contact to create new tasks.</string>
|
||||
<string>The project name is required</string>
|
||||
<string>No project found.</string>
|
||||
</ressources>
|
||||
Reference in New Issue
Block a user