This question has been flagged
1 Reply
3477 Views

hi all,

i want to add some fields in odoo signup form like: contact_no, address etc. below are the model and controller files, are these OK to achieve this? anything wrong here or i missed something? and what about xml template (view) file, please guide how to add in xml file. and anything i missed or misunderstood...

Model inherit and add required fields

class ResUsersExt(models.Model):
    _inherit = 'res.users'
    contact_no = fields.Char(string='Contact No.', required=True)
    address = fields.Text(string='Address', required=True)

in my module's controllers/main.py (ref: https://www.odoo.com/fr_FR/forum/aide-1/how-to-capture-additional-fields-on-signup-74161)

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', 'contact_no', address))
        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()

regards

Avatar
Discard
Best Answer

Hi,

There are few free modules in the odoo app store, which add/brings new field to the sign up form, you can have a look at the coding done for those module and see whether it helps.

  1. https://apps.odoo.com/apps/modules/13.0/auth_signup_address/

  2. https://apps.odoo.com/apps/modules/13.0/additional_fields_signup/


For overriding the existing controllers in Odoo, see this tutorials explaining the same.

  1. How To Inherit Existing Controller in Odoo

  2. Q Context In Odoo


Thanks

Avatar
Discard
Author

thanks @Niyas Raphy, will check and confirm.