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
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • 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
    Iní
    • 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
  • Pomoc

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

Expected singleton on One2many model with related fields

Odoberať

Get notified when there's activity on this post

This question has been flagged
one2manyrelatedodoo10
6 Replies
6424 Zobrazenia
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
Zrušiť
Niyas Raphy (Walnut Software Solutions)

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

Samo Arko
Autor

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
Best Answer

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
Zrušiť
Samo Arko
Autor

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
Autor

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

ayman mohammed adam

Thanks..

Avatar
Samo Arko
Autor Best Answer

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
Zrušiť
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
get Job_ids from hr_contracts one2many field Solved
one2many related
Avatar
Avatar
1
máj 24
3331
One2many field odoo version 10
one2many odoo10
Avatar
Avatar
1
sep 22
2863
"RuntimeError: maximum recursion depth exceeded in cmp" problem
one2many odoo10
Avatar
Avatar
Avatar
Avatar
4
máj 18
12085
Values has false in one2many field when changing the customer in Sale Order ODOO 10
one2many sale.order.line odoo10
Avatar
0
mar 23
6016
Prevent create and delete on a One2many tree view Solved
treeview one2many odoo10
Avatar
1
júl 20
9414
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