Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
2441 Widoki

Hello all,

I am using v15. In the survey module, i want only the questions of the current record questions in an another Many2one field. How can i achieve it. Here is my code:


class SurveyQuestion(models.Model):
_name = 'survey.question.question'

 survey = fields.Many2one('survey.survey')
question = fields.Many2one('survey.question')


Thanks in regards.

Awatar
Odrzuć
Najlepsza odpowiedź

Hi,

You can select only the questions from the questions from the selected surveys by passing the domain to the question field

survey_id = fields.Many2one('survey.survey')
question_id = fields.Many2one('survey.question' , domain="[(survey_id, '=', survey_id)]"))

So by applying the domain you can only select question that are present in the previously selected survey

For more information on domain passing to a Many2one field refer to the forum answer below.

https://www.odoo.com/forum/help-1/odoo-14-how-i-can-set-domain-filter-on-many2one-type-field-181671

Regards

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
wrz 23
1561
2
lut 24
2681
1
mar 23
11927
0
lis 22
1612
0
mar 22
1762