diff options
| author | Olivier Dony <odo@openerp.com> | 2011-10-05 13:38:46 +0200 |
|---|---|---|
| committer | Olivier Dony <odo@openerp.com> | 2011-10-05 13:38:46 +0200 |
| commit | 72d5ab8b9954f77e71e8db6b1d07965e1617bbbf (patch) | |
| tree | 0376cac086c51ea79447bf460496c600a7e34df3 | |
| parent | ea8c703bbb3bbb23e186e431eaed6a7b920f7234 (diff) | |
[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
| -rw-r--r-- | addons/email_template/__init__.py | 1 | ||||
| -rw-r--r-- | addons/email_template/__openerp__.py | 4 | ||||
| -rw-r--r-- | addons/email_template/res_partner.py | 37 | ||||
| -rw-r--r-- | addons/email_template/res_partner_demo.yml | 9 | ||||
| -rw-r--r-- | addons/email_template/res_partner_view.xml | 16 |
5 files changed, 67 insertions, 0 deletions
diff --git a/addons/email_template/__init__.py b/addons/email_template/__init__.py index 97931ea8bd5..d1cf5b28431 100644 --- a/addons/email_template/__init__.py +++ b/addons/email_template/__init__.py @@ -21,5 +21,6 @@ ############################################################################## import email_template import wizard +import res_partner # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/email_template/__openerp__.py b/addons/email_template/__openerp__.py index e5f83f9ac0c..575550cf2d3 100644 --- a/addons/email_template/__openerp__.py +++ b/addons/email_template/__openerp__.py @@ -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", diff --git a/addons/email_template/res_partner.py b/addons/email_template/res_partner.py new file mode 100644 index 00000000000..74d8b4e0693 --- /dev/null +++ b/addons/email_template/res_partner.py @@ -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, + }
\ No newline at end of file diff --git a/addons/email_template/res_partner_demo.yml b/addons/email_template/res_partner_demo.yml new file mode 100644 index 00000000000..8eaf48f9e87 --- /dev/null +++ b/addons/email_template/res_partner_demo.yml @@ -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})
\ No newline at end of file diff --git a/addons/email_template/res_partner_view.xml b/addons/email_template/res_partner_view.xml new file mode 100644 index 00000000000..4790aa7522a --- /dev/null +++ b/addons/email_template/res_partner_view.xml @@ -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>
\ No newline at end of file |
