[FIX] mail_restrict_follower_selection: res_model not always in context
When creating a record from a record from another model, the model is not in the context (`default_res_model` key). For example: creating an invoice from a sale order.
This commit is contained in:
parent
3316ab142a
commit
d6cc4a8aa9
@ -35,10 +35,11 @@ class MailFollowers(models.Model):
|
||||
existing_policy=existing_policy,
|
||||
)
|
||||
domain = self.env[
|
||||
"mail.wizard.invite"
|
||||
]._mail_restrict_follower_selection_get_domain()
|
||||
partners = self.env["res.partner"].search(
|
||||
[("id", "in", partner_ids)] + safe_eval(domain)
|
||||
'mail.wizard.invite'
|
||||
]._mail_restrict_follower_selection_get_domain(res_model=res_model)
|
||||
partners = self.env['res.partner'].search(
|
||||
[('id', 'in', partner_ids)] +
|
||||
safe_eval(domain)
|
||||
)
|
||||
_res_ids = res_ids.copy() or [0]
|
||||
new, update = super()._add_followers(
|
||||
|
@ -11,19 +11,15 @@ class MailWizardInvite(models.TransientModel):
|
||||
_inherit = "mail.wizard.invite"
|
||||
|
||||
@api.model
|
||||
def _mail_restrict_follower_selection_get_domain(self):
|
||||
parameter_name = "mail_restrict_follower_selection.domain"
|
||||
return (
|
||||
self.env["ir.config_parameter"]
|
||||
.sudo()
|
||||
.get_param(
|
||||
"{}.{}".format(
|
||||
parameter_name, self.env.context.get("default_res_model")
|
||||
),
|
||||
self.env["ir.config_parameter"]
|
||||
.sudo()
|
||||
.get_param(parameter_name, default="[]"),
|
||||
)
|
||||
def _mail_restrict_follower_selection_get_domain(self, res_model=None):
|
||||
if not res_model:
|
||||
res_model = self.env.context.get('default_res_model')
|
||||
parameter_name = 'mail_restrict_follower_selection.domain'
|
||||
return self.env['ir.config_parameter'].sudo().get_param(
|
||||
"{0}.{1}".format(parameter_name,
|
||||
res_model),
|
||||
self.env['ir.config_parameter'].sudo().get_param(
|
||||
parameter_name, default='[]')
|
||||
)
|
||||
|
||||
@api.model
|
||||
|
Loading…
Reference in New Issue
Block a user