Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

How to get value from a radio button in a form

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
xmlformradiobuttonv15
1 Odpowiedz
4410 Widoki
Awatar
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
Awatar
Odrzuć
luca li
Autor

any one ?

Awatar
Cybrosys Techno Solutions Pvt.Ltd
Najlepsza odpowiedź

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
Awatar
Odrzuć
Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
how to set radio widget as a required field? Rozwiązane
radiobutton v15
Awatar
Awatar
Awatar
2
lis 22
4733
How to set a domain
domain xml v15
Awatar
Awatar
1
lis 25
391
Error while creating template for pdf
pdf xml v15
Awatar
Awatar
1
maj 25
4032
How do i add stages for odoo 15 kanban view?
views xml v15
Awatar
Awatar
1
maj 24
3858
ValueError: Wrong value for ir.ui.view.type: 'data'
xml valueerror v15
Awatar
1
kwi 24
3281
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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