콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

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.

    



아바타
취소
작성자 베스트 답변

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.

Still an issue in Odoo V13 & this solution still works by the way.

베스트 답변

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.


아바타
취소
관련 게시물 답글 화면 활동
0
5월 22
2340
1
11월 24
2160
4
6월 22
20763
2
8월 20
10760
0
7월 20
3285