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("Expected singleton: %s" % self)

Abonare

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

Această întrebare a fost marcată
errorsingletonodoov11
6 Răspunsuri
9934 Vizualizări
Imagine profil
Chaanto

THIS CODE RUN

def name_get(self):

            def _name_get(d):

                name = d.get('name', '')

                identity_no = d.get('identity_no', '')

                reg = '%s ( %s )' % (name, identity_no)

                return (d['id'], reg)

            result = list(map(_name_get, self.read(['name', 'identity_no'])))

            return result


BUT I WANT GIVE A CONDITION LIKE THIS

@api.multi

    def name_get(self):

        if self.identity_no != False :

            def _name_get(d):

                name = d.get('name', '')

                identity_no = d.get('identity_no', '')

                reg = '%s ( %s )' % (name, identity_no)

                return (d['id'], reg)

            result = list(map(_name_get, self.read(['name', 'identity_no'])))

        else :

            def _name_get(d):

                name = d.get('name', '')

                return (d['id'], name)

            result = list(map(_name_get, self.read(['name'])))

        return result

ERROR :
File "/home/ubuntu/mycompany/addons/v11_company_custom/base/partner.py", line 44, in name_get
    if self.identity_no != False :
  File "/home/ubuntu/mycompany/gigerhe/fields.py", line 935, in __get__
    record.ensure_one()
  File "/home/ubuntu/mycompany/gigerhe/models.py", line 4365, in ensure_one
    raise ValueError("Expected singleton: %s" % self)
ValueError: Expected singleton: res.partner(857, 825, 77, 83, 69, 42, 840, 806)
0
Imagine profil
Abandonează
Sehrish

Odoo Tips and Development Guide: https://plus.google.com/collection/4UX8UE

Imagine profil
Manish Bohra
Cel mai bun răspuns

Hello,

You can modify your code

@api.multi

    def name_get(self):

    for res in self:

        if res.identity_no != False :

            def _name_get(d):

                name = d.get('name', '')

                identity_no = d.get('identity_no', '')

                reg = '%s ( %s )' % (name, identity_no)

                return (d['id'], reg)

            result = list(map(_name_get, res.read(['name', 'identity_no'])))

        else :

            def _name_get(d):

                name = d.get('name', '')

                return (d['id'], name)

            result = list(map(_name_get, res.read(['name'])))

        return result

Thanks

1
Imagine profil
Abandonează
Chaanto
Autor

Hello, Thanks for answering. but it didnt solve my problem. cause when i use that loop another problem come out. so i searching for another alternative.

Manish Bohra

Just Break your method ..

like

def functionA(A)

def functionB(B):

if your condition:

self.functionA()

else:

self.functionA()

Chaanto
Autor

there is an error TypeError: 'NoneType' object is not iterable

Chaanto
Autor

well i will try it

Imagine profil
subbarao
Cel mai bun răspuns

Try this one 

@api.multi

def name_get(self):

    res = []

    for order in self:

        if order.identity_no != False :

            name = '%s ( %s )' % (order.name, order.identity_no)

            res.append((order.id, name))

        else :

            name= order.name

            res.append((order.id, name))

    return res

0
Imagine profil
Abandonează
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
Expected singleton error from csv file
error csv singleton
Imagine profil
0
apr. 22
3076
ValueError: Expected singleton: Models_name(38, 39) Rezolvat
error odoo singleton
Imagine profil
Imagine profil
Imagine profil
3
mar. 19
7516
How setup multi workers using command line in odoo 11? Rezolvat
error workers odoov11
Imagine profil
Imagine profil
1
mar. 18
7128
Throwing error when creating new ticket in help desk Rezolvat
error mailserver odoov11
Imagine profil
4
feb. 18
5898
ValueError: Expected singleton Rezolvat
error treeview singleton Odoo13.0
Imagine profil
Imagine profil
1
dec. 21
4873
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