Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Guest House
    • Drankenhandelaar
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Solar Energy Systems
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC Services
    Others
    • Nonprofit Organization
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

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

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
sale.order.linesale.order
1 Beantwoorden
4163 Weergaven
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
Annuleer
Avatar
Sudhir Arya (ERP Harbor Consulting Services)
Beste antwoord

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
Annuleer
Renato Paolo Espinoza Terrones
Auteur

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
Auteur

I agree.

Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
Merge Same Item in Sale Order Line Opgelost
sale.order.line sale.order
Avatar
Avatar
Avatar
2
jan. 24
6233
Combine inline editing with more detailed form view
sale.order.line sale.order
Avatar
0
jun. 23
2736
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
3206
How to count stockable product in orderline in Quotations Opgelost
sale.order.line sale.order
Avatar
Avatar
1
apr. 19
6811
Odoo 19 - how does rounding work on Sales Order Lines? The Total isn't the sum of the order line totals Opgelost
sale sale.order.line sale.order
Avatar
Avatar
1
nov. 25
265
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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