[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,
|
existing_policy=existing_policy,
|
||||||
)
|
)
|
||||||
domain = self.env[
|
domain = self.env[
|
||||||
"mail.wizard.invite"
|
'mail.wizard.invite'
|
||||||
]._mail_restrict_follower_selection_get_domain()
|
]._mail_restrict_follower_selection_get_domain(res_model=res_model)
|
||||||
partners = self.env["res.partner"].search(
|
partners = self.env['res.partner'].search(
|
||||||
[("id", "in", partner_ids)] + safe_eval(domain)
|
[('id', 'in', partner_ids)] +
|
||||||
|
safe_eval(domain)
|
||||||
)
|
)
|
||||||
_res_ids = res_ids.copy() or [0]
|
_res_ids = res_ids.copy() or [0]
|
||||||
new, update = super()._add_followers(
|
new, update = super()._add_followers(
|
||||||
|
@ -11,19 +11,15 @@ class MailWizardInvite(models.TransientModel):
|
|||||||
_inherit = "mail.wizard.invite"
|
_inherit = "mail.wizard.invite"
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _mail_restrict_follower_selection_get_domain(self):
|
def _mail_restrict_follower_selection_get_domain(self, res_model=None):
|
||||||
parameter_name = "mail_restrict_follower_selection.domain"
|
if not res_model:
|
||||||
return (
|
res_model = self.env.context.get('default_res_model')
|
||||||
self.env["ir.config_parameter"]
|
parameter_name = 'mail_restrict_follower_selection.domain'
|
||||||
.sudo()
|
return self.env['ir.config_parameter'].sudo().get_param(
|
||||||
.get_param(
|
"{0}.{1}".format(parameter_name,
|
||||||
"{}.{}".format(
|
res_model),
|
||||||
parameter_name, self.env.context.get("default_res_model")
|
self.env['ir.config_parameter'].sudo().get_param(
|
||||||
),
|
parameter_name, default='[]')
|
||||||
self.env["ir.config_parameter"]
|
|
||||||
.sudo()
|
|
||||||
.get_param(parameter_name, default="[]"),
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
|
Loading…
x
Reference in New Issue
Block a user