-
-
Notifications
You must be signed in to change notification settings - Fork 583
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ivan Yelizariev
committed
Feb 10, 2020
1 parent
de40575
commit 70883cb
Showing
242 changed files
with
5,147 additions
and
4,523 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
wechatpy[cryptography] | ||
requests-mock | ||
python-alipay-sdk | ||
websocket-client | ||
websocket-client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). | ||
|
||
|
||
def post_load(): | ||
from . import controllers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,28 +9,20 @@ | |
"images": [], | ||
"version": "12.0.2.0.1", | ||
"application": False, | ||
|
||
"author": "IT-Projects LLC, Dinar Gabbasov", | ||
"support": "[email protected]", | ||
"website": "https://apps.odoo.com/apps/modules/12.0/hw_printer_network/", | ||
"license": "LGPL-3", | ||
"price": 59.00, | ||
"currency": "EUR", | ||
|
||
"depends": [ | ||
"hw_escpos", | ||
], | ||
"depends": ["hw_escpos"], | ||
"external_dependencies": {"python": [], "bin": []}, | ||
"data": [ | ||
], | ||
"qweb": [ | ||
], | ||
"data": [], | ||
"qweb": [], | ||
"demo": [], | ||
|
||
"post_load": "post_load", | ||
"pre_init_hook": None, | ||
"post_init_hook": None, | ||
|
||
"auto_install": False, | ||
"installable": False, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,14 @@ | |
# Copyright 2018 Tom Blauwendraat <[email protected]> | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). | ||
|
||
from odoo import http | ||
import logging | ||
import time | ||
import socket | ||
import subprocess | ||
import threading | ||
import time | ||
import traceback | ||
|
||
from odoo import http | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
@@ -30,7 +30,7 @@ def __init__(self, ip): | |
self.stdout = None | ||
self.stderr = None | ||
threading.Thread.__init__(self) | ||
self.status = 'offline' | ||
self.status = "offline" | ||
self.ip = ip | ||
self.stop = False | ||
|
||
|
@@ -40,10 +40,10 @@ def run(self): | |
["ping", "-c1", "-w5", self.ip], | ||
shell=False, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE | ||
stderr=subprocess.PIPE, | ||
) | ||
child.communicate() | ||
self.status = 'offline' if child.returncode else 'online' | ||
self.status = "offline" if child.returncode else "online" | ||
time.sleep(1) | ||
|
||
def get_status(self): | ||
|
@@ -54,7 +54,6 @@ def __del__(self): | |
|
||
|
||
class EscposNetworkDriver(EscposDriver): | ||
|
||
def __init__(self): | ||
self.network_printers = [] | ||
self.ping_processes = {} | ||
|
@@ -64,11 +63,11 @@ def __init__(self): | |
def get_network_printer(self, ip, name=None): | ||
found_printer = False | ||
for printer in self.network_printers: | ||
if printer['ip'] == ip: | ||
if printer["ip"] == ip: | ||
found_printer = True | ||
if name: | ||
printer['name'] = name | ||
if printer['status'] == 'online': | ||
printer["name"] = name | ||
if printer["status"] == "online": | ||
printer_object = self.printer_objects.get(ip, None) | ||
if not printer_object: | ||
try: | ||
|
@@ -82,11 +81,7 @@ def get_network_printer(self, ip, name=None): | |
return None | ||
|
||
def add_network_printer(self, ip, name=None): | ||
printer = dict( | ||
ip=ip, | ||
status='offline', | ||
name=name or 'Unnamed printer' | ||
) | ||
printer = dict(ip=ip, status="offline", name=name or "Unnamed printer") | ||
self.network_printers.append(printer) # dont return because offline | ||
self.start_pinging(ip) | ||
|
||
|
@@ -96,58 +91,80 @@ def start_pinging(self, ip): | |
pinger.start() | ||
|
||
def update_driver_status(self): | ||
count = len([p for p in self.network_printers if p.get('status', None) == 'online']) | ||
count = len( | ||
[p for p in self.network_printers if p.get("status", None) == "online"] | ||
) | ||
if count: | ||
self.set_status('connected', '{} printer(s) Connected'.format(count)) | ||
self.set_status("connected", "{} printer(s) Connected".format(count)) | ||
else: | ||
self.set_status('disconnected', 'Disconnected') | ||
self.set_status("disconnected", "Disconnected") | ||
|
||
def run(self): | ||
if not escpos: | ||
_logger.error('ESC/POS cannot initialize, please verify system dependencies.') | ||
_logger.error( | ||
"ESC/POS cannot initialize, please verify system dependencies." | ||
) | ||
return | ||
while True: | ||
try: | ||
error = True | ||
timestamp, task, data = self.queue.get(True) | ||
if task == 'xml_receipt': | ||
if task == "xml_receipt": | ||
error = False | ||
if timestamp >= (time.time() - 1 * 60 * 60): | ||
receipt, network_printer_ip = data | ||
printer_info = self.get_network_printer(network_printer_ip) | ||
printer = self.printer_objects.get(network_printer_ip, None) | ||
if printer_info and printer_info['status'] == 'online' and printer: | ||
_logger.info('Printing XML receipt on printer %s...', network_printer_ip) | ||
if ( | ||
printer_info | ||
and printer_info["status"] == "online" | ||
and printer | ||
): | ||
_logger.info( | ||
"Printing XML receipt on printer %s...", | ||
network_printer_ip, | ||
) | ||
try: | ||
printer.receipt(receipt) | ||
except socket.error: | ||
printer.open() | ||
printer.receipt(receipt) | ||
_logger.info('Done printing XML receipt on printer %s', network_printer_ip) | ||
_logger.info( | ||
"Done printing XML receipt on printer %s", | ||
network_printer_ip, | ||
) | ||
else: | ||
_logger.error('xml_receipt: printer offline!') | ||
_logger.error("xml_receipt: printer offline!") | ||
# add a missed order to queue | ||
time.sleep(3) | ||
self.queue.put((timestamp, task, data)) | ||
elif task == 'printstatus': | ||
elif task == "printstatus": | ||
pass | ||
elif task == 'status': | ||
elif task == "status": | ||
error = False | ||
for printer in self.network_printers: | ||
ip = printer['ip'] | ||
ip = printer["ip"] | ||
pinger = self.ping_processes.get(ip, None) | ||
if pinger and pinger.isAlive(): | ||
status = pinger.get_status() | ||
if status != printer['status']: | ||
if status != printer["status"]: | ||
# todo: use a lock? | ||
printer['status'] = status | ||
printer["status"] = status | ||
self.update_driver_status() | ||
else: | ||
self.start_pinging(ip) | ||
error = False | ||
except Exception as e: | ||
self.set_status('error', str(e)) | ||
errmsg = str(e) + '\n' + '-'*60+'\n' + traceback.format_exc() + '-'*60 + '\n' | ||
self.set_status("error", str(e)) | ||
errmsg = ( | ||
str(e) | ||
+ "\n" | ||
+ "-" * 60 | ||
+ "\n" | ||
+ traceback.format_exc() | ||
+ "-" * 60 | ||
+ "\n" | ||
) | ||
_logger.error(errmsg) | ||
finally: | ||
if error: | ||
|
@@ -158,25 +175,25 @@ def run(self): | |
# original driver runs in parallel and deals with USB printers | ||
network_driver = EscposNetworkDriver() | ||
|
||
hw_proxy.drivers['escpos_network'] = network_driver | ||
hw_proxy.drivers["escpos_network"] = network_driver | ||
|
||
# this will also start the message handling loop | ||
network_driver.push_task('printstatus') | ||
network_driver.push_task("printstatus") | ||
|
||
|
||
class UpdatedEscposProxy(EscposProxy): | ||
@http.route('/hw_proxy/print_xml_receipt', type='json', auth='none', cors='*') | ||
@http.route("/hw_proxy/print_xml_receipt", type="json", auth="none", cors="*") | ||
def print_xml_receipt(self, receipt, proxy=None): | ||
if proxy: | ||
network_driver.push_task('xml_receipt', (receipt, proxy)) | ||
network_driver.push_task("xml_receipt", (receipt, proxy)) | ||
else: | ||
super(UpdatedEscposProxy, self).print_xml_receipt(receipt) | ||
|
||
@http.route('/hw_proxy/network_printers', type='json', auth='none', cors='*') | ||
@http.route("/hw_proxy/network_printers", type="json", auth="none", cors="*") | ||
def network_printers(self, network_printers=None): | ||
for printer in network_printers: | ||
network_driver.get_network_printer(printer['ip'], name=printer['name']) | ||
network_driver.get_network_printer(printer["ip"], name=printer["name"]) | ||
|
||
@http.route('/hw_proxy/status_network_printers', type='json', auth='none', cors='*') | ||
@http.route("/hw_proxy/status_network_printers", type="json", auth="none", cors="*") | ||
def network_printers_status(self): | ||
return network_driver.network_printers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
OCA_web https://github.com/it-projects-llc/web | ||
misc-addons https://github.com/it-projects-llc/misc-addons | ||
stock-logistics-barcode https://github.com/it-projects-llc/stock-logistics-barcode | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,46 +5,30 @@ | |
"summary": """The module allows to open Cashbox/Cashdrawer from Backend""", | ||
"category": "Point of Sale", | ||
# "live_test_url": "http://apps.it-projects.info/shop/product/pos-cashbox?version=10.0", | ||
"images": ['images/pos_cashbox_main.png'], | ||
"images": ["images/pos_cashbox_main.png"], | ||
"version": "10.0.1.0.0", | ||
"application": False, | ||
|
||
"author": "IT-Projects LLC, Dinar Gabbasov", | ||
"support": "[email protected]", | ||
"website": "https://it-projects.info/team/GabbasovDinar", | ||
"license": "LGPL-3", | ||
"price": 25.00, | ||
"currency": "EUR", | ||
|
||
"depends": [ | ||
"point_of_sale", | ||
], | ||
"depends": ["point_of_sale"], | ||
"external_dependencies": {"python": [], "bin": []}, | ||
"data": [ | ||
"views/pos_cashbox_template.xml", | ||
"views/pos_cashbox_view.xml", | ||
], | ||
"qweb": [ | ||
], | ||
"demo": [ | ||
], | ||
|
||
"data": ["views/pos_cashbox_template.xml", "views/pos_cashbox_view.xml"], | ||
"qweb": [], | ||
"demo": [], | ||
"post_load": None, | ||
"pre_init_hook": None, | ||
"post_init_hook": None, | ||
"uninstall_hook": None, | ||
|
||
"auto_install": False, | ||
"installable": False, | ||
|
||
"demo_title": "Open CashBox from Backend", | ||
"demo_addons": [ | ||
], | ||
"demo_addons_hidden": [ | ||
], | ||
"demo_addons": [], | ||
"demo_addons_hidden": [], | ||
"demo_url": "pos-cashbox", | ||
"demo_summary": "The module allows to open the CashBox from Backend", | ||
"demo_images": [ | ||
"images/pos_cashbox_main.png", | ||
] | ||
"demo_images": ["images/pos_cashbox_main.png"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
# Copyright 2018 Dinar Gabbasov <https://it-projects.info/team/GabbasovDinar> | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
from odoo import api, fields, models | ||
from odoo import fields, models | ||
|
||
|
||
class PosSession(models.Model): | ||
_inherit = 'pos.session' | ||
_inherit = "pos.session" | ||
|
||
iface_cashdrawer = fields.Boolean(related='config_id.iface_cashdrawer') | ||
proxy_ip = fields.Char(related='config_id.proxy_ip') | ||
iface_cashdrawer = fields.Boolean(related="config_id.iface_cashdrawer") | ||
proxy_ip = fields.Char(related="config_id.proxy_ip") | ||
|
||
def open_backend_cashbox(self): | ||
pass |
Oops, something went wrong.