Skip to Content
Menu
This question has been flagged
1 Atsakyti
10130 Rodiniai

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?

 

Portretas
Atmesti

@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?

Autorius

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.

Autorius Best Answer

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()

Portretas
Atmesti
Related Posts Replies Rodiniai Veikla
2
bal. 25
3227
2
geg. 15
7414
0
kov. 15
4515
2
gruod. 23
44171
1
lapkr. 17
5596