Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Gastenverblijf
    • Drankenhandelaar
    • Hotel
    Vastgoed
    • Makelaarskantoor
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accountantskantoor
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textiel
    • Metaal
    • Meubels
    • Eten
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Zonne-energiesystemen
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC-diensten
    Andere
    • Non-profitorganisatie
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

a model based on a hand written sql query

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
modelssqlmodel
1 Beantwoorden
3171 Weergaven
Avatar
Adriano Peluso

I have a model based on a hand written sql query


I'm having this error


Errore:
Odoo Server Error

Traceback (most recent call last):
  File "/home/plus/odoo/odoo/addons/base/models/ir_http\.py",\ line\ 237,\ in\ _dispatch
 \  \ result\ =\ request\.dispatch\(\)
 \ File\ "/home/plus/odoo/odoo/http\.py",\ line\ 685,\ in\ dispatch
 \  \ result\ =\ self\._call_function\(\*\*self\.params\)
 \ File\ "/home/plus/odoo/odoo/http\.py",\ line\ 361,\ in\ _call_function
 \  \ return\ checked_call\(self\.db,\ \*args,\ \*\*kwargs\)
 \ File\ "/home/plus/odoo/odoo/service/model\.py",\ line\ 94,\ in\ wrapper
 \  \ return\ f\(dbname,\ \*args,\ \*\*kwargs\)
 \ File\ "/home/plus/odoo/odoo/http\.py",\ line\ 349,\ in\ checked_call
 \  \ result\ =\ self\.endpoint\(\*a,\ \*\*kw\)
 \ File\ "/home/plus/odoo/odoo/http\.py",\ line\ 908,\ in\ __call__
 \  \ return\ self\.method\(\*args,\ \*\*kw\)
 \ File\ "/home/plus/odoo/odoo/http\.py",\ line\ 533,\ in\ response_wrap
 \  \ response\ =\ f\(\*args,\ \*\*kw\)
 \ File\ "/home/plus/odoo/addons/web/controllers/main\.py",\ line\ 1372,\ in\ call_kw
 \  \ return\ self\._call_kw\(model,\ method,\ args,\ kwargs\)
 \ File\ "/home/plus/odoo/addons/web/controllers/main\.py",\ line\ 1364,\ in\ _call_kw
 \  \ return\ call_kw\(request\.env\[model\],\ method,\ args,\ kwargs\)
 \ File\ "/home/plus/odoo/odoo/api\.py",\ line\ 395,\ in\ call_kw
 \  \ result\ =\ _call_kw_model\(method,\ model,\ args,\ kwargs\)
 \ File\ "/home/plus/odoo/odoo/api\.py",\ line\ 368,\ in\ _call_kw_model
 \  \ result\ =\ method\(recs,\ \*args,\ \*\*kwargs\)
 \ File\ "/home/plus/odoo/addons/web/models/models\.py",\ line\ 99,\ in\ web_read_group
 \  \ groups\ =\ self\._web_read_group\(domain,\ fields,\ groupby,\ limit,\ offset,\ orderby,\ lazy,\ expand,
 \ File\ "/home/plus/odoo/addons/web/models/models\.py",\ line\ 130,\ in\ _web_read_group
 \  \ groups\ =\ self\.read_group\(domain,\ fields,\ groupby,\ offset=offset,\ limit=limit,
 \ File\ "/home/plus/odoo/odoo/models\.py",\ line\ 2254,\ in\ read_group
 \  \ result\ =\ self\._read_group_raw\(domain,\ fields,\ groupby,\ offset=offset,\ limit=limit,\ orderby=orderby,\ lazy=lazy\)
 \ File\ "/home/plus/odoo/odoo/models\.py",\ line\ 2381,\ in\ _read_group_raw
 \  \ self\._cr\.execute\(query,\ where_clause_params\)
 \ File\ "",\ line\ 2,\ in\ execute
 \ File\ "/home/plus/odoo/odoo/sql_db\.py",\ line\ 101,\ in\ check
 \  \ return\ f\(self,\ \*args,\ \*\*kwargs\)
 \ File\ "/home/plus/odoo/odoo/sql_db\.py",\ line\ 301,\ in\ execute
 \  \ res\ =\ self\._obj\.execute\(query,\ params\)
Exception

The\ above\ exception\ was\ the\ direct\ cause\ of\ the\ following\ exception:

Traceback\ \(most\ recent\ call\ last\):
 \ File\ "/home/plus/odoo/odoo/http\.py",\ line\ 641,\ in\ _handle_exception
 \  \ return\ super\(JsonRequest,\ self\)\._handle_exception\(exception\)
 \ File\ "/home/plus/odoo/odoo/http\.py",\ line\ 317,\ in\ _handle_exception
 \  \ raise\ exception\.with_traceback\(None\)\ from\ new_cause
psycopg2\.errors\.UndefinedColumn:\ ERRORE:\  la\ colonna\ sc_personale_partecipazioni_agli_studi_generale\.id\ non\ esiste
LINE\ 2:\  \  \  \  \  \  \ SELECT\ min\("sc_personale_partecipazioni_agli_stu\.\.\.
 \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \^\ \ \ \ \ \ \




It's\ claiming\ that\ the\ table\ "sc_personale_partecipazioni_agli_studi_generale"\ has\ _no_\ "id"\ column


Here's\ my\ model\ definition


from\ odoo\ import\ fields,\ models,\ tools

class\ PersonalePartecipazioniAgliStudigenerale\(models\.Model\):
\ \ \ \ _name\ =\ 'sc_personale_partecipazioni_agli_studi_generale'
\ \ \ \ _auto\ =\ False
\ \ \ \ _description\ =\ 'Una\ vista\ unica\ su\ tutte\ le\ partecipazioni\ agli\ studi\ di\ tutto\ il\ personale'

\ \ \ \
\ \ \ \ id_professionista\ =\ fields\.Many2one\('sc\.personale',\ String="ID\ professionista",\ readonly=True\)

\ \ \ \ nome\ =\ fields\.Char\(String="Nome",\ readonly=True\)
\ \ \ \ cognome\ =\ fields\.Char\(String="Nome",\ readonly=True\)
\ \ \ \ profilo_professionale\ =\ fields\.Char\(String="Profilo\ Professionale",\ readonly=True\)
\ \ \ \ studio\ =\ fields\.Char\(String="Studio",\ readonly=True\)\
\ \ \ \ id_studio\ =\ fields\.Many2one\('res\.studio',\ String="ID\ studio",\ readonly=True\)

\ \ \ \ def\ init\(self\):
\ \ \ \ \ \ \ \ tools\.drop_view_if_exists\(self\.env\.cr,\ self\._table\)
\ \ \ \ \ \ \ \ query\ =\ """

\ \ \ \ \ \ \ \ CREATE\ OR\ REPLACE\ VIEW\ sc_personale_partecipazioni_agli_studi_generale\ AS\ \(
\ \ \ \ \ \ \ \ WITH\ partecipazioni\ AS\ \(



select\ \
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ studio\.id\ AS\ id_studio,\
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ studio\.name\ as\ nome_studio,
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ partecipazioni_tecnici\.id\ AS\ id_partecipazione_tecnico,
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ partecipazioni_infermieri\.id\ AS\ id_partecipazione_infermiere,
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ partecipazioni_medici\.id\ AS\ id_partecipazione_medico,
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ partecipazioni_tecnici\.tecnico_id\ AS\ id_tecnico,
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ partecipazioni_infermieri\.infermiere_id\ AS\ id_infermiere,
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ partecipazioni_medici\.medico_id\ AS\ id_medico
\
\ FROM\ res_studio\ AS\ studio
\
\ LEFT\ OUTER\ JOIN\ sc_personale_partecipazione_tecnici_allo_studio\ AS\ partecipazioni_tecnici\ ON\ studio\.id\ =\ partecipazioni_tecnici\.studio_id
\ LEFT\ OUTER\ JOIN\ sc_personale_partecipazione_infermieri_allo_studio\ AS\ partecipazioni_infermieri\ ON\ studio\.id\ =\ partecipazioni_infermieri\.studio_id
\ LEFT\ OUTER\ JOIN\ sc_personale_partecipazione_medici_allo_studio\ AS\ partecipazioni_medici\ ON\ studio\.id\ =\ partecipazioni_medici\.studio_id
\)

SELECT\ sc_personale\.id\ AS\ id_professionista,\ sc_personale\.name\ as\ nome,\ sc_personale\.cognome,\ sc_personale\.profilo_professionale,\ nome_studio\ as\ studio,\ id_studio
FROM\ sc_personale,\ partecipazioni
WHERE\ sc_personale\.id\ =\ partecipazioni\.id_tecnico\ OR\ sc_personale\.id\ =\ partecipazioni\.id_infermiere\ OR\ sc_personale\.id\ =\ partecipazioni\.id_medico
GROUP\ BY\ sc_personale\.id,\ partecipazioni\.id_studio,\ partecipazioni\.nome_studio
ORDER\ BY\ \ sc_personale\.profilo_professionale\)
\ \ \ \ \ \ \ \ """
\ \ \ \ \ \ \ \ self.env.cr.execute(query)




0
Avatar
Annuleer
Jason Vu

Hi Adriano Peluso,

If 'id_professionista' is unique field, you can change this column name to 'id' 

or select new auto increment 'id' column like this: 

SELECT row_number() over () as id, ...

Thanks!

Avatar
Niyas Raphy (Walnut Software Solutions)
Beste antwoord

Hi,

You can update your query with this piece of code in the select statement.

row_number() OVER () as id

Thanks

0
Avatar
Annuleer
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
a model based on a sql query
models sql
Avatar
0
apr. 25
1303
Odoo 'build a module'...Model not seen in my module
models model tutorial
Avatar
Avatar
4
nov. 20
7827
Why can't i find some models in db? Opgelost
models model odoov12
Avatar
Avatar
1
mrt. 19
4088
How to add products to quotation template without product name?
models quotation model
Avatar
Avatar
1
mrt. 15
7953
Odoo new Model class? Opgelost
import models model
Avatar
Avatar
1
mrt. 15
14114
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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