Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Managament
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Producție
    • Textile
    • Metal
    • Furnitures
    • Food
    • 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
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

Need help in new controller for new model and module. Always KeyError in return from controller to model

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
modelsdownloadcontrollers
2 Răspunsuri
6708 Vizualizări
Imagine profil
abhitechsavy@gmail.com

I have small model as below:

I am always getting error as here console.. Web shows internal server error. :

-------------

return http.request.env['newgst.gstreturn']._gstr_response({'rec_id': rec_id})
  File "/opt/odoo/odoo-10.0/odoo/api.py", line 752, in __getitem__
    return self.registry[model_name]._browse((), self)
  File "/opt/odoo/odoo-10.0/odoo/modules/registry.py", line 174, in __getitem__
    return self.models[model_name]
KeyError: 'newgst.gstreturn'


-----------------

newgst : is my custom module
gstreturn : is my model

I wrote this referring to this answer:

https://stackoverflow.com/questions/42022416/generate-an-odoo-downloadable-csv-report

But unfortunately not able to make it working.. :(

Please please help.............Its total blocker for me.


class NewgstGstreturn(models.Model):
_name = 'gstreturn'

# _inherit = "account.invoice"

@api.model
def _gstr_response(self, vals):

rec_id = vals.get('rec_id')
_logger.warning('abhishek in _gstr_response')
_logger.warning('abhishek - num (%d)', rec_id )


def get_gstr_file(self):
return {
'type' : 'ir.actions.act_url',
'url': '/web/Gstrdownload/csvdownload',
'target': 'blank',

My controller as below:

# -*- coding: utf-8 -*- 
from openerp import http
from openerp.http import request
from openerp.addons.web.controllers.main import serialize_exception,content_disposition

import base64


class Gstrdownload(http.Controller):

@http.route('/web/Gstrdownload/csvdownload/<int:rec_id>/', type='http',auth='user', website=True)
def csvdownload(self, rec_id, **kw):
return http.request.env['newgst.gstreturn']._gstr_response({'rec_id': rec_id})

1
Imagine profil
Abandonează
Imagine profil
Hugo Francisco Adan Oliva
Cel mai bun răspuns

You have to reference your model without the module part

self.registry['gstreturn']

request.env['gstreturn']
1
Imagine profil
Abandonează
Imagine profil
abhitechsavy@gmail.com
Autor Cel mai bun răspuns

Many Thanks Hugo .
That solved my problem.. ;)

0
Imagine profil
Abandonează
Enjoying the discussion? Don't just read, join in!

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

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
how we render model form in controller in odoo v9
models controllers odooV9
Imagine profil
Imagine profil
Imagine profil
3
dec. 19
8935
ImportError: cannot import name controllers, why? Rezolvat
v8 import models controllers
Imagine profil
Imagine profil
Imagine profil
2
dec. 23
45439
[Odoo 14] - Model is not updating via Controller
widget models controllers v14
Imagine profil
Imagine profil
1
sept. 21
5372
Open an url using python, without using return
models actions url controllers
Imagine profil
Imagine profil
1
iul. 21
5960
Website document download problem for public user
xml download controllers ir_attachment
Imagine profil
Imagine profil
1
mar. 20
6974
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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