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

How to create/insert multiple row in single action?

Odoberať

Get notified when there's activity on this post

This question has been flagged
createoverrideodooV8
2 Replies
18195 Zobrazenia
Avatar
YOPI ANGI

I have some case where single data from form submitted have posibitilies become multiple row (data/dicts) after manipulation. I am trying to override create method and put it in loop, but after test in website, i got warning message like this.

@api.returns('self', lambda value: value.id)

AttributeError: 'list' object has no attribute 'id'

here my code :

class Test(models.Model):

...

@api.model

def create(self, values):

test_id = self._manipulate_data(values)

res_id = []

if len(test_id) > 0:

for value_id in test_id:

res_id.append(super(Test, self).create(value_id))

return res_id

return super(Test, self).create(values)

res_id containing values like this : [test(160,), test(161,), test(162,)]

1
Avatar
Zrušiť
Avatar
Bole
Best Answer

here is what happend in pseudo code (human readable translated) :

- original create method recived values, 
- then you 'manipulate' those valuse and put it in test_id ( by naming convention it should be _ids.. butok) 
- after that you check if you have elements in test_id list and for each value in list you try to call create...
that is no good... 
 

if create recived values (in whatever form : list, dict tuple.. ) 
you super class call should be passed the same form of vals... 

in your case : recived values ( one variable, ) returning correct super call only if test_id has no values.. 
but if it has some vals.. it trys to return a list of super calls... 

think again and modify your _manipulate_data method to do whatever, but one the data is ready for next step.. it should be in same form (modified or not) as the entered.. 


one more thing , and this might be the most important part... 
create method can be run on ONE record only, and it MUST return ONE ID of newly created recor, or False if record was not created...
 

hope it helps :)

0
Avatar
Zrušiť
Avatar
YOPI ANGI
Autor Best Answer

Bole, thanks a lot for advice. :)

I desperate after doing lot of experiments for this case. Before pushing the creation in create method, i implemented it in function workflow but it seems not work too (in function workflow, i put self.create(data_manipulate) inside loop. After debug, i found that the original data submitted from form is process first followed my manipulated data).

i make some modification, like this:

@api.model

def create(self, values):

test_id = self._manipulate_data(values)

if len(test_id) > 0:

for value_id in test_id:

res_id = super(Test, self).create(value_id)

return res_id

return super(Test, self).create(values)

this code is work, but i dont know, it's a good code or bad code.

1
Avatar
Zrušiť
Bole

well .. you should try writing a method wich is not create, but some other.. in wich you will loop / iterate over some data, modify/prepare data.. and from that method ( from loop or outside loop) call create method.. (just pass ready vals to create... that would be preffered way to achieve what yu need...

YOPI ANGI
Autor

thanks bole, i will try it :)

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
[Odoo 8] override function
override odooV8
Avatar
Avatar
1
júl 15
4108
[odoo 8]: How set value of one2many field by overriding create method with api coding standard? Solved
one2many create api override odooV8
Avatar
Avatar
2
dec 20
9201
Override create method with sudo() Solved
create override sudo()
Avatar
Avatar
1
apr 24
579
How to override a default module using a custom module (e.g. override the 'web' module in order to modify the login screen & rem Solved
templates override odooV8
Avatar
Avatar
Avatar
2
dec 23
24622
[Solved] Error when clicking on create - Odoo 8 Solved
error create odooV8
Avatar
Avatar
Avatar
2
jan 16
4723
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