Scenario to reproduce the issue on runbot 12.0 Community: - Go to Settings > Technical > Email > Digest Emails - Select the Weekly Digest - Click on Action > Delete - Click on OK - Go to Settings > Users & Companies > Users - Click on Create - Fill the Name and the Email Address - Save - Odoo Server Error - Missing Record Some users seem to delete this record to stop receiving the digest for everyone, including for future users. The problem is that, even if the digest has been deleted, the config parameters are still referencing it. This commit prevents the exception by having an empty recordset if the digest does not exist. closes odoo/odoo#73237 X-original-commit: 2910bd24f410e882b9745337f918a206b25925f7 Signed-off-by: Paul Morelle <madprog@users.noreply.github.com>
19 lines
858 B
Python
19 lines
858 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
from odoo import api, models
|
|
|
|
|
|
class ResUsers(models.Model):
|
|
_inherit = "res.users"
|
|
|
|
@api.model_create_multi
|
|
def create(self, vals_list):
|
|
""" Automatically subscribe employee users to default digest if activated """
|
|
users = super(ResUsers, self).create(vals_list)
|
|
default_digest_emails = self.env['ir.config_parameter'].sudo().get_param('digest.default_digest_emails')
|
|
default_digest_id = self.env['ir.config_parameter'].sudo().get_param('digest.default_digest_id')
|
|
if default_digest_emails and default_digest_id:
|
|
digest = self.env['digest.digest'].sudo().browse(int(default_digest_id)).exists()
|
|
digest.user_ids |= users.filtered_domain([('share', '=', False)])
|
|
return users
|