Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
5145 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona
Autore

thanks @Niyas Raphy, will check and confirm.

Risposta migliore

Hi, this might help you: https://youtu.be/An6YTH3kJD8

Thanks

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
3
ago 23
5256
1
dic 24
4286
0
giu 21
2336
2
giu 22
4597
0
giu 21
2572