Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
5 Antwoorden
7039 Weergaven

Hello everyone.

Can anyone know, how to display customized many2one field as selection field in website shopping cart. Please share the ideas(also code).Thanks in advance

Avatar
Annuleer

dear vadivel,

If i understood you right , I think you need to add widget="selection" on your many2one field.

I hope I helped you.

Beste antwoord

Try it...

Pass all model  objects of the many2one field to the template.

then ...

<select>

    <t t-foreach="all_objects" t-as="each_objects">
        <option>

            <t t-esc="each_objects.name"/>
         </option>
     </t>

</select>    


Avatar
Annuleer

Don't forget to close the <t>-Tag with </t>.

tank u , i shall ...

Beste antwoord

Does anybody know how to "Pass all model  objects of the many2one field to the template.", see answer of "Odoo developer". I could not find an easy way. I could grap the model in the controller via env() and then try to fetch all records in a for loop or something like that but there must be a simpler "odoonic" way to do this, I guess.

(As the questions is old, I am using Odoo 11)

(I would have done a comment but I am  not allowed)

Thanks 

Ok, figured it out myself:

put this in the controller

all_objects = request.env['model.name'].search([])
values = {
"some_values": some_values,
"all_objects": all_objects
}
return request.render(template_name, values)
Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
1
jan. 22
2890
0
jan. 24
1068
1
nov. 15
12060
1
mrt. 15
8512
0
mrt. 15
3565