Aide

1

How to display with selection my users into my form

Avatar
Jules

Hello, 

I want to display with selection input, my users database 's table.


This is my template : 

<div class="form-group form-field">
<div class="col-md-3 col-sm-4 text-right">
<label class="control-label" for="x_membre_interne">
Membres de l'équipe ffeeaz
</label>
</div>

<div class="col-md-7 col-sm-8 ">
<select id="membre_interne" name="x_membre_interne"
class="form-control height-select">
<option value="" selected="selected">Sélectionnez...</option>
<t t-foreach="users" t-as="user">
<option value="">
<t t-esc="user.name"/>
</option>
</t>
</select>
</div>
Controller.py: 
""" formulaire pour deposer un appel d'offre """
@http.route('/coopaname_helpdesk/post_form_ticket/<string:model_name>', methods=['POST'], type = 'http', auth='public', website= True, Store=True )
def website_form(self, model_name, **kwargs):

objet_consultation = kwargs.get('x_objet_consultation')
cat = kwargs.get('x_cat')
membre_interne = kwargs.get('x_membre_interne')
membre_externe = kwargs.get('x_membre_externe')
equipeok = kwargs.get('x_equipeok')
admin = kwargs.get('x_admin')
type_marche = kwargs.get('x_type_marche')
ville_adju = kwargs.get('x_ville_adju')
date_order = kwargs.get('x_date_order')
date_limite = kwargs.get('x_date_limite')
duree_marche = kwargs.get('x_duree_marche')
montant_marche = kwargs.get('x_montant_marche')
num_ref = kwargs.get('x_num_ref')
pj = kwargs.get('x_pj')
name = kwargs.get('x_name')
mail = kwargs.get('x_mail')
inputstreet1 = kwargs.get('x_inputstreet1')
inputcity1 = kwargs.get('x_inputcity1')
inputzip1 = kwargs.get('x_inputzip1')
inputstreet2 = kwargs.get('x_inputstreet2')
inputcity2 = kwargs.get('x_inputcity2')
inputzip2 = kwargs.get('x_inputzip2')

data = {
'x_cat' : cat,
'x_objet_consultation' : objet_consultation,
'x_membre_interne' : membre_interne,
'x_membre_externe' : membre_externe,
'x_equipeok' : equipeok,
'x_admin' : admin,
'x_type_marche' : type_marche,
'x_ville_adju':ville_adju,
'x_date_order': date_order,
'x_date_limite': date_limite,
'x_duree_marche': duree_marche,
'x_montant_marche' : montant_marche,
'x_num_ref' : num_ref,
'x_pj' : pj,
'x_name' : name,
'x_mail' : mail,
'x_inputstreet1' : inputstreet1,
'x_inputcity1' : inputcity1,
'x_inputzip1' : inputzip1,
'x_inputstreet2': inputstreet2,
'x_inputzip2' : inputzip2,
'x_inputcity2' : inputcity2
}
users = request.env['res_partner'].sudo().search([])
request.env['monmarchepublic'].create(data)
return http.request.render('/coopaname_helpdesk/succes', {'users' : users})

Should i put my foreach loop inside my value 's input or outside ? 

Thanks for help my friends ! 

2 Comments
Avatar
Discard

Thanks my friends you're the best ! 

Sorry but i just started odoo and python language ^^


Not a problem. I am glad that at least you tried something rather than just asking how to do that.

2 Réponses
2

Your code of  searching the users / partners is wrong.

It should be as follow:

users = request.env['res.users'].sudo().search([])


Avatar
Discard
0
Avatar
Jithin
Best Answer
<div class="col-md-7 col-sm-8 ">
<select id="membre_interne" name="x_membre_interne"
class="form-control height-select">
<option value="" selected="selected">Sélectionnez...</option>
<t t-foreach="users" t-as="user">
<option t-att-value="user.name">
<t t-esc="user.name"/>
</option>
</t>
</select>
</div>


Avatar
Discard