Search Here

Get Web Form or Template Value in Odoo Controller

In this article I am going to discuss how to get web form values such as input type text, radio, date and checkbox in odoo web controller

Odoo get web form or template value in controller


To achieve this we need to create a form tag in our template and in that form we have to create some input elements such as a date picker, two checkbox and one submit button. Now on the click of submit button we want form data in out controller.

Problem Statement 1

On submit button click get all form data for example (one date picker value and two checkbox value). In this scenario we want to get all form data in our controller. Remember that the form data will be fetched in the form of python dictionary in our controller. In our second scenario we will get only checkbox value in our controller.

Read More: Inherit web login controller in Odoo

Get Web Form or Template Value in Odoo Controller


get_web_form_value_in_controller.xml


get_web_form_value_in_controller.py



Odoo get web form or template value in controller


Read More:
 Invoke controller class function from another controller in odoo

Problem Statement 2

In our second scenario we will manipulate only two checkbox values which we have got on submit button. To achieve this functionality we will modify our controller code like below.

get_web_form_value_in_controller.py


Odoo get web form or template value in controller

As you can see that now we have only two checkbox values in our controller as per our need.

Post a Comment

7 Comments

  1. can you tell me code javascript? how can html know if link go to /tes1 ?

    ReplyDelete
  2. To access the kw dictionary attribute you do it with the get() method, for example
    kw.get('start_date')

    ReplyDelete
  3. how to get related field vlaue in Controllers odoo14?

    ReplyDelete
    Replies
    1. you can set store True in related fields to get value in controller

      Delete
  4. how to display one2many field in a website using controller?

    ReplyDelete