Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

How to get value from a radio button in a form

Odoberať

Get notified when there's activity on this post

This question has been flagged
xmlformradiobuttonv15
1 Odpoveď
4407 Zobrazenia
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
Zrušiť
luca li
Autor

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
Zrušiť
Enjoying the discussion? Don't just read, join in!

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
how to set radio widget as a required field? Solved
radiobutton v15
Avatar
Avatar
Avatar
2
nov 22
4733
How to set a domain
domain xml v15
Avatar
Avatar
1
nov 25
391
Error while creating template for pdf
pdf xml v15
Avatar
Avatar
1
máj 25
4031
How do i add stages for odoo 15 kanban view?
views xml v15
Avatar
Avatar
1
máj 24
3857
ValueError: Wrong value for ir.ui.view.type: 'data'
xml valueerror v15
Avatar
1
apr 24
3279
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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