def download(self): Путь к вашему файлу на сервере filepath = r'files/finishedreport…
- User
def download(self): # Путь к вашему файлу на сервере file_path = r'files/finished_report (7).xlsx'
codewith open(file_path, 'rb') as file: file_content = file.read() return { 'type': 'ir.actions.act_url', 'url': 'data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,' + base64.b64encode(file_content).decode(), 'target': 'self', 'download': True, 'filename': 'downloaded_file.xlsx', }Это функция для кнопки в odoo
после нажатия выдает ошибку Not Found The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
если в коде поменять 'url': 'data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,' + base64.b64encode(file_content).decode(), на 'url': 'data:text/plain;base64,' + base64.b64encode(file_content).decode(), то выдает ошибку Сайт localhost не отправил данные.
- Assistant
- User
def send(self): file_data = base64.b64decode(self.file_f) # Декодируем переданный файл xlsx_data = io.BytesIO(file_data) # Конвертируем в поток
codeself.format_file(xlsx_data, xlsx_data) self.send_time = datetime.now() self.create_stats('report') xlsx_content = xlsx_data.getvalue() _logger.info('success') return { 'type': 'ir.actions.act_url', 'url': 'data:text/plain;base64,' + base64.b64encode(xlsx_content).decode(), 'target': 'self', 'download': True, 'filename': 'downloaded_file.xlsx', }Это функция для кнопки в odoo
после нажатия выдает ошибку Not Found The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
если в коде поменять 'url': 'data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,' + base64.b64encode(file_content).decode(), на 'url': 'data:text/plain;base64,' + base64.b64encode(file_content).decode(), то выдает ошибку Сайт localhost не отправил данные.
- Assistant
- User
в какую директорию добавлять файл с классом контроллера odoo
- Assistant
- User
функция format_file() это функция обрабатывающая полученный файл, перемести ее в модель из контроллера
- Assistant
- User
этот код выдает такую ошибку Internal Server Error The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
- Assistant