Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Is it possible to add a functionnal field, or perform onchange functions on odoo survey (Qweb views) ?

By
Yassine TEIMI
on 11/2/15, 3:09 PM 897 views

Dears,

During the survey, I need to add a "functionnal field", that computes a value based on other fields value.

For example, I have a question (Matrix type), and I want to perform such action during the survey (please copy/paste the link below):

http://prntscr.com/8yar4b

Is it possible to perform such developpement on a survey ?

Any hints, propositions will be welcome guys.

I have some ideas to share, your toughts interest me a lot.

Thanks.

Thanks Axel for your answer. It's very interesting. In my case, the survey module has no Qweb reports, it's based on generated Qweb templates. My goal is to compute the values and store them in the database, so as to use them on the survey dashboard. To be more precise, I'm developping a very specific human ressources appraisals, and the purpose is to compute values based on other fields value to give the hr manager, after the evaluation, an idea about the reaching goals percentage, defined last year. Therefore, once the evaluation is finished, the manager should be able to print these computed values, and also have them on his dashboard. Is it possible to do such developpement using javascript functions ? How could it be stored on the database then ? ( I would like to know more about what happens on server side when the evaluation form is sent). Thanks a lot for your answers.

Yassine TEIMI
on 11/3/15, 11:30 AM
0
Yassine TEIMI
On 11/5/15, 5:18 AM

Axel, The main problem for me, is that I'm obligated to print the computation, that's why I'm looking for a solution to compute and show results on the qweb template, if only there is a way to collect data, compute on the background via a functionnal field, and show computation results via a new qweb report (survey answers), it will be a great solution. What do you think of mi idea ? do you think is technically doable ? 

There are 3 ways for using qweb templates,2 that matters for your situation, one for reports and the other for website pages, I'm doing deep stuffs inside qweb templates and their components these days, maybe if you show me some code of what you are doing or images of what you need, then I could figure out better your situation and could help you

Axel Mendoza
on 11/30/15, 4:17 AM

If you will share some code, better upload to a github repo in the form of a module so I can install it and test it

Axel Mendoza
on 11/30/15, 4:19 AM
0

Axel Mendoza

--Axel Mendoza--
10203
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 11/2/15, 4:17 PM

From my point of view the best way to solve this is by doing the computation in a parser method that return the list of rows to display and iterate that list in the qweb report template. An example for your image

def crosstab(self, values):
    crosstab = []
headers = ('','Col 1', 'Col 2')
crosstab.append(headers)
    crosstab.append(('Line 1', 'Value (1,1)', 'Value (1,2)'))
crosstab.append(('Line 2', 'Value (2,1)', 'Value (2,2)'))
#calculate the rest of the lines or the previous to add the result to the list
crosstab.append(('Line 1', 'Value (1,1)', 'Value (1,2)'))

    return crosstab

Use like this in the qweb report template:

<table class="table table-bordered">
<t t-foreach="crosstab(value)" t-as="row">
    <tr>
<t t-foreach="row" t-as="measure">
        <td t-esc="measure"/>
      </t>
    </tr>
</t>
</table>

Change value to what you need to pass to the report function as an argument or pass more or less arguments depending of what you need to use to compute the crosstab table measures

Here is how to add functions in the parser, config the parser and use it on the qweb report template:

https://www.odoo.com/es_ES/forum/help-1/question/how-to-define-a-custom-methods-functions-to-be-used-in-a-qweb-report-how-to-define-and-use-a-report-parser-92244

Do you means that your surveys are website templates? and you need the same as I described but for the website templates?

Axel Mendoza
on 11/3/15, 1:15 PM

Yes the surveys are website templates (Qweb), Yes I need some solution to compute the values entered by the user, and after the survey is sent, store it to the database, because I'll need it after for hr appraisals dashboards.

Yassine TEIMI
on 11/4/15, 4:37 AM

Please take a look at : survey/views/survey_templates.xml there is all templates rendered during the survey user experience. I did some specific developpement on the matrix template, by extending its behavior ... I'm available if you want further explainations.

Yassine TEIMI
on 11/4/15, 4:48 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

3 follower(s)

Stats

Asked: 11/2/15, 3:09 PM
Seen: 897 times
Last updated: 11/5/15, 5:19 AM