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 hide Selection Field Options based on condition :

Підписатися

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

Це запитання позначене
fieldsselectioninvisibleodooV11
5 Відповіді
20409 Переглядів
Аватар
Chaanto

Class ExampleCode(models.Model) :

_name = 'example.code'

there is have a one event list

event_list = fields.Selection([
('commu', 'Community Event'),

('company', 'Company Event'),

('school'', 'School Event'),

('collage'', 'Collage Event'),

], string='Event Type')

there 4 set of option based on event_list :

position_company = fields.Selection([
                                                ('ceo', 'CEO'),
                                                ('manager', 'Manager'),
                                                ('employee', 'Employee'),
                                                ('other', 'Others')
                                                ], string='Position')

position_community = fields.Selection([
                                                ('leader', 'Leader'),
                                                ('vice', 'Vice Leader'),
                                                ('member', 'member'),
                                                ('speaker', 'Speaker'),
                                                ('other', 'Others')
                                                ], string='Position')

position_school = fields.Selection([
                                                ('head', 'Headmaster'),
                                                ('teacher', 'Teacher'),
                                                ('council', 'Student Council'),
                                                ('student', 'Student'),
                                                ('other', 'Others')
                                                ], string='Position')

position_collage = fields.Selection([
                                                ('rector', 'Rector'),
                                                ('lecture', 'Lecturer'),
                                                ('student', 'Collage Student),
                                                ('other', 'Others')
                                                ], string='Position')


so instead of making 4 set of them i wanna to put them all in one fields selection then it would be invisible based on event_list is that possible ? if possible can you show me how to do it ?


reason why i wanna do something like this because i dont wanna show 4 position on one tree view so i should make something like this if there is another alternative please tell me how to do this .


Thank you,

Best Regards

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

As an alternative approach you can use a computed field that will have the correct selection, but still use the 4 sub selections to dynamically show the appropriate options:

from odoo import api, fields, models

COMPANY_SELECTION = [
('ceo', 'CEO'),
('manager', 'Manager'),
('employee', 'Employee'),
('other', 'Others')
]
COMMUNITY_SELECTION = [
('leader', 'Leader'),
('vice', 'Vice Leader'),
('member', 'member'),
('speaker', 'Speaker'),
('other', 'Others')
]
SCHOOL_SELECTION = [
('head', 'Headmaster'),
('teacher', 'Teacher'),
('council', 'Student Council'),
('student', 'Student'),
('other', 'Others')
]
COLLAGE_SELECTION = [
('rector', 'Rector'),
('lecture', 'Lecturer'),
('student', 'Collage Student'),
('other', 'Others')
]


class ExampleCode(models.Model):
_name = 'example.code'
event_list = fields.Selection(string='Event Type', selection=[
('company', 'Company Event'),
('commu', 'Community Event'),
('school', 'School Event'),
('collage', 'Collage Event')
])

position_company = fields.Selection(string='Company Position', selection=COMPANY_SELECTION)
position_community = fields.Selection(string='Company Position', selection=COMMUNITY_SELECTION)
position_school = fields.Selection(string='Company Position', selection=SCHOOL_SELECTION)
position_collage = fields.Selection(string='Company Position', selection=COLLAGE_SELECTION)
position = fields.Selection(string="Position", selection=COMPANY_SELECTION + COMMUNITY_SELECTION + SCHOOL_SELECTION + COLLAGE_SELECTION, compute='_compute_position', store=True)

@api.depends('position', 'position_company', 'position_community', 'position_school', 'position_collage')
def _compute_position(self):
for rec in self:
if rec.event_list == 'company':
rec.position = rec.position_company
elif rec.event_list == 'commu':
rec.position = rec.position_community
elif rec.event_list == 'school':
rec.position = rec.position_school
elif rec.event_list == 'collage':
rec.position = rec.position_collage
else:
                rec.position = False


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

There is no way to filter value of selection field or even would not apply domain on it.
​
So the alternative is 
Instead of taking four selection field take one many2one field like
                                                                                                                                                                                                  
position_id = fields.Many2one('job.position')

in job.position take named as type as a selection field like [('community','Community'), ('company','Company'), ....]

now on change of event_list set domain on position_id like
return {'domain': {'position_id': [('type', '=', self.event_list)]}}
​

0
Аватар
Відмінити
Chaanto
Автор

well i thinks is not a good way to solve this problem, because i must make the many2one to handle this things. and my system already full of selection field for this, so i must fix all of them if i using this way.

Ravi Gadhia

Ok, but my main concern about your approach is if you create four different selection field when you need position value in another part of business logic you have to check/select all the fields

Chaanto
Автор

thanks for you answer, i'm already found the alternative that can dynamically to change fields selection based on condition, it just need the 4 global variable and 1 selection field and return the domain for filtering the slection field without change to m2o

Vysakh B Thottarath

@Chaanto Please Share your Answer ..

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 can I make a one2many field a selection field in view Вирішено
fields selection
Аватар
Аватар
Аватар
3
жовт. 25
18270
how to hide a field if empty in view mode and view it in edit mode (odoo11)?
fields invisible
Аватар
0
лист. 17
6282
How to pass values to a method that defines selection for multiple fields?
fields selection
Аватар
0
квіт. 15
4867
How To Change Field Value According To Selection Field Openerp?
fields selection
Аватар
Аватар
1
бер. 15
10325
Why in Selection Field Only Key is Store in Database Not the Value ? Вирішено
fields database selection
Аватар
Аватар
1
груд. 24
2454
Спільнота
  • Навчальний посібник
  • Документація
  • Форум
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