Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
8950 Zobrazení

in the below code i can able to submit form and can able to store data in database, but at the same time how to call method

please see the below code

==============template.xml===============

================

<template id="regis">  
<t t-call="website.layout">
<div id="wrap" class="oe_structure oe_empty">
<form action="/website_form/" method="post" class="s_website_form form-horizontal container-fluid mt32" enctype="multipart/form-data" data-model_name="empdetails.regis" data-success_page="/christjobs/thankyou">
<div class="hff hff_textbox form-group" data-form-type="textbox" data-field-id="0">
<input type="text" name="reg_name" class="form-control" placeholder="NAME OF STUDENT AS PER 10 RECORD "/>
</div>
<button class="btn btn-primary btn-lg o_website_form_send">Register</button>
</form>
</div>
</div>
</t>
</template>

==============model.py===============================

class regis(models.Model): 
_name = 'empdetails.regis'
reg_name = fields.Char(string="Name", required=True)
@api.multi
def otp_send_email(self):
print 'method calling done'
Avatar
Zrušit
Nejlepší odpověď

Hi,

It will be better for you to call the method from the python. once you successfully submitted the data to back end, you will be redirected to this page as per the code, /christjobs/thankyou

data-success_page="/christjobs/thankyou">

So, from the controller of this page you can call the method.

@http.route('/christjobs/thankyou', type='http', auth="public", website=True)
def test_method(self, **kw):
    # from here you can call
    sale_rec = request.env['sale.order'].search([('id', '=', 1)]).method_name()
    request.render('template_page')


Thanks

Avatar
Zrušit
Autor

Thank you Task Done

Autor Nejlepší odpověď

you are amazing boss..............

Task Done

Avatar
Zrušit