コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
5943 ビュー

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})

アバター
破棄
最善の回答

You have to reference your model without the module part

self.registry['gstreturn']

request.env['gstreturn']
アバター
破棄
著作者 最善の回答

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

アバター
破棄
関連投稿 返信 ビュー 活動
3
12月 19
8138
2
12月 23
44167
1
9月 21
4549
1
7月 21
5194
1
3月 20
6314