[IMP] mail: add res_users_settings_id field
Add the `res_users_settings_id` field on `res.users` so that it can be used as a target for relateds that is not a x2many field. closes odoo/odoo#90015 Related: odoo/upgrade#3479 Related: odoo/enterprise#26287 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
@@ -27,6 +27,8 @@ class Users(models.Model):
|
||||
"- Handle by Emails: notifications are sent to your email address\n"
|
||||
"- Handle in Odoo: notifications appear in your Odoo Inbox")
|
||||
res_users_settings_ids = fields.One2many('res.users.settings', 'user_id')
|
||||
# Provide a target for relateds that is not a x2Many field.
|
||||
res_users_settings_id = fields.Many2one('res.users.settings', string="Settings", compute='_compute_res_users_settings_id', search='_search_res_users_settings_id')
|
||||
|
||||
_sql_constraints = [(
|
||||
"notification_type",
|
||||
@@ -41,6 +43,15 @@ class Users(models.Model):
|
||||
if user.share or not user.notification_type:
|
||||
user.notification_type = 'email'
|
||||
|
||||
@api.depends('res_users_settings_ids')
|
||||
def _compute_res_users_settings_id(self):
|
||||
for user in self:
|
||||
user.res_users_settings_id = user.res_users_settings_ids and user.res_users_settings_ids[0]
|
||||
|
||||
@api.model
|
||||
def _search_res_users_settings_id(self, operator, operand):
|
||||
return [('res_users_settings_ids', operator, operand)]
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# CRUD
|
||||
# ------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user