From 31483abb991508e723752d734c8819e62a19a202 Mon Sep 17 00:00:00 2001 From: Chafique Date: Thu, 26 Sep 2019 12:11:09 +0200 Subject: [PATCH] add mail_follower_option module --- mail_follower_option/README.rst | 13 +++++++++++++ mail_follower_option/__init__.py | 3 +++ mail_follower_option/__manifest__.py | 14 ++++++++++++++ mail_follower_option/models/__init__.py | 4 ++++ mail_follower_option/models/ir_model.py | 11 +++++++++++ mail_follower_option/models/mail_follower.py | 18 ++++++++++++++++++ mail_follower_option/views/ir_model_view.xml | 15 +++++++++++++++ 7 files changed, 78 insertions(+) create mode 100644 mail_follower_option/README.rst create mode 100644 mail_follower_option/__init__.py create mode 100644 mail_follower_option/__manifest__.py create mode 100644 mail_follower_option/models/__init__.py create mode 100644 mail_follower_option/models/ir_model.py create mode 100644 mail_follower_option/models/mail_follower.py create mode 100644 mail_follower_option/views/ir_model_view.xml diff --git a/mail_follower_option/README.rst b/mail_follower_option/README.rst new file mode 100644 index 0000000..1e6b50b --- /dev/null +++ b/mail_follower_option/README.rst @@ -0,0 +1,13 @@ +Mail Follower Option +==================== + +This module ensures that the addition of followers on a model is not automatic but that it is an option on each model. +By default, the option is unchecked on each model, so that the followers are not added. + +Credits +======= + +Contributors +------------ + +* Chafique Delli (chafique.delli@akretion.com) diff --git a/mail_follower_option/__init__.py b/mail_follower_option/__init__.py new file mode 100644 index 0000000..cde864b --- /dev/null +++ b/mail_follower_option/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import models diff --git a/mail_follower_option/__manifest__.py b/mail_follower_option/__manifest__.py new file mode 100644 index 0000000..d28264a --- /dev/null +++ b/mail_follower_option/__manifest__.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +{ + 'name': 'Mail Follower Option', + 'version': '10.0.1.0.0', + 'category': 'Base', + 'license': 'AGPL-3', + 'author': 'Akretion', + 'website': 'http://www.akretion.com', + 'depends': ['mail'], + 'data': [ + 'views/ir_model_view.xml', + ], + 'installable': True, +} diff --git a/mail_follower_option/models/__init__.py b/mail_follower_option/models/__init__.py new file mode 100644 index 0000000..976b9ea --- /dev/null +++ b/mail_follower_option/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +from . import mail_follower +from . import ir_model diff --git a/mail_follower_option/models/ir_model.py b/mail_follower_option/models/ir_model.py new file mode 100644 index 0000000..ee22ab2 --- /dev/null +++ b/mail_follower_option/models/ir_model.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- + +from odoo import models, fields + + +class IrModel(models.Model): + _inherit = 'ir.model' + + mail_follower = fields.Boolean(string='Follow', default=False, + help='Check if you want create followers' + ' on this model') diff --git a/mail_follower_option/models/mail_follower.py b/mail_follower_option/models/mail_follower.py new file mode 100644 index 0000000..01b7a2e --- /dev/null +++ b/mail_follower_option/models/mail_follower.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +from odoo import models, api + + +class Followers(models.Model): + _inherit = 'mail.followers' + + @api.model + def create(self, vals): + # Do not implicitly create followers on an object + model = self.env['ir.model'].search([ + ('model', '=', vals['res_model']), + ('mail_follower', '=', True), + ], limit=1) + if not model: + return + return super(Followers, self).create(vals) diff --git a/mail_follower_option/views/ir_model_view.xml b/mail_follower_option/views/ir_model_view.xml new file mode 100644 index 0000000..cd22d42 --- /dev/null +++ b/mail_follower_option/views/ir_model_view.xml @@ -0,0 +1,15 @@ + + + + + + ir.model + + + + + + + + +