social/mail_restrict_follower_selection/models/mail_wizard_invite.py

41 lines
1.4 KiB
Python
Raw Permalink Normal View History

# 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
from odoo import api, models
2015-07-08 11:32:21 +02:00
class MailWizardInvite(models.TransientModel):
_inherit = "mail.wizard.invite"
2015-07-08 11:32:21 +02:00
@api.model
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(
"{}.{}".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
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(
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"]'):
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