2018-03-06 09:18:36 +01:00
|
|
|
# Copyright (C) 2015 Therp BV <http://therp.nl>
|
|
|
|
# Copyright (C) 2017 Komit <http://www.komit-consulting.com>
|
|
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
|
|
|
|
2015-07-08 11:32:21 +02:00
|
|
|
from lxml import etree
|
2020-03-09 15:10:18 +01:00
|
|
|
|
2018-03-06 09:18:36 +01:00
|
|
|
from odoo import api, models
|
2015-07-08 11:32:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
class MailWizardInvite(models.TransientModel):
|
2020-03-09 15:10:18 +01:00
|
|
|
_inherit = "mail.wizard.invite"
|
2015-07-08 11:32:21 +02:00
|
|
|
|
|
|
|
@api.model
|
2020-01-02 13:45:13 +01:00
|
|
|
def _mail_restrict_follower_selection_get_domain(self, res_model=None):
|
|
|
|
if not res_model:
|
2020-12-22 10:18:50 +01:00
|
|
|
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(
|
|
|
|
"{}.{}".format(parameter_name, res_model),
|
|
|
|
self.env["ir.config_parameter"]
|
|
|
|
.sudo()
|
|
|
|
.get_param(parameter_name, default="[]"),
|
|
|
|
)
|
2015-07-08 11:32:21 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@api.model
|
2020-03-09 15:10:18 +01:00
|
|
|
def fields_view_get(
|
|
|
|
self, view_id=None, view_type="form", toolbar=False, submenu=False
|
|
|
|
):
|
2015-07-08 11:32:21 +02:00
|
|
|
result = super(MailWizardInvite, self).fields_view_get(
|
2020-03-09 15:10:18 +01:00
|
|
|
view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu
|
|
|
|
)
|
|
|
|
arch = etree.fromstring(result["arch"])
|
2015-07-08 11:32:21 +02:00
|
|
|
for field in arch.xpath('//field[@name="partner_ids"]'):
|
2020-03-09 15:10:18 +01:00
|
|
|
field.attrib["domain"] = self._mail_restrict_follower_selection_get_domain()
|
|
|
|
result["arch"] = etree.tostring(arch)
|
2015-07-08 11:32:21 +02:00
|
|
|
return result
|