Help

4

error: (31, 'ShellExecute', 'A device attached to the system is not functioning.) When using win32api

Avatar
Hilar AK

I tried to print some data on Odoo 8, using the package win32api I am getting the traceback below:


2017-09-05 05:40:58,779 2896 INFO 8_kitchen openerp.addons.point_of_sale.print_network: c:\windows\temp\tmpdq1h78.txt
2017-09-05 05:40:58,779 2896 ERROR 8_kitchen openerp.http: Exception during JSON request handling.
Traceback (most recent call last):
  File "C:\Program Files (x86)\Odoo 8.0-20170309\server\.\openerp\http.py", line 544, in _handle_exception
  File "C:\Program Files (x86)\Odoo 8.0-20170309\server\.\openerp\http.py", line 581, in dispatch
  File "C:\Program Files (x86)\Odoo 8.0-20170309\server\.\openerp\http.py", line 317, in _call_function
  File "C:\Program Files (x86)\Odoo 8.0-20170309\server\.\openerp\service\model.py", line 118, in wrapper
  File "C:\Program Files (x86)\Odoo 8.0-20170309\server\.\openerp\http.py", line 314, in checked_call
  File "C:\Program Files (x86)\Odoo 8.0-20170309\server\.\openerp\http.py", line 810, in __call__
  File "C:\Program Files (x86)\Odoo 8.0-20170309\server\.\openerp\http.py", line 410, in response_wrap
  File "C:\Program Files (x86)\Odoo 8.0-20170309\server\openerp\addons\web\controllers\main.py", line 944, in call_kw
  File "C:\Program Files (x86)\Odoo 8.0-20170309\server\openerp\addons\web\controllers\main.py", line 936, in _call_kw
  File "C:\Program Files (x86)\Odoo 8.0-20170309\server\.\openerp\api.py", line 268, in wrapper
  File "C:\Program Files (x86)\Odoo 8.0-20170309\server\openerp\addons\point_of_sale\print_network.py", line 37, in print_network_printer
error: (31, 'ShellExecute', 'A device attached to the system is not functioning.')

My code is :

import tempfile
import win32api
# import win32print
# win32print.OpenPrinter('\\\\CYBROSYS\\EPSON L360 Series (Copy 3)')
filename = tempfile.mktemp(".txt")
open(filename, "w").write("This is a test")
win32api.ShellExecute(
    0,
    "print",
    filename,
    #
    # If this is None, the default printer will
    # be used anyway.
    #
    None,
    ".",
    0
)

This is actually fine working while using the code on console. this is the same case of win32print and win32api. Any other restrictions are set by odoo for accessing network printers?

Or any other solutions to access and print data with printer?



Avatar
Discard