Skip to Content
Menu
This question has been flagged
1 Reply
5462 Views

I want to add a new partner from website.


//.py

class Test(http.Controller):
@http.route('/create/partner', type="http", website=True, auth="public")
    def create_partner(self, **kw):
        request.env["res.partner"].sudo().create(kw)
        return request.render("my_project.first_page", {
        })

//.xml
<template id="create_page" name="Create">
    <t t-call="website.layout">
         <form role="form" action="/create/partner" method="POST">
             <input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
                    <div class="form-group row form-field o_website_form_custom o_website_form_required_custom">
                        <div class="col-lg-3 col-md-4">
                            <label class="col-form-label" for="Name">Partner Name</label>
                        </div>
                        <div class="col-lg-4 col-md-8">
                            <input type="text" id="name" class="form-control o_website_form_input"
                                   placeholder="name..."
                                   required="required"/>
                        </div>
                          <div class="col-lg-4 col-md-8">
                               <button  type="submit" class="btn btn-primary te_theme_button">Add Partner</button>
                        </div>
                    </div>
         </form>
    </t>
</template>

But , I got this error message :  "res_partner_check_name"
Any help please ?

Thanks.


Avatar
Discard
Best Answer

Hi,

This error occurred because the name field in res.partner is empty.Make sure that there is a name attribute in the kw argument list.

Regards

Avatar
Discard
Related Posts Replies Views Activity
0
Sep 23
41
4
Mar 23
15287
2
Jul 22
2451
0
May 22
1135
1
Nov 21
17204