Skip to content
Permalink
Browse files

[REM] survey: dynamic domain

Task 2115472
  • Loading branch information
xmo-odoo committed Nov 26, 2019
1 parent 4f226e7 commit ecc56306b978053821845a614bf6e552c0779b97
Showing with 9 additions and 11 deletions.
  1. +8 −11 addons/survey/wizard/survey_invite.py
  2. +1 −0 addons/survey/wizard/survey_invite_views.xml
@@ -43,7 +43,13 @@ def _get_default_author(self):
help="Author of the message.")
# recipients
partner_ids = fields.Many2many(
'res.partner', 'survey_invite_partner_ids', 'invite_id', 'partner_id', string='Recipients')
'res.partner', 'survey_invite_partner_ids', 'invite_id', 'partner_id', string='Recipients',
domain="""[
'|', (survey_users_can_signup, '=', 1),
'|', (not survey_users_login_required, '=', 1),
('user_ids', '!=', False),
]"""
)
existing_partner_ids = fields.Many2many(
'res.partner', compute='_compute_existing_partner_ids', readonly=True, store=False)
emails = fields.Text(string='Additional emails', help="This list of emails of recipients will not be converted in contacts.\
@@ -62,6 +68,7 @@ def _get_default_author(self):
survey_url = fields.Char(related="survey_id.public_url", readonly=True)
survey_access_mode = fields.Selection(related="survey_id.access_mode", readonly=True)
survey_users_login_required = fields.Boolean(related="survey_id.users_login_required", readonly=True)
survey_users_can_signup = fields.Boolean(related='survey_id.users_can_signup')
deadline = fields.Datetime(string="Answer deadline")

@api.depends('partner_ids', 'survey_id')
@@ -110,16 +117,6 @@ def _onchange_emails(self):
raise UserError(_("Some emails you just entered are incorrect: %s") % (', '.join(error)))
self.emails = '\n'.join(valid)

@api.onchange('survey_users_login_required')
def _onchange_survey_users_login_required(self):
if self.survey_users_login_required and not self.survey_id.users_can_signup:
return {'domain': {
'partner_ids': [('user_ids', '!=', False)]
}}
return {'domain': {
'partner_ids': []
}}

@api.onchange('partner_ids')
def _onchange_partner_ids(self):
if self.survey_users_login_required and self.partner_ids:
@@ -10,6 +10,7 @@
<group col="2">
<field name="survey_access_mode" invisible="1"/>
<field name="survey_users_login_required" invisible="1"/>
<field name="survey_users_can_signup" invisible="1"/>
<field name="survey_id" readonly="context.get('default_survey_id')"/>
<field name="existing_mode" widget="radio" invisible="1" />
<field name="survey_url" label="Public share URL" readonly="1" widget="CopyClipboardChar"

0 comments on commit ecc5630

Please sign in to comment.
You can’t perform that action at this time.