Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • eLearning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Información
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Food & Hospitality
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Guest House
    • Distribuidor de bebidas
    • Hotel
    Real Estate
    • Real Estate Agency
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consulting
    • Accounting Firm
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Trades
    • Handyman
    • Hardware y asistencia informática
    • Solar Energy Systems
    • Zapatero
    • Servicios de limpieza
    • HVAC Services
    Others
    • Nonprofit Organization
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Browse all Industries
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Services for Partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar una demostración
  • Precios
  • Ayuda

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

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyecto
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

Related selection field or parent child drop down menus in odoo 14

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
pythonxmlmany2onerelateddomain_filter
2 Respuestas
4464 Vistas
Avatar
jomin joseph

Hi guys i am using odoo 14, i have created a custom module that inherit into odoo, i want to create a selection field which i related to another field for eg: i have a selection field: A it has 3 options 1,2,3 if i select option 1 , it should show another selection field which should come only if i select 1 , if i select 2 it should show another selection field , is there any way i can achieve this using python or xml in odoo

0
Avatar
Descartar
Avatar
ss
Mejor respuesta

Hi, @jo
In Python
, Define all the SELECTION FIELDS that is required feature, that is the selection field with value 1 2 3 and selection field that will show for option 1 and selection field to show for option 2.

selection = fields.Selection([('1', '1'), ('2', '2'), ('3', '3')])
slection_for_opt_1 = fields.Selection([('5', '5'), ('6', '6')])
slection_for_opt_2 = fields.Selection([('7', '7'), ('8', '8')])

In XML, Add attrs attribute for the field defination on view as mentioned below

field name="selection"
field name="slection_for_opt_1" attrs="{'invisible': [('selection', '!=', '1')]}"
field name="slection_for_opt_2" attrs="{'invisible': [('selection', '!=', '2')]}"

1
Avatar
Descartar
jomin joseph
Autor

Hi @Sujata Bhuyan, i tried the code you shared but i am getting this error ValueError: dictionary update sequence element #0 has length 3; 2 is required

ss

Hi @jo, Can you share your code here. So that I can help.

jomin joseph
Autor

python side

# -*- coding: utf-8 -*-

from odoo import models, fields, api

class FieldsCustomDropDown(models.Model):
_inherit = 'sale.order'

selection = fields.Selection([('1', '1'), ('2', '2'), ('3', '3')])
slection_for_opt_1 = fields.Selection([('5', '6', '7')])
slection_for_opt_2 = fields.Selection([('8', '9', '10')])
slection_for_opt_3 = fields.Selection([('11', '12', '13')])
xml side

<record id="new_test_add_custom_purchase_fields_parameters_inherit" model="ir.ui.view">
<field name="name">purchase.test.add..new.custom.fields.inherited</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='category']"
position="after">
<field name="item"/>
</xpath>
</field>
</record>
actual selection will be around 10 options this for testing purpose i did but its not working

Avatar
Jainesh Shah(Aktiv Software)
Mejor respuesta

Hi Jo, 

Please find code in comment. 

I hope this will help you. 

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

0
Avatar
Descartar
Jainesh Shah(Aktiv Software)

Code :-

XML:
<field name="selection"/>
<field name="slection_for_opt_1" attrs="{'invisible': [('selection', '!=', '1')]}"/>
<field name="slection_for_opt_2" attrs="{'invisible': [('selection', '!=', '2')]}"/>
PY:
selection = fields.Selection([('1', '1'), ('2', '2'), ('3', '3')], string="Selection")
slection_for_opt_1 = fields.Selection([('5', '5'), ('6', '6'), ('7', '7')], string="Selection_1")
slection_for_opt_2 = fields.Selection([('8', '8'), ('9', '9'), ('10', '10')], string="Selection_2")

jomin joseph
Autor

this worked perfectly, i made an error in python side that's why it was not reflecting, thank you sir

¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
What should the view inherit from?
python xml view many2one
Avatar
0
mar 15
5133
OpenERP 7 many2one with current month filter
filter python xml many2one
Avatar
Avatar
2
mar 15
30226
openerp 7 .netsvc: Unable to use a closed cursor.
python xml many2one __openerp__.py
Avatar
0
mar 15
7096
How to hide view.xml fields group in Account module with attr
python xml
Avatar
Avatar
Avatar
2
dic 23
13886
how to remove first empty element from fields.selection Resuelto
python xml
Avatar
Avatar
Avatar
3
jul 22
24298
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y totalmente integrado.

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