Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

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

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
sale.order.linesale.order
1 Răspunde
4182 Vizualizări
Imagine profil
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
Imagine profil
Abandonează
Imagine profil
Sudhir Arya (ERP Harbor Consulting Services)
Cel mai bun răspuns

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
Imagine profil
Abandonează
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!

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
Merge Same Item in Sale Order Line Rezolvat
sale.order.line sale.order
Imagine profil
Imagine profil
Imagine profil
2
ian. 24
6254
Combine inline editing with more detailed form view
sale.order.line sale.order
Imagine profil
0
iun. 23
2747
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
Imagine profil
0
apr. 22
3215
How to count stockable product in orderline in Quotations Rezolvat
sale.order.line sale.order
Imagine profil
Imagine profil
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 Rezolvat
sale sale.order.line sale.order
Imagine profil
Imagine profil
1
nov. 25
300
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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