Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

How to get value from a radio button in a form

Subscribe

Get notified when there's activity on this post

This question has been flagged
xmlformradiobuttonv15
1 Reply
4411 Views
Avatar
luca li

Hello, 

I want to create an object from the website, i can catch a simple field but i dont undetstand how to do with radio. When i tried i only got "on" value

So here i want to have a field with 3 radio for the remediation_type (soil,choice2,choice3-

here is my controller 

from odoo import http
from odoo.http import request


class Estimate(http.Controller):

@http.route('/estimate_webform/', type="http",auth="public",website="true")
def patient_webform(self,**kw):
return http.request.render('theme_haemertest.create_estimate',{})

@http.route('/create/estimate/', type="http",auth="public",website="true")
def create_estimate(self, **kw):
estimate = request.env['haemer.estimate'].sudo().create({
'owner': kw.get('nowner'),
'name': kw.get('name'),
'address': kw.get('address'),
'latitude': kw.get('latitude'),
'longitude': kw.get('longitude'),
'past_activity': kw.get('past_activity'),
'future_activity': kw.get('future_activity'),
'remediation_type': kw.get('remediation_type'),
'volume': kw.get('volume'),
'density': kw.get('density'),
'humidity': kw.get('humidity'),
'porosity': kw.get('porosity'),
})
vals = {
'estimate': estimate,
}
return request.render("theme_haemertest.create_estimate", vals)

my model : 

from odoo import models, fields

class HaemertestEstimate (models.Model):
_name= "haemer.estimate"
_description = "Estimate's customer"

owner = fields.Char(string='Owner')
name = fields.Char(string='Name')
address = fields.Char(string='Address')
latitude = fields.Integer(string='Latitude')
longitude = fields.Integer(string='Longitude')
past_activity = fields.Char(string='Past Activity')
future_activity = fields.Char(string='Future Activity')
remediation_type = fields.Selection([
('soil', 'Soil'),
('n2', 'Choice2'),
('n3', 'Choice3'),
], required=True, default='soil', tracking=True)
volume = fields.Integer(string='Volume')
density = fields.Integer(string='Density')
humidity = fields.Float(string='Humidity')
porosity = fields.Float(string='Porosity')



xml version="1.0" encoding="UTF-8" ?>

id="menu_estimate_form" model="website.menu">
name="name">create estimate
name="url">/estimate_webform
name="parent_id" ref="website.main_menu"/>
name="sequence">75

id="create_estimate" name="Create Estimate">
t-call="website.layout">
id="wrap">
class="oe_structure">
class="container">
role="form" action="/create/estimate" method="post">
type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
class="form-group">

type="text" name="name" t-att-value="owner" id="owner"
class="form-control" placeholder="owner" required ="required"/>

class="form-group">

type="text" name="name" t-att-value="name" id="name"
class="form-control" placeholder="name" required ="required"/>

class="form-group">

type="text" name="address" t-att-value="address" id="address"
class="form-control" placeholder="address" required ="required"/>

class="form-group">

type="number" step ="any" name="latitude" t-att-value="latitude" id="latitude"
class="form-control" placeholder="0" required ="required"/>

class="form-group">

type="number" step ="any" name="longitude" t-att-value="longitude" id="longitude"
class="form-control" placeholder="0" required ="required"/>

class="form-group">

type="text" name="past_activity" t-att-value="past_activity" id="past_activity"
class="form-control" placeholder="past activity" required ="required"/>

class="form-group">

type="text" name="future_activity" t-att-value="future_activity" id="future_activity"
class="form-control" placeholder="future activity" required ="required"/>

class="form-group">






class="form-group">

type="number" step ="any" name="volume" t-att-value="volume" id="volume"
class="form-control" placeholder="0" required ="required"/>

class="form-group">

type="number" step ="any" name="density" t-att-value="density" id="density"
class="form-control" placeholder="0" required ="required"/>

class="form-group">

type="number" step ="any" name="humidity" t-att-value="humidity" id="humidity"
class="form-control" placeholder="0" required ="required"
min="0" max="1"/>

class="form-group">

type="number" step ="any" name="porosity" t-att-value="porosity" id="porosity"
class="form-control" placeholder="0" required ="required"
min="0" max="1"/>

class="clearfix oe_login_buttons">









 

0
Avatar
Discard
luca li
Author

any one ?

Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi,

Add the selection field as radio button as follows.

<div>


    <input type="radio" id="Choice1" name="remediation_type" value="soil" />


    <label for="Choice1">Soil</label>


    <input type="radio" id="Choice2" name="remediation_type" value="n2" />


    <label for="Choice2">Choice2</label>


    <input type="radio" id="Choice3" name="remediation_type" value="n3" />


    <label for="Choice3">Choice3</label>


</div>

Inside the controller, can access the field as follows:-

kw.get('remediation_type')

Regards

0
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
how to set radio widget as a required field? Solved
radiobutton v15
Avatar
Avatar
Avatar
2
Nov 22
4737
How to set a domain
domain xml v15
Avatar
Avatar
1
Nov 25
393
Error while creating template for pdf
pdf xml v15
Avatar
Avatar
1
May 25
4038
How do i add stages for odoo 15 kanban view?
views xml v15
Avatar
Avatar
1
May 24
3865
ValueError: Wrong value for ir.ui.view.type: 'data'
xml valueerror v15
Avatar
1
Apr 24
3282
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now