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

Website get multiple value of selection(multiple="multiple")? [SOLVED]

By
yopi
on 10/12/15, 2:48 AM 1,798 views

Hello,

I've defined a selection on website form, this selection will hold 'many2many' field, so it will look like 'many2many_tags' widget.

For now, on the website form view, I can select more than one value, but when I validated the form value sent to backend, it's only get the first value for this selection.

here my code (xml):

<div id="group_permit" t-attf-class="form-group

       <label class="col-md-3 col-sm-4 control-label" for="permit" >Driving License</label>

       <div id="fields_permit" class="col-md-7 col-sm-8">

       <select multiple="multiple" name="permit_id" class="form-control select2">

              <t t-foreach="permit_ids" t-as="permit">

                         <option t-att-value="permit.id">

                               <t t-esc="permit.name"/>

                          </option>

                   </t>

             </select>

          </div>

    </div>

On the 'firebugs', I see, there are two value for selection field was sent to server:

example:

permit_id: 1

permit_id: 2


On the backend, when I debug the value was sent:

Only detected the first value. {'permit_id': u'1'}


How to get all the value was selected?


Please help :)

thanks.

    



1
yopi
On 12/16/15, 7:37 AM

Hello Jamin Shah,


Thanks for the answer.

Just get a notification for your answer (I almost forget if I asked this question).

Actually, it was solved, nothing wrong with that view, just need extra code on the backend (controller) to handle it.

example:

permit_ids = request.httprequest.form.getlist('permit_id')

Thank you so much, I am also having same issue with multiple select in Odoo website.

Gajanan Kathar
on 11/16/16, 7:03 AM
1
Jamin Shah
On 12/16/15, 12:30 AM

Hello,


Code is fine.

Same code works for me.I think you are missing somewhere in selecting value.

For many2many it send in [1, 2] format which then converted to (6, 0 ..) format.


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

1 follower(s)

Stats

Asked: 10/12/15, 2:48 AM
Seen: 1798 times
Last updated: 7/7/16, 4:48 AM