This question has been flagged

helo everyone,

while trying to generate an .xlsx report using report_xlsx  module I got this error Access denied 

 but, when working with the same module in other machine everything work perfectly.


File "/opt/odoo/odoo/addons/base/res/res_users.py", line 506, in check
raise AccessDenied()
AccessDenied: Access denied

sql_export.py

@api.multi
def execute_query(self):
    datas['form'] = self.read()[0]
    name = 'Export OR'+ ' ' + date
    return {'type': 'ir.actions.report.xml',
            'report_name': 'my_module.my_report_name.xlsx',
            'datas': datas,
            'name': name
            }    

report_export.py

from odoo.addons.report_xlsx.report.report_xlsx import ReportXlsx
class InvoiceReportXls(ReportXlsx):
    def execute_query(self,datas):
        query = '''
            SELECT ... from ... 
            '''
        self.env.cr.execute(query,(...,...,),)
        lines = []
        lines = self.env.cr.dictfetchall()
        return lines
     def generate_xlsx_report(self, workbook, data, lines):
         sheet = workbook.add_worksheet('field_')
         #my_xlsx_code ...
InvoiceReportXls('report.my_module.my_report_name.xlsx','account.invoice') 


view.xml

    <report
        id="export_invoice_xlsx"
        model="account.invoice"
        string=" "
        report_type="xlsx"
        name="my_module.my_report_name.xlsx"
        file="my_module.my_report_name.xlsx"
        attachment_use="False"
    /> 

When i forced passwd in check method in /opt/odoo/odoo/addons/base/res_users.py  everything worked perfectly

    @classmethod
def check(cls, db, uid, passwd):
"""Verifies that the given (uid, password) is authorized for the database ``db`` and raise an exception if it is not."""
p
asswd = 'admin' # I added this line
if not passwd:
# empty passwords disallowed for obvious security reasons
raise AccessDenied()
db = cls.pool.db_name

....
....
....


Avatar
Discard