Hello. I have a survey and I want to fetch the answers once customer has filled it and display them inside my custom view.
Odoo version: 16
Within my custom model I have the following code to link it with the survey answers:
answer_ids = fields.One2many('survey.user_input', 'order_id', string="Survey answers")
answers= fields.One2many(
related="answer_ids.user_input_line_ids",
string="Answers",
readonly=True
)
And here is my extension of survey.user_input model:
class CustomSurveyInput(models.Model):
_inherit = ['survey.user_input']
order_id = fields.Many2one('crm.lead', string="Order")
And finally here is the part of the view that tries to show those answers inside a notebook page:
page string="Answers"
field name="answers"
tree
field name="question_id"/
field name="display_name"/
/tree
/field
/page
The notebook tab correctly appears with the Question and Display Name fields but the answers of the survey which I have filled do not populate it and I do not know why. I've looked for a tutorial in Youtube but couldn't find one for this problem. Additionally I have asked ChatGPT for help but it is not getting me further. Any help appreciated and sorry if this is a noob question, I have only recently started learning Odoo.
The thing it's that without a complete scenario and code I will be guessing, but just something to ask... Your custom model it's `crm.lead`? it needs to be because your field `order_id` is a many2one to ``crm.lead
Yes Axel the custom model representing an order inherits the 'crm.lead' and builds upon it.
The idea is that I have extended 'crm.lead' with some custom fields, regex checks etc., and I have also customer model which is an extension of 'res.partner'. I have created a survey which is sent to the customer and once the fill it out I could see their answers inside custom view where I have most of the information from the extended 'crm.lead' that I want to have readily available. I chose to leave most of the code out since I have tested it works and thought it would make it even more difficult to identify the problem (also some of the code is in Finnish so I would have to translate it).
The code doesn't show any errors nor does it crash so I am thinking the problem is due to the logic, but I just can't figure out why the answers to the survey don't show inside the notebook page "Answers".