add mail_follower_option module

This commit is contained in:
Chafique
2019-09-26 12:11:09 +02:00
committed by Hpar
parent 6377f0984d
commit 31483abb99
7 changed files with 78 additions and 0 deletions

View File

@@ -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)

View File

@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import models

View File

@@ -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,
}

View File

@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
from . import mail_follower
from . import ir_model

View File

@@ -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')

View File

@@ -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)

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_model_form" model="ir.ui.view">
<field name="model">ir.model</field>
<field name="inherit_id" ref="base.view_model_form"/>
<field name="arch" type="xml">
<field name="transient" position="after">
<field name="mail_follower"/>
</field>
</field>
</record>
</odoo>