From fe99eeddea5853edee1832eb89879861a3391450 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valent=C3=ADn=20Castravete=20Georgian?= <58530982+valentincastravete@users.noreply.github.com> Date: Fri, 24 Nov 2023 10:47:47 +0100 Subject: [PATCH 1/2] [IMP] Disable auto subscribe on projects (#323) --- .../__manifest__.py | 8 ++++---- .../models/__init__.py | 1 + .../models/project_project.py | 14 ++++++++++++++ .../models/project_task.py | 6 ++---- .../models/res_users.py | 5 +++++ .../views/res_users.xml | 3 ++- 6 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 project_task_disable_auto_subscribe/models/project_project.py diff --git a/project_task_disable_auto_subscribe/__manifest__.py b/project_task_disable_auto_subscribe/__manifest__.py index fe428d7..feb2e8c 100644 --- a/project_task_disable_auto_subscribe/__manifest__.py +++ b/project_task_disable_auto_subscribe/__manifest__.py @@ -1,7 +1,7 @@ ############################################################################### # -# SDi Soluciones Digitales -# Copyright (C) 2021-Today SDi Soluciones Informáticas +# SDi Digital Group +# Copyright (C) 2023-Today SDi Digital Group # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -20,9 +20,9 @@ { 'name': 'Project Task Disable Auto Subscribe', 'summary': '''Check on user for disabling auto subscription when the user - creates a new project task.''', + creates a new project or task.''', 'author': '''Valentín Castravete Georgian, Jorge Luis Quinteros, - SDi Soluciones Digitales''', + SDi Digital Group''', 'website': 'https://www.sdi.es/odoo-cloud/', 'license': 'AGPL-3', 'category': 'Project', diff --git a/project_task_disable_auto_subscribe/models/__init__.py b/project_task_disable_auto_subscribe/models/__init__.py index b66ec0a..5d7d318 100644 --- a/project_task_disable_auto_subscribe/models/__init__.py +++ b/project_task_disable_auto_subscribe/models/__init__.py @@ -1,5 +1,6 @@ ############################################################################### # For copyright and license notices, see __manifest__.py file in root directory ############################################################################### +from . import project_project from . import project_task from . import res_users diff --git a/project_task_disable_auto_subscribe/models/project_project.py b/project_task_disable_auto_subscribe/models/project_project.py new file mode 100644 index 0000000..0391863 --- /dev/null +++ b/project_task_disable_auto_subscribe/models/project_project.py @@ -0,0 +1,14 @@ +############################################################################### +# For copyright and license notices, see __manifest__.py file in root directory +############################################################################### +from odoo import models + + +class Project(models.Model): + _inherit = 'project.project' + + def create(self, vals): + user_id = self.env['res.users'].browse(self._context['uid']) + if not user_id.project_disable_auto_subscribe: + return super().create(vals) + return super().with_context(mail_create_nosubscribe=True).create(vals) diff --git a/project_task_disable_auto_subscribe/models/project_task.py b/project_task_disable_auto_subscribe/models/project_task.py index 05f4003..53bd0e2 100644 --- a/project_task_disable_auto_subscribe/models/project_task.py +++ b/project_task_disable_auto_subscribe/models/project_task.py @@ -1,16 +1,14 @@ ############################################################################### # For copyright and license notices, see __manifest__.py file in root directory ############################################################################### -from odoo import api, models +from odoo import models class ProjectTask(models.Model): _inherit = 'project.task' - @api.multi def create(self, vals): user_id = self.env['res.users'].browse(self._context['uid']) if not user_id.project_task_disable_auto_subscribe: return super().create(vals) - return super(ProjectTask, self.with_context( - mail_create_nosubscribe=True)).create(vals) + return super().with_context(mail_create_nosubscribe=True).create(vals) diff --git a/project_task_disable_auto_subscribe/models/res_users.py b/project_task_disable_auto_subscribe/models/res_users.py index 37b909a..c01ed00 100644 --- a/project_task_disable_auto_subscribe/models/res_users.py +++ b/project_task_disable_auto_subscribe/models/res_users.py @@ -12,3 +12,8 @@ class ResUsers(models.Model): help='''Check to disable auto subscription when the user creates a new project task.''', ) + project_disable_auto_subscribe = fields.Boolean( + string='Disable auto subscribe on project creation', + help='''Check to disable auto subscription when the user creates a new + project.''', + ) diff --git a/project_task_disable_auto_subscribe/views/res_users.xml b/project_task_disable_auto_subscribe/views/res_users.xml index fe01be4..c4a76f1 100644 --- a/project_task_disable_auto_subscribe/views/res_users.xml +++ b/project_task_disable_auto_subscribe/views/res_users.xml @@ -5,8 +5,9 @@ - + + From ca78034a8f38afe3f744c237d6e3359f3adbb90d Mon Sep 17 00:00:00 2001 From: Valentin Castravete Date: Mon, 27 Nov 2023 14:46:19 +0100 Subject: [PATCH 2/2] [FIX] Translation fix --- project_task_disable_auto_subscribe/i18n/es.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project_task_disable_auto_subscribe/i18n/es.po b/project_task_disable_auto_subscribe/i18n/es.po index 9a0bb13..bfc6704 100644 --- a/project_task_disable_auto_subscribe/i18n/es.po +++ b/project_task_disable_auto_subscribe/i18n/es.po @@ -21,7 +21,7 @@ msgid "Check to disable auto subscription when the user creates a new project ta msgstr "Verificación para deshabilitar la suscripción automática cuando un usuario crea una nueva tarea de proyecto." #. module: project_task_disable_auto_subscribe -#: model:ir.model.fields,field_description:project_task_disable_auto_subscribe.field_res_users__project_task_disable_auto_subscribe +#: model:ir.model.fields,field_description:project_task_disable_auto_subscribe.field_res_users__project_disable_auto_subscribe msgid "Disable auto subscribe on project creation" msgstr "Deshabilitar suscripción automática al crear un proyecto"