Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

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

Odoberať

Get notified when there's activity on this post

This question has been flagged
one2manyodoostudioodoo16featuresodoo-online
1 Odpoveď
4482 Zobrazenia
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
Zrušiť
Avatar
Paige Youderian
Autor Best Answer

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
Zrušiť
Enjoying the discussion? Don't just read, join in!

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
one2many fields, advise/guidance needed... Solved
one2many odoo16features
Avatar
Avatar
1
sep 23
2604
Filter One2many field in res.partner Solved
filter one2many odoo16features
Avatar
Avatar
1
jan 24
2605
Attendance device for Odoo Online
attendance odoo16features odoo-online
Avatar
Avatar
Avatar
Avatar
3
nov 23
4226
Many2one not filled until One2many is saved Odoo 16
many2one one2many odoo16features
Avatar
Avatar
1
dec 22
3353
odoo 16 One2many insert value doesnt work Solved
one2many value add odoo16features
Avatar
Avatar
2
nov 23
3612
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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