Files
odoo_source/addons/mail/models/res_config_settings.py
T
std-odoo d497dbe919 [IMP] fetchmail_gmail, google_gmail: simplify the mail server form view
Purpose
=======
A field `use_google_gmail_service` has been used in stable to define
a mail server which use Gmail authentication.

But now that the fields `smtp_authentication` exists, we want to use it
to simplify the mail server form view. For the incoming mail server,
the field `server_type` will be used for the same purpose.

Add a new field to have the option to install `google_gmail` in the
main settings page.

Task-2170676

closes odoo/odoo#83413

Related: odoo/upgrade#3199
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-02-01 15:32:16 +00:00

45 lines
1.8 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import datetime
from odoo import api, fields, models, tools
class ResConfigSettings(models.TransientModel):
""" Inherit the base settings to add a counter of failed email + configure
the alias domain. """
_inherit = 'res.config.settings'
fail_counter = fields.Integer('Fail Mail', compute="_compute_fail_counter")
alias_domain = fields.Char(
'Alias Domain', config_parameter='mail.catchall.domain',
help="If you have setup a catch-all email domain redirected to the Odoo server, enter the domain name here.")
module_google_gmail = fields.Boolean('Support Gmail Authentication')
restrict_template_rendering = fields.Boolean(
'Restrict Template Rendering',
config_parameter='mail.restrict.template.rendering',
help='Users will still be able to render templates.\n'
'However only Mail Template Editors will be able to create new dynamic templates or modify existing ones.')
use_twilio_rtc_servers = fields.Boolean(
'Use Twilio ICE servers',
help="If you want to use twilio as TURN/STUN server provider",
config_parameter='mail.use_twilio_rtc_servers',
)
twilio_account_sid = fields.Char(
'Twilio Account SID',
config_parameter='mail.twilio_account_sid',
)
twilio_account_token = fields.Char(
'Twilio Account Auth Token',
config_parameter='mail.twilio_account_token',
)
def _compute_fail_counter(self):
previous_date = fields.Datetime.now() - datetime.timedelta(days=30)
self.fail_counter = self.env['mail.mail'].sudo().search_count([
('date', '>=', previous_date),
('state', '=', 'exception'),
])