From b96ff618086580ef23c8476978330bf4af479e9f Mon Sep 17 00:00:00 2001 From: std-odoo Date: Tue, 1 Jun 2021 11:57:14 +0000 Subject: [PATCH] [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 --- .../controllers/mail_plugin.py | 1 + .../controllers/project_client.py | 11 +++++---- .../src/to_translate/translations_gmail.xml | 23 +++++++++++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 addons/project_mail_plugin/static/src/to_translate/translations_gmail.xml diff --git a/addons/project_mail_plugin/controllers/mail_plugin.py b/addons/project_mail_plugin/controllers/mail_plugin.py index 4ca062f8074..0b8f275c146 100644 --- a/addons/project_mail_plugin/controllers/mail_plugin.py +++ b/addons/project_mail_plugin/controllers/mail_plugin.py @@ -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 diff --git a/addons/project_mail_plugin/controllers/project_client.py b/addons/project_mail_plugin/controllers/project_client.py index 613794d9344..2fdbf445a16 100644 --- a/addons/project_mail_plugin/controllers/project_client.py +++ b/addons/project_mail_plugin/controllers/project_client.py @@ -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): diff --git a/addons/project_mail_plugin/static/src/to_translate/translations_gmail.xml b/addons/project_mail_plugin/static/src/to_translate/translations_gmail.xml new file mode 100644 index 00000000000..a16863056f0 --- /dev/null +++ b/addons/project_mail_plugin/static/src/to_translate/translations_gmail.xml @@ -0,0 +1,23 @@ + + + + Task + Could not create the project + Could not create the task + Search + Search a Project + Create a Task in a new Project + Create a Task in an existing Project + Project Name + Create Project & Task + Email already logged on the task + Tasks (%s) + Create + OR + Log the email on the task + Save the contact to create new tasks. + The project name is required + No project found. +