So I have a POST route in my controller that is supposed to send an email.
controller.py:
class Customer(http.Controller): @http.route('/api/hello', methods=['POST'], auth='public', type='http', website=True) def index(self, **kw): message = Mail( from_email='x@gmail.com', to_emails='x@gmail.com', subject='Notification', html_content="Working") sg = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY')) sg.send(message)
And in my view.xml I have a form asking for name, email and that kind of stuff.
view_field.xml:
<?xml version="1.0" encoding="UTF-8"?> <odoo> <record model="ir.ui.view" id="customer_field_form"> <field name="name">Field</field> <field name="model">customer.field</field> <field name="arch" type="xml"> <form action="/api/hello" method="POST"> <sheet> <group> <field name="name" placeholder="Full Name"/><br /> <field name="email_address" placeholder="Email Address" /><br /> <field name="subject" placeholder="Subject"/><br /> <field name="message" placeholder="Message" /><br /> <button name="submit" type="submit" > Submit </button> </group> </sheet> </form> </field> </record> </odoo>
Well no matter what I do my route is never called and the email never sent. I tried putting an < input > instead of a button but it doesn't work either. I really don't see what I'm doing wrong.
If I change my method in a GET and launch it with Chrome the email is sent. So I doubt the problem comes from my route. And yes I have my imported my route in the init.py file.