Odoo Help


Autopopulate "Contact Form" form fields

on 6/29/16, 10:35 AM 1,113 views

Hello everyone, I am using Odoo 9 and I have been trying to autopopulate the "Subject" field of the website's contact form.

So far, each product of the shop has an "Add to cart" button, and I have added a "Contact us" button as well. When the user clicks on the "Contact us" button, the user is sent to the Contact Form. In this scenario, I wish to autopopulate the Subject field of the contact form with the product's name that the customer was checking out before clicking on the contact button.For example, if the user is checking out the product named "Computer" and clicks on the corresponding Contact us" button, the subject field should be autopopulated with "Computer".

The nuance to this is that if a customer enters the website for the first time and goes directly to the Contact Form, the Subject field should be empty, since he is not interested in a specific product.

So far I have tried the following code on the "Product" xml template

<a t-att-href="/page/contactus?name=#{product.name}" class="btn btn-primary btn-lg mt8 js_check_product a-submit"> <font style="font-size: 18px;">Contact us</font> </a>

But this instead of populating the form with the product's name, it populates the form with the word "product.name". Does anyone have any idea how to solve this?


Axel Mendoza

--Axel Mendoza--
| 7 8 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full-time employee trying to understand what to do and how

Reach me at aekroft@gmail.com

Axel Mendoza
On 6/29/16, 4:53 PM

You need to extends the Contact Form controller to pass the product object record to the template rendering, also that controller need to receive the product id to be able to retrieve their name or if you like you could pass the name directly for the Contact Us link

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 6/29/16, 10:35 AM
Seen: 1113 times
Last updated: 6/29/16, 4:53 PM