summaryrefslogtreecommitdiff
path: root/addons/digest/models/res_users.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/digest/models/res_users.py
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/digest/models/res_users.py')
-rw-r--r--addons/digest/models/res_users.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/addons/digest/models/res_users.py b/addons/digest/models/res_users.py
new file mode 100644
index 00000000..397d672e
--- /dev/null
+++ b/addons/digest/models/res_users.py
@@ -0,0 +1,18 @@
+# -*- 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