Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

Expected singleton on One2many model with related fields

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
one2manyrelatedodoo10
6 Risposte
6392 Visualizzazioni
Avatar
Samo Arko

I looked at different forum posts but I don't see a fix. I have 2 custom models that are in a relation One2many. One the many side I have a few related fields just for displaying the data in the view. Now if I change a value on the One side model that is related to the many side model I get the Expected singleton: my_custom_model_many(id1, id2, id3).

How can I fix this? I tough to make create and  write methods @api.multi and then iterate with "for rec in self:" but they have return statements so the methods would finish in the first iteration. 

If anyone has any suggestions with maybe a code example, that would be very appreciated!  


class my_custom_module_one(models.Model):
	_name = 'my.custom.one'
	month = fields.Char()
	date_from = fields.Date()
	date_to = fields.Date()

	many_ids = fields.One2many('my.custom.many', 'one_id')

class my_custom_module_many(models.Model):
	_name = 'my.custom.many'
	one_month = fields.Char(related='one_id.month')
	one_date_form = fields.Date(related='one_id.date_from')
	one_date_to = fields.Date(related='one_id.date_to')

	one_id = fields.Many2one('my.custom.one')
0
Avatar
Abbandona
Niyas Raphy (Walnut Software Solutions)

Can you update the question with your code and with the error message

Samo Arko
Autore

Can't update the question... get only 403 forbidden page.

Niyas Raphy (Walnut Software Solutions)

I have updated the question with what you have put as answer, by with this code there will not be any issues, I think you may have written some other functions in it

Avatar
ayman mohammed adam
Risposta migliore

Dear Samo Arko

I think you must use @api.multi instead of @api.one  on specific function and make for loop in your function:

@api.multi

def your_function_name(self):

      for rec in self:

                     ......................



I Hope I helped you..

0
Avatar
Abbandona
Samo Arko
Autore

ok... I've removed the api.one method decorators. I've used them only a few for returning values of calculations. Didn't know that they are deprecated or I wouldn't even use them. But I'm still getting the error. A line before the "Except singleton" is "odoo models.py", line 4820, in ensure_one"

Samo Arko
Autore

Thanks for getting me on the right path! can't up vote your answer else I would!

ayman mohammed adam

Thanks..

Avatar
Samo Arko
Autore Risposta migliore

Thank all you guys for the help. Aymans answer got me on the right path. I all ready changed the @api.one to @api.multi decorators. After I changed all and still got the error I looked on those that I changed before. And there was the problem. In one of the methods I forgot to change self to rec when I added the for rec in self. 

0
Avatar
Abbandona
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
get Job_ids from hr_contracts one2many field Risolto
one2many related
Avatar
Avatar
1
mag 24
3323
One2many field odoo version 10
one2many odoo10
Avatar
Avatar
1
set 22
2847
"RuntimeError: maximum recursion depth exceeded in cmp" problem
one2many odoo10
Avatar
Avatar
Avatar
Avatar
4
mag 18
12073
Values has false in one2many field when changing the customer in Sale Order ODOO 10
one2many sale.order.line odoo10
Avatar
0
mar 23
6005
Prevent create and delete on a One2many tree view Risolto
treeview one2many odoo10
Avatar
1
lug 20
9405
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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