Skip to Content
Odoo Меню
  • Увійти
  • Спробуйте це безкоштовно
  • Додатки
    Фінанси
    • Бухоблік
    • Виставлення рахунку
    • Витрати
    • Електронні таблиці (BI)
    • Документи
    • Підпис
    Продажі
    • CRM
    • Продажі
    • POS Магазин
    • POS Ресторан
    • Підписки
    • Оренда
    Веб-сайти
    • Конструктор веб-сайту
    • Електронна комерція
    • Блог
    • Форум
    • Живий чат
    • Електронне навчання
    Ланцюг поставок
    • Склад
    • Виробництво
    • PLM
    • Купівлі
    • Технічне обслуговування
    • Якість
    Кадри
    • Співробітники
    • Рекрутинг
    • Відпустки
    • Оцінювання
    • Рекомендації
    • Автотранспорт
    Маркетинг
    • Маркетинг соцмереж
    • Email-маркетинг
    • SMS-маркетинг
    • Події
    • Автом. маркетингу
    • Опитування
    Послуги
    • Проект
    • Табелі
    • Виїзне обслуговування
    • Служба підтримки
    • Планування
    • Призначення
    Продуктивність
    • Обговорення
    • Схвалення
    • IoT
    • IP-телефонія
    • База знань
    • WhatsApp
    Сторонні модулі Odoo Studio Платформа Odoo Cloud
  • Сфери
    Роздрібна торгівля
    • Книжковий магазин
    • Магазин одягу
    • Магазин меблів
    • Продуктовий магазин
    • Магазин будівельних матеріалів
    • Магазин іграшок
    Food & Hospitality
    • Бар та паб
    • Ресторан
    • Фастфуд
    • Guest House
    • Дистриб'ютор напоїв
    • Hotel
    Нерухомість
    • Real Estate Agency
    • Архітектурна фірма
    • Будівництво
    • Управління нерухомістю
    • Садівництво
    • Асоціація власників нерухомості
    Консалтинг
    • Бухгалтерська компанія
    • Партнер Odoo
    • Агенція маркетингу
    • Юридична фірма
    • Придбання Талантів
    • Аудит та сертифікація
    Виробництво
    • Textile
    • Metal
    • Меблі
    • Їжа
    • Brewery
    • Корпоративні подарунки
    Здоров'я & Фітнес
    • Спортивний клуб
    • Оптика
    • Фітнес-центр
    • Практики здоров'я
    • Аптека
    • Салон краси
    Trades
    • Ремонтник
    • IT-обладнання та Підтримка
    • Системи сонячної енергії
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Інші
    • Nonprofit Organization
    • Екологічна агенція
    • Оренда білбордів
    • Фотографія
    • Лізинг велосипедів
    • Реселлер програмного забезпечення
    Browse all Industries
  • Спільнота
    Навчання
    • Навчальний посібник
    • Документація
    • Сертифікації
    • Тренування
    • Блог
    • Подкаст
    Сприяйте Освіті
    • Програма навчання
    • Бізнес гра Scale Up!
    • Відвідайте Odoo
    Отримайте програмне забезпечення
    • Завантаження
    • Порівняйте версії
    • Релізи
    Співпрацюйте
    • Github
    • Форум
    • Події
    • Переклади
    • Стати партнером
    • Services for Partners
    • Зареєструйте вашу бухгалтерську фірму
    Отримайте послуги
    • Знайдіть партнера
    • Знайдіть бухгалтера
    • Зустріньтеся з консультантом
    • Послуги з впровадження
    • Референси клієнтів
    • Підтримка
    • Оновлення
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Отримати демо
  • Ціни
  • Допомога

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

  • CRM
  • e-Commerce
  • Бухоблік
  • Склад
  • PoS
  • Проект
  • MRP
All apps
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
All Posts Люди Значки
Мітки (View all)
odoo accounting v14 pos v15
Про цей форум
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
All Posts Люди Значки
Мітки (View all)
odoo accounting v14 pos v15
Про цей форум
Допомога

How to filter second selector depending on the answer of the first selector?

Підписатися

Отримуйте сповіщення про активність щодо цієї публікації

Це запитання позначене
authenticationqwebsignupauth_signup
5 Відповіді
9868 Переглядів
Аватар
Jesús Alan Ramos Rodríguez

I have been working in the singup form view where I define new fields that are selectors, I need that when you select the first field (Brand), the second shows data depending on the first selector (Brand/Model). To get the data from the database to the selectors I use.

<t t-foreach="request.env['fleet.vehicle.model.brand'].search([])" t-as="brand">

It works perfectly, but the problem is that I need the second selector only shows Models from the brand I selected in  the first selector.

How can I get the data from the first selector to use in a search([('brand_id', '=', brand_id)])?

There is on_change in website views?

I paste the code below:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="auth_signup_motomanic.fields"
inherit_id="auth_signup.fields"
name="Auth Signup/ResetPassword form fields">
<xpath expr="//div[@class='form-group field-confirm_password']" position="after">
<div t-attf-class="form-group #{error and 'brand_id' in error and 'has-error' or ''}">
<label class="control-label" for="brand_id">Brand</label>
<select name="brand_id" class="form-control">
<option value="">Brand...</option>
<t t-foreach="request.env['fleet.vehicle.model.brand'].search([])" t-as="brand">
<option t-att-value="brand.id" t-att-selected="brand.id == (int(brand_id) if brand_id else website.user_id.partner_id.vehicle_id.model_id.brand_id.id)">
<t t-esc="brand.name"/>
</option>
</t>
</select>
</div>
<div t-attf-class="form-group #{error and 'model_id' in error and 'has-error' or ''}">
<label class="control-label" for="model_id">Model</label>
<label class="control-label" for="model_id"><t t-esc="brand_id"/></label>
<select name="model_id" class="form-control">
<option value="">Model...</option>
<option value=""><t t-esc="request.params.copy()"/></option>
<t t-foreach="request.env['fleet.vehicle.model'].search([])" t-as="model">
<option t-att-value="model.id" t-att-selected="model.id == (int(model_id) if model_id else website.user_id.partner_id.vehicle_id.model_id.id)">
<t t-esc="model.name"/>
</option>
</t>
</select>
</div>
</data>
</openerp>

0
Аватар
Відмінити
Oscar Alcala

You need JS here.

Аватар
Oscar Alcala
Найкраща відповідь

Dude there is no on_change for the website templates, but here is a workaround that will work for you in JS:

     $("select[name='brand_id']").change(function(){

     var $select = $("select[name='model_id']");

     $select.find("option:not(:first)").hide();

     var nb = $select.find("option[data-brand_id="+($(this).val() || 0)+"]").show().size();

     $select.val(0);

     });

you also need to add this two atttributes to your selection field on his <option> tag: `style="display:none;" t-att-data-brand_id="model.brand_id.id"`


Hope it works, haven't tested on a real project.

0
Аватар
Відмінити
Аватар
Shivam Mahajan
Найкраща відповідь

Well you can use the attrs attribute of the field .Depending upon the value in the first selection box the value in the second box changes automatically . 

The demo code for simplifying your need is :

class selector(models.Model):

_name='select.selector'

selector1=fields.Selection([('BLY','Bareilly'),('NDA','Noida'),('DL','Delhi')],"Brands")

selector21=fields.Selection([('IU','Invertis University'),('SRMS','SRMS')],"Models")

selector22=fields.Selection([('GU','Galgotia University'),('AU','Amity')],"Models")

selector23=fields.Selection([('DCE','DU'),('IIT','IIT DELHI')],"Models")



View.xml

<group><field name="selector1"/></group>

<group><field name="selector21" attrs="{'invisible': [('selector1', '!=', 'BLY')]}"/>

<field name="selector22" attrs="{'invisible': [('selector1', '!=', 'NDA')]}"/>

<field name="selector23" attrs="{'invisible': [('selector1', '!=', 'DL')]}"/></group>

 



1
Аватар
Відмінити
Аватар
Ray Carnes
Найкраща відповідь

Checkout crm_claim - the module that does this:


0
Аватар
Відмінити
Jesús Alan Ramos Rodríguez
Автор

thanks for your response. The main problem is that Sign Up is a front end (Qweb) view. It's created with auth_signup module and Allow external users to sign up = True, I cannot upload a picture of the view but when you register name, email and password I added two new fields "Brand" and "Model" that are after "Confirm Password", when you select the brand the models related to that brand need to be shown in the second selector.

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

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

Реєстрація
Related Posts Відповіді Переглядів Дія
How to Register new users on Odoo with Google
authentication auth_signup
Аватар
Аватар
Аватар
2
груд. 22
4011
An exception while creating new user signup. Record does not exist or has been deleted. None
signup auth_signup
Аватар
Аватар
1
бер. 18
6114
[V8] Google OAuth 2 and Sign up - how to make the work at the same time?
authentication google signup auth_signup resetpassword
Аватар
0
квіт. 15
4565
How to add Country field in signup page?
login signup auth_signup
Аватар
Аватар
1
квіт. 25
4330
Help needed for authenticating users on Odoo16
authentication auth_signup authenticate
Аватар
Аватар
1
лип. 23
3203
Спільнота
  • Навчальний посібник
  • Документація
  • Форум
Open Source
  • Завантаження
  • Github
  • Runbot
  • Переклади
Послуги
  • Хостинг Odoo.sh
  • Підтримка
  • Оновлення
  • Кастомні доробки
  • Навчання
  • Знайдіть бухгалтера
  • Знайдіть партнера
  • Стати партнером
Про нас
  • Наша компанія
  • Торгові активи
  • Зв'яжіться з нами
  • Вакансії
  • Події
  • Подкаст
  • Блог
  • Клієнти
  • Юридичні документи • Конфіденційність
  • Безпека
الْعَرَبيّة 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 - це набір програм для роботи з відкритим кодом, які охоплюють всі ваші потреби компанії: CRM, електронна комерція, бухгалтерський облік, склад, точка продажу, управління проектами тощо.

Унікальна пропозиція Odoo - це одночасно дуже проста у використанні та повністю інтегрована.

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