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
    • Conocimientos
    • 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
    Alimentación y hostelería
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • 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

Pull and Display a One2Many Field from a relation through a One2Many Field

Suscribirse

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

Se marcó esta pregunta
one2manyodoostudioodoo16featuresodoo-online
1 Responder
4477 Vistas
Avatar
Paige Youderian

For the purposes of this question say I have the following tables Orders, Order Items, Items, Item Components and Components.
Orders with

  • Items (one2many field connecting to Order-Items)

Order-Items has

  • Order (many2one)
  • Item (many2one)

Items

  • Components (one2many field connecting to Item-Components)

Item Components has

  • Item (many2one)
  • Component(many2one)


I need a way to generate a list of all the component involved in an order, aka I need to pull the Item-Component details for every Item on the Order. I don't even particularly care whether or not it is broken out by part, but I can only use xml, computed fields, or server actions because I'm using Odoo Studio w/ Odoo Online.


I have tried to find a way to do it through related fields.
I have tried to find a way to do it through on views.
I have tried to find a way to do it through report views, although that is less than ideal.

At this point unless someone knows a trick for one of the above methods, I'm looking for a way to setup a server action to create a new record for every line in a one to many table so I can setup a Order-Item-Component table with the item-component details added every time an item is added to an order, but i'm not sure how to accomplish that inside of a server action. There is a ton of documentation about how to write into a one2many field, but I wasn't finding much about iterating out of a one2many field.


Hopefully, this isn't like the other night when I was trying to test an error message and getting frustrated it was throwing an error message. (Lesson there, despite the majority of the documentation still saying to use raise Warning, if you want it to be user-friendly you need to use raise UserError. But that doesn't mean that Warning won't raise an error :D)

0
Avatar
Descartar
Avatar
Paige Youderian
Autor Mejor respuesta

I figured out the Order-Item-Component table code. I still feel like I'm doing more work than neccessary, but at least its a work around.

Server Action w/ Model as Order-Items and Action as Execute Python Code

Model

Field

Field Type

order
idinteger
orderx_order_itemsone2many (order_items via x_order_id)
itemidinteger
item
x_item_components
one2many (item_components via x_item_id)
order_items
idinteger
order_items
x_order_id
many2one (order)
order_itemsx_item_idmany2one (item)
item_componentsidinteger
item_components
x_item_idmany2one (item)
item_components
x_component_idmany2one (component)
order_item_compomentsx_item_idmany2one (item)
order_item_compoments
x_item_component_idmany2one (item_components)
order_item_compoments
x_order_idmany2one (order)
order_item_compoments
x_order_item_idmany2one (order_items)


order_var = record.x_order_id.id
item_var = record.x_item_id.id
order_item_var = record.id
addList = record.x_item_id.x_item_components.mapped('id') #pulls a list ids for all lines of the one2many x_item_components field

for component in addList:
  vals=dict(x_item_id = item_var, x_item_component_id = component, x_order_id = order_var, x_order_item_id = order_item_var)
  env['order_item_compoments'].create(vals)


0
Avatar
Descartar
¿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
one2many fields, advise/guidance needed... Resuelto
one2many odoo16features
Avatar
Avatar
1
sept 23
2597
Filter One2many field in res.partner Resuelto
filter one2many odoo16features
Avatar
Avatar
1
ene 24
2600
Attendance device for Odoo Online
attendance odoo16features odoo-online
Avatar
Avatar
Avatar
Avatar
3
nov 23
4220
Many2one not filled until One2many is saved Odoo 16
many2one one2many odoo16features
Avatar
Avatar
1
dic 22
3349
odoo 16 One2many insert value doesnt work Resuelto
one2many value add odoo16features
Avatar
Avatar
2
nov 23
3606
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