Skip to Content
Menu
This question has been flagged
3 Replies
3247 Views

I am trying to add in a company name and job position field on the sign up form and add that to the customers record.

I've created a custom module to inherit the auth_signup and added in the field:

<div class="form-group field-name">

                <label for="org_name" class="control-label">Organization Name</label>

                <input type="text" name="org_name" t-att-value="org_name" id="org_name" class="form-control" placeholder="e.g. Organization" required="required" />

</div>

<div class="form-group field-name">

                <label for="pos_type" class="control-label">position Type</label>

               <select name="pos_type" required="True"

                    class="o_website_form_input form-control" >


                      <!--<option value="">Select</option>-->

                      <t t-foreach="[('0', 'Employer'), ('1', 'Employee')]" t-as="pos_type">

                        <option t-att-value="pos_type[0]">

                            <t t-esc="pos_type[1]" />

                        </option>

                     </t>

                </select>

            </div>

How do I get this to save in the res.user, res.partner?

Avatar
Discard
Best Answer

This form should have an action and in the controller, you can see the route which treats the URL, here you will get the values as key:value pair.

Avatar
Discard
Best Answer

Try something like this: https://github.com/marclijour/TFBN/blob/master/addons_project_TFBN/tfbn/controllers/controllers.py

class MyAuthSignupHome(AuthSignupHome):
    # Override
    # Adding two required fields to the value dict, to be passed on to ResUser (Odoo base)
    # The rest is the same
    def do_signup(self, qcontext):
        """ Shared helper that creates a res.partner out of a token """
        values = { key: qcontext.get(key) for key in ('login', 'name', 'password', 
                                                      'company_name', 'function' # Added two fields
                                                     ) }
        _logger.info(qcontext.get('policy'))
        assert qcontext.get('policy') != 'checked', "You need to accept the terms and conditions to become a member."
        assert values.values(), "The form was not properly filled in."
        assert values.get('password') == qcontext.get('confirm_password'), "Passwords do not match; please retype them."
        supported_langs = [lang['code'] for lang in request.env['res.lang'].sudo().search_read([], ['code'])]
        if request.lang in supported_langs:
            values['lang'] = request.lang
        self._signup_with_values(qcontext.get('token'), values) # calls signup() on ResUsers, then authenticates or fails
        request.env.cr.commit()


Avatar
Discard
Author Best Answer

I have this in the controller but the pos_type and org_name is not being stored into the customers page.

class AuthSignupHome(AuthSignupHome):

    def do_signup(self, qcontext):

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

        values = {key: qcontext.get(key) for key in ('login', 'name', 'password', 'org_name', 'pos_type')}

assert values.values(), "The form was not properly filled in."

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

        supported_langs = [lang['code'] for lang in request.env['res.lang'].sudo().search_read([], ['code'])]

        if request.lang in supported_langs:

            values['lang'] = request.lang

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

        request.env.cr.commit()

How do I get pos_type to show in the Job Position field in the sales/customers page?

Avatar
Discard