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.

1

How to capture additional fields on signup?

By
GARY F WALTERS
on 1/25/15, 1:18 AM 1,531 views

The default signup form has fields for Email, Name, Password, and Confirm Password.  I want to add the phone number.

I created a custom module and was able to override the HTML form to add the phone input tag.  

But the only way I could get it to save to the DB was to manually change  addons/auth_signup/controller/main.py

    def do_signup(self, qcontext):

        """ Shared helper that creates a res.partner out of a token """

        values = dict((key, qcontext.get(key)) for key in ('login', 'name', 'password'))

        assert any([k for k in values.values()]), "The form was not properly filled in."

        assert values.get('password') == qcontext.get('confirm_password'), "Passwords do not match; please retype them."

        self._signup_with_values(qcontext.get('token'), values)

The line causing the issue is values = dict((key, qcontext.get(key)) for key in ('login', 'name', 'password')).  If I edit this line and add 'phone' after 'password' it works as expected.

My question is how can I make this change in a custom module instead of hard-coding the change in this file?

 

@Gary,

You definitely can and should make these changes in a custom module as opposed to editing core modules/files.

Could you post the files you have edited on a github gist or repo so that I can take a look?

From what I understand you simply want to add a phone number field to the signup process that will save to the customer's related partner profile after they signup, is that correct?

Luke Branch
on 1/25/15, 2:46 AM

Luke, thanks for the comment. I was able to get the phone number to save by overriding the method in my custom module as shown below.

GARY F WALTERS
on 1/25/15, 8:41 PM
1
GARY F WALTERS
On 1/25/15, 8:23 PM

I found the documentation here https://www.odoo.com/documentation/8.0/reference/http.html#controllers which explained how to extend a controller.  I overrode this method and was able to get the phone number to save to the DB on signup.

# override do_signup method to allow referred_by_id to be set from sign-up form
class AuthSignupHome(AuthSignupHome):
    def do_signup(self, qcontext):
        """ Shared helper that creates a res.partner out of a token """
        values = dict((key, qcontext.get(key)) for key in ('login', 'name', 'password', 'phone'))
        assert any([k for k in values.values()]), "The form was not properly filled in."
        assert values.get('password') == qcontext.get('confirm_password'), "Passwords do not match; please retype them."
        self._signup_with_values(qcontext.get('token'), values)
        request.cr.commit()

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: 1/25/15, 1:18 AM
Seen: 1531 times
Last updated: 3/16/15, 8:10 AM