Mailing : actions #42

Open
youssef wants to merge 33 commits from youssef/GOLEM:Mailing_actions into master
Showing only changes of commit da9b44114c - Show all commits

View File

@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Youssef El Ouahby <youssef@yaltik.com>
# Copyright 2018 Fabien Bourgeois <fabien@yaltik.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/>.
""" GOLEM Mail Recipient Management """
import logging
from odoo import models, fields, api, _
_LOGGER = logging.getLogger(__name__)
class GolemMailRecipient(models.TransientModel):
""" GOLEM Mail Recipient """
_name = 'golem.mail.recipient'
partner_id = fields.Many2one('res.partner')
email = fields.Char()
firstname = fields.Char()
lastname = fields.Char()
phone = fields.Char()
opt_out = fields.Boolean()
presend_wizard_id = fields.Many2one('golem.mail.presend.wizard')
@api.multi
@api.constrains('partner_id')
def fill_related_fields(self):
""" fill related fields from partner_id """
for recipient in self:
if recipient.partner_id:
recipient.email = recipient.partner_id.email
recipient.firstname = recipient.partner_id.firstname
recipient.lastname = recipient.partner_id.lastname
recipient.phone = recipient.partner_id.phone
recipient.opt_out = recipient.partner_id.opt_out