[IMP] email_template: added opt_out flag on res.partner

In the context of email templates or for related features
like marketing campaigns or automated business document
notification, this flag may be used to disable the sending
of template-based emails to the partner.
It will not prevent sending an email based on a template
by default, each feature using a template should implement
this if needed.

bzr revid: odo@openerp.com-20111005113846-qik6d5gxd4xqeqdj
This commit is contained in:
Olivier Dony 2011-10-05 13:38:46 +02:00
parent ea8c703bbb
commit 72d5ab8b99
5 changed files with 67 additions and 0 deletions

View File

@ -21,5 +21,6 @@
##############################################################################
import email_template
import wizard
import res_partner
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -61,9 +61,13 @@ Openlabs was kept
"data": [
'wizard/email_template_preview_view.xml',
'email_template_view.xml',
'res_partner_view.xml',
'wizard/email_compose_message_view.xml',
'security/ir.model.access.csv'
],
"demo": [
'res_partner_demo.yml',
],
"installable": True,
"active": False,
"certificate" : "00817073628967384349",

View File

@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Business Applications
# Copyright (c) 2011 OpenERP S.A. <http://openerp.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields,osv
class res_partner(osv.osv):
"""Inherit res.partner to add a generic opt-out field that can be used
to restrict usage of automatic email templates.
This field is unused by default. """
_inherit = 'res.partner'
_columns = {
'opt_out': fields.boolean('Opt-out', help="If checked, this partner will not receive any automated email " \
"notifications, such as the availability of invoices."),
}
_defaults = {
'opt_out': False,
}

View File

@ -0,0 +1,9 @@
-
Set opt-out to True on all demo partners
-
!python {model: res.partner}: |
partner_ids = self.search(cr, uid, [])
# assume partners with an external ID come from demo data
ext_ids = self._get_external_ids(cr, uid, partner_ids)
ids_to_update = [k for (k,v) in ext_ids.iteritems() if v]
self.write(cr, uid, ids_to_update, {'opt_out': True})

View File

@ -0,0 +1,16 @@
<?xml version="1.0" ?>
<openerp>
<data>
<record model="ir.ui.view" id="res_partner_opt_out_form">
<field name="name">res.partner.opt_out.form</field>
<field name="model">res.partner</field>
<field name="type">form</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<xpath expr="/notebook/page/field[@name='active']" position="after">
<field name="opt_out" groups="base.group_extended"/>
</xpath>
</field>
</record>
</data>
</openerp>