mirror of
https://github.com/bringout/oca-ocb-core.git
synced 2026-04-22 11:52:04 +02:00
Initial commit: Core packages
This commit is contained in:
commit
12c29a983b
9512 changed files with 8379910 additions and 0 deletions
19
odoo-bringout-oca-ocb-digest/digest/models/res_users.py
Normal file
19
odoo-bringout-oca-ocb-digest/digest/models/res_users.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# -*- 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')
|
||||
users_to_subscribe = users.filtered_domain([('share', '=', False)])
|
||||
if default_digest_emails and default_digest_id and users_to_subscribe:
|
||||
digest = self.env['digest.digest'].sudo().browse(int(default_digest_id)).exists()
|
||||
digest.user_ids |= users_to_subscribe
|
||||
return users
|
||||
Loading…
Add table
Add a link
Reference in a new issue