Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • Apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

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

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

How does the ORM Read() method work exactly?

Tilmeld

Få besked, når der er aktivitet på dette indlæg

Dette spørgsmål er blevet anmeldt
externalintegrationorm
2 Besvarelser
42348 Visninger
Avatar
Moin

I assumed that the read method returns a list of dictionaries (records) which are then directly displayed by the list view or form view but that does not seem to be the case. I have this very simple python object defined as follows:

class time_periods(osv.osv):

def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'):
    res = super(time_periods, self).read(cr, uid, ids, fields=fields, context=context, load='_classic_read')
            #res is empty at this point since the underlying table is empty
            #I want to display completely new data (same fields though) in the list view
    res = [{'name': 'Test', 'id':1}, {'name': 'Test 2', 'id':2}]

    print res
    return res

_name = 'time.periods'

_columns = {
    'name': fields.char('Name', size=50),
        }

time_periods()

currently the corresponding table in the OpenERP database is empty but I assumed that the hardcoded list(res) would act as records retrieved from the database however the list view still renders enpty.

As an experiment, I created a record with id = 2, name = "Test" in the database and the tree view showed one record but with name = "Test 2" as defined in the list(res).

The idea is to replace the list(res) with data retrived from an external database through xmlrpc call.

So, how does the read method work exactly?

Thank You.

EDIT

Just to make my problem clearer, the time_periods table in the OpenERP database is empty so the super call to the read method returns an empty list. What I want to do is display data (from another database but with same fields as the python object) in OpenERP even when the local database is empty. So, essentially I want to intercept the data source of the list view and attach my own data in it not simply make changes to existing data since there is no data.

0
Avatar
Kassér
Yug Faa

Try to format your code, I think that you're replaced the content of res, use two variables res1 and res2 and display them with print :)

Yug Faa

use res.get(NAME_OF_FIELD) to get values from res

Moin
Forfatter

It doesn't matter that I override the content of res since res is an empty list by default (the table is empty) I want to display new records entirely at run time despite there being no data in the OpenERP database.

Sehrish

Hope this will helps: https://learnopenerp.blogspot.com/2021/09/restrict-user-to-access-differnt-records-by-changing-id-in-url-odoo.html

Avatar
Yohanes Iwan Sugiarto
Bedste svar

Hi Moin!

Here is a simple example to demonstrate the read method. Just for demonstration sake, this code will add triple asterisks '***' in front of the name field of product_category field.

You can replace line 8 with another code to replace the value from another database.

def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'):
    if context is None:
        context = {}
    res = super(product_category, self).read(cr, uid, ids, fields=fields, context=context, load=load)
    idx = 0
    for r in res:
        if r.has_key('name'):
            r['name'] = '***' + r['name']
            #replace line above with replacement value from external database
        res[idx] = r
        idx = idx + 1
    return res
1
Avatar
Kassér
Moin
Forfatter

Thanks for your answer Yohanes, although I think I may have not described my problem correctly. See the EDIT for clarification please. Thank you again for your time.

priyankahdp

thanks Iwan.. any idea about this issue ? http://help.openerp.com/question/8391/how-to-load-child-records-to-fields/

Avatar
Noel Jesús Rivero
Bedste svar

Hello , I'm having the same problem. I can't find a way to do this. Do you have a solution?
 

0
Avatar
Kassér
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Tilmeld dig
Related Posts Besvarelser Visninger Aktivitet
Integration from Rails
external integration
Avatar
Avatar
1
jul. 17
6136
Integrate external VoIP server.
external integration voip
Avatar
0
feb. 24
2450
Connecting two Odoo instances Løst
security external integration internal
Avatar
Avatar
Avatar
Avatar
3
okt. 24
9375
Is it possible to integrate Webflow into Odoo? If yes, is there any documentation on this?
integration
Avatar
Avatar
1
nov. 25
7060
is the odoo API integration available for odoo cloud edition? Løst
integration
Avatar
Avatar
Avatar
Avatar
3
aug. 25
5320
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة 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 er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

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