Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
5933 มุมมอง

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.. ;)

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
3
ธ.ค. 19
8123
2
ธ.ค. 23
44167
1
ก.ย. 21
4546
1
ก.ค. 21
5178
1
มี.ค. 20
6306