Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
4986 Lượt xem

I am working with the Surveys module in Odoo v14, and it seems to be powerful enough to design different questionaires to be used in many different situations... for example to send it to clients to ask for their satisfaction about a given product or service, or to a candidate that has applied for a job to ask them detailed questions about their previous experience.

The problem I'm facing is how to associate those survey responses to the object that originated them, for example if I send the satisfaction survey to a given customer, I want to be able to see that survey response from the client record. Or if I send the previous experience survey to a candidate, I want to access it from the candidate record.

Currently I can only access the surveys from the surveys module, and have to manually search for the specific survey response I want to find, which is highly inefficient and also lacks any traceability and direct link to the original object. Has anybody faced this situation and has found a solution or workaround for this problem?

Any ideas are appreciated, thanks!

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Is it possible to implement this functionality even if the user is not logged in? If I collect email addresses through the survey, is there a method to match these emails with the corresponding contacts? Thanks in advance!

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Answer above only covers use cases when survey is related to a user.

But in real life you want to relate survey results to products, affiliates, partners, ... 

In my case I have service tasks to assess partners, doing a supplier audit/assessment.

So you have somehow relate the survey to a particular partner and their products, which is not supported out of the box.

The approach I've implemented in odoo is outlined as follows

  • Inherit Controller to write related business object info)
  • In calling the  survey (URL-Action) pass the context (related business object info)
  • Inherited Controller process the context and add it to survey.user_input

Custom Controller

Important here: add an additional parameter, in my case task_id

The clue is to pass your context info in the additional_vals which are then evaluated and written by default to the survey.user_input.

You have to inherit of course the according to your needs.

class SurveyController(Survey):        
​@http.route('/survey/start/', type='http', auth='public', ​website=True)   
def survey_start(self, survey_token, answer_token=None, email=False, task_id=None,**post):
    ​# the clue, add additional_vals, which are then written to the survey anser       
​additional_vals = {} # f
​if task_id:           
​reffering_task = request.env['project.task'].sudo().search([
​('id', '=', task_id)], limit=1)           
​additional_vals = {'my_partner_id': reffering_task.partner_id.id,
​ 'my_standard_id': reffering_task.standard_id.id                    # rest of the controller remain unchanged
​....

Call Survey:

Survey is called by url action. you have to add your context info (in my case task_id) to be evaluated be the survey controller start (see above)

...
   self.ensure_one()       
​url = '%s?%s' % (self.get_start_url(), werkzeug.urls.url_encode(
​{'answer_token': answer and answer.access_token or None,
​'task_id': self.id}))  # open via URL-Action       
​return {
​'type': 'ir.actions.act_url',
​​'name': "Start Survey", 
​'target': 'new', 
​'url': url       
​}
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Since the Customer is a Contact in Odoo (res.partner records) you can use Odoo Studio to create a smart button to access all responses, because the partner_id field is already on the Survey Response (if the Customer is logged in when they reply).

First, create a field on the Contact to link to the Survey Responses:



Next, use Odoo Studio to create the Smart Button:







Once you send a Survey and receive a response, you will see them from the Contact record.


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 3 24
3250
0
thg 9 23
1180
2
thg 5 23
2049
1
thg 12 20
3761
print survey Đã xử lý
2
thg 10 20
3702