I'm trying to get extract information from Odoo surveys from the "Detailed answers" pivot view (I had to enable the pivot view myself since the detailed views only has tree and kanban views enabled by default).
To make it simpler to explain, I'll give an example using the "Furniture creation certification" survey that is already configured when you install the survey module, which has two questions with multiple choice answers:
What type of wood is the best for furniture?
- Fir / Oak / Ash / Beech Select all the furniture shown in the video
- Chair / Table / Desk / Shelf / Bed
What I'm trying to find out is the answers to the second question, but related to the answer to the first one. That is, out of the answers that chose Fir as the best type of wood, how many of them chose "Chair", or "Table", or "Desk"... as an answer to the second question. The same for all types of wood.
Keep in mind that I'm using an example that only has two questions, although the real case could have many more (anyway, I would always want to group those answers based on one question). I think that may be achieved using grouping and filters in the view, but I can't figure out how to configure the filter. This is one of my last intents:
<record id="survey.survey_user_input_line_view_search" model="ir.ui.view">
<field name="name">survey.user_input.line.view.search</field>
<field name="model">survey.user_input.line</field>
<field name="arch" type="xml">
<search string="Search User input lines">
<field name="user_input_id"/>
<field name="survey_id"/>
<group expand="1" string="Group By">
<filter name="group_by_survey" string="Survey" domain="[]" context="{'group_by':'survey_id'}"/>
<filter name="group_by_user_input" string="User Input" domain="[]" context="{'group_by':'user_input_id'}"/>
<filter name="group_by_wood" string="Wood" domain="{'my_id':[('question_id','=','Select all the furniture shown in the video')]}" context="{'group_by':'question_id'}"/>
</group>
</search>
</field>
</record>
The last filter tag is the one I'm messing with. I'd really appreciate any help with this, specially if it doesn't involve changing the class, but only the view.
Thank you very much!
Edit: I have been banging my head against Odoo domains for hours to achieve the filter I asked about. I am now narrowing it down to trying to get the ID of all the user submissions that answered "Chair" to the question "Select all the furniture shown in the video".
First, I got all the lines that meet that condition:
<filter name="group_by_wood" string="Wood" domain="[('question_id','=','Select all the furniture shown in the video'), ('suggested_answer_id','=','Chair')]" context="{}"/>
That works fine. In each of these lines, one of the fields is the "user_input_id". So the step I am struggling with now is to get all of the lines with that user_input_id(s). My current query is:
<filter name="group_by_wood" string="Wood" domain="['user_input_id', 'in', {[('question_id','=','Select all the furniture shown in the video'), ('suggested_answer_id','=','Chair')]}]" context="{}"/>
That is, I'm trying to query "give me all the user_input_id of the lines whose question_id is 'Select all the furniture shown in the video' and the suggested_answer_id is 'Chair'. I think it is achievable, but I'm just not hitting the right syntax. Not sure how to use square, curled or normal brackets in the domain and was unable to find any information or example about it.
Please, give me a hand with this.