This question has been flagged
2 Replies
11763 Views

Here i need the following,

1.add country while user signing up in web/signup url.


Here is my code...

addons/auth_signup/views/auth_signup_login.xml


<div class="form-group">

<label class="control-label" for="country_id">Country</label>

<select name="country_id" id="country_id" class="form-control">

<option value="">Country...</option>

<t t-foreach="countries or []" t-as="country">

<option t-att-value="country.id" t-att-selected="country.id == auth_signup.get('country_id')"><t t-esc="country.name"/></option>

</t>

</select>

</div>


but it not listing the countries list from res.country

please give any ideas / suggestions

thanks in advance...!

Avatar
Discard
Best Answer

Hello Jothimani

I recently came across this problem and found a solution.

Now, the t-att-selected in your xml option will still fail as auth_signup does not have anything with country-id. I'd just remove the t-att-selected.

You'll have to modify the controller 'main.py' of the module auth_signup. Or inherit it (preferred way)

Then add the following code to the top of the method 'web_auth_signup':

orm_country = request.registry.get('res.country') 
country_ids = orm_country.search(request.cr, SUPERUSER_ID, [], context=request.context)
countries = orm_country.browse(request.cr, SUPERUSER_ID, country_ids, context=request.context)
qcontext = self.get_auth_signup_qcontext() # This line is already present in this method.
qcontext['countries'] = countries
# Paste the rest of the original method here.

Hope my explanation was clear

Cheers!

Avatar
Discard
Best Answer

Hello,

Thanks @SonnyV, It worked for me,

Here is how to do the same thing in a single line with the new v8 API:

qcontext['countries'] = http.request.env['res.country'].sudo().search([])
Avatar
Discard