Skip to content

Commit

Permalink
[IMP] Disable auto subscribe on projects
Browse files Browse the repository at this point in the history
  • Loading branch information
valentincastravete committed Nov 24, 2023
1 parent 5282136 commit 52f1b79
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 9 deletions.
8 changes: 4 additions & 4 deletions project_task_disable_auto_subscribe/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###############################################################################
#
# SDi Soluciones Digitales
# Copyright (C) 2021-Today SDi Soluciones Informáticas <www.sdi.es>
# SDi Digital Group
# Copyright (C) 2023-Today SDi Digital Group <www.sdi.es>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
Expand All @@ -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',
Expand Down
1 change: 1 addition & 0 deletions project_task_disable_auto_subscribe/models/__init__.py
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions project_task_disable_auto_subscribe/models/project_project.py
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 2 additions & 4 deletions project_task_disable_auto_subscribe/models/project_task.py
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 5 additions & 0 deletions project_task_disable_auto_subscribe/models/res_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.''',
)
3 changes: 2 additions & 1 deletion project_task_disable_auto_subscribe/views/res_users.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
<field name="inherit_id" ref="base.view_users_form"/>
<field name="arch" type="xml">
<group name="preferences" position="after">
<group string="Disable auto subscription on project task creation" name="disable_auto_subscription_on_project_task_creation">
<group string="Disable auto subscription on project or task creation" name="disable_auto_subscription_on_project_or_task_creation">
<field name="project_task_disable_auto_subscribe"/>
<field name="project_disable_auto_subscribe"/>
</group>
</group>
</field>
Expand Down

0 comments on commit 52f1b79

Please sign in to comment.