Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Nekilnojamasis turtas
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Konsultavimas
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Maistas
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Saulės energijos sistemos
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Kiti
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

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

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

How to create/insert multiple row in single action?

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
createoverrideodooV8
2 Replies
18198 Rodiniai
Portretas
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
Portretas
Atmesti
Portretas
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
Portretas
Atmesti
Portretas
YOPI ANGI
Autorius 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
Portretas
Atmesti
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
Autorius

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!

Registracija
Related Posts Replies Rodiniai Veikla
[Odoo 8] override function
override odooV8
Portretas
Portretas
1
liep. 15
4108
[odoo 8]: How set value of one2many field by overriding create method with api coding standard? Solved
one2many create api override odooV8
Portretas
Portretas
2
gruod. 20
9201
Override create method with sudo() Solved
create override sudo()
Portretas
Portretas
1
bal. 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
Portretas
Portretas
Portretas
2
gruod. 23
24628
[Solved] Error when clicking on create - Odoo 8 Solved
error create odooV8
Portretas
Portretas
Portretas
2
saus. 16
4723
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة 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 yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

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