This question has been flagged

Hi,

I followed the instructions written by Frank Adler on the following post about the same question:

https://www.odoo.com/es_ES/forum/ayuda-1/question/how-to-do-custom-forms-in-v8-website-62623

I will paste my question at this point:

I am trying to do the same operation explained in the previous post by Frank but using the recruitment module. I am trying to insert values into the applicant profile (equivalent to a Lead in your example) from the contact form which is filled by the candidate itself. I added a new field in the contact form (for example, the surname of the candidate) like follows:

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

    <div class="col-md-3 col-sm-4 text-right">

        <label class="control-label" for="x_surname">Your surname</label>

    </div>

    <div class="col-md-7 col-sm-8">

        <input type="text" class="form-control o_website_form_input" name="x_surname" required=""/>

    </div>

</div>

At the same time, I created the field x_surname on the Odoo backend as explained in the video. But when the applicant fills the form, every predefined field  (name, email, phone...) is well inserted but not the surname that I created.

Do anyone have any idea what can be missing?

Thank you so much!

Avatar
Discard
Best Answer

Hi,
You can write your own new field i the front end and also you created the fields at the back end

now you focus on the controller and inherit the classes


class WebsiteFormCustom(WebsiteForm):

 def insert_record(self, request, model, values, custom, meta=None):
        """ Inserting the values from the forms use the function """
        if model.model == 'hr.applicant':
           
            applicant_id = super(WebsiteFormCustom, self).insert_record(request,
                                                                        model,
                                                                        values,
                                                                        custom,
                                                                        meta=None)
            this_applicant_id = request.env['hr.applicant'].sudo().browse(
                applicant_id)
           
            this_applicant_id.sudo().write({
                'partner_name': values['partner_name'] + values['last_name'],
                'first_name': values['partner_name'],
                'last_name': values['last_name'],
                'street1': values['street1'],
             //Add your custom fields here
            })
 
            return applicant_id

Hope it helps

Avatar
Discard