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
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Managament
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • 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
    Others
    • 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
  • Help

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

ValueError: <class 'ValueError'>: "Expected singleton: sale.order.line(<NewId ref='virtual_117'>, <NewId ref='virtual_131'>)"

Odoberať

Get notified when there's activity on this post

This question has been flagged
sale.order.linesale.order
1 Odpoveď
4177 Zobrazenia
Avatar
Renato Paolo Espinoza Terrones

Odoo v15

I create a "Margin 2 [x_studio_margen_2]" field at "sale.order" that is supposed to be the sum of every field "Total Margin 2 [x_studio_total_margen_2" at "sale.order.line".

When I add one product, everything is ok, but the problem comes when I add a second product.

I though that it would work but it release an "Expected singleton" error

total = 0
for record in self:
    total += record.order_line.x_studio_total_margen_2
    record['x_studio_margen_2'] = tot

I've read another post with same error but not the same case and I haven't fix it.

1
Avatar
Zrušiť
Avatar
Sudhir Arya (ERP Harbor Consulting Services)
Best Answer

When you access the "order_line" One2many field, it gives you the number of recordsets (in your case 2 recordsets because you have added 2nd product also).

So you need to use a loop on "order_line" to access every line.

Try the following code:

for record in self:
total = 0
for line in record.order_line:
total += line.x_studio_total_margen_2
record['x_studio_margen_2'] = total

I am sure this will work as you expect.

2
Avatar
Zrušiť
Renato Paolo Espinoza Terrones
Autor

Thanks a lot!!

That's true, it is now working but another problem happens.

"x_studio_margen_2" is not being updating as "margin" default field does.

For example:

A product with a cost by default 2€ but without a default price_unit that appears at the order line with a "x_studio_total_margen_2" = -2€, so "x_studio_margen_2" now is -2€.

So if I add the price_unit of it product as 3€ it's supposed to have a "x_studio_margen_2" of 1€ but the operation that it does is "-2€ + 1€= so the result is "x_studio_margen_2" = -1€.

Another example:

If I delete the product, "x_studio_margen_2" is still with the -2€, so if I add a product with 3€ of margin ("x_studio_total_margen_2)", now the "x_studio_margen_2" will be -2 + 3 = 1€.

I've tried to only use the formula of "x_studio_total_margen_2" while number is more than 0, but it doesn't work when I delete any product.

Thanks again!

Sudhir Arya (ERP Harbor Consulting Services)

I would suggest to accept this and create another post.

Renato Paolo Espinoza Terrones
Autor

I agree.

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
Merge Same Item in Sale Order Line Solved
sale.order.line sale.order
Avatar
Avatar
Avatar
2
jan 24
6250
Combine inline editing with more detailed form view
sale.order.line sale.order
Avatar
0
jún 23
2744
How to update a custom field as "Margin" default from sale.order does, when some product of sale.order.line is updated/deleted.
sale.order.line sale.order
Avatar
0
apr 22
3213
How to count stockable product in orderline in Quotations Solved
sale.order.line sale.order
Avatar
Avatar
1
apr 19
6815
Odoo 19 - how does rounding work on Sales Order Lines? The Total isn't the sum of the order line totals Solved
sale sale.order.line sale.order
Avatar
Avatar
1
nov 25
288
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