Bug fixes

master
Glueck Martin 2024-07-23 08:21:11 +02:00
parent 0e5286c333
commit 8a05d7b10f
6 changed files with 83 additions and 15 deletions

View File

@ -2,8 +2,8 @@ from QT import QtWidgets, QtGui, QT
from QT.Input_Dialog import Input_Dialog
from _With_Table_Widget_ import _With_Table_Widget_
from App_State import App_State
from Action_List import Action_Dialog
import subprocess
import requests
import threading
import time
import pathlib
@ -217,7 +217,6 @@ class Order_List (_With_Table_Widget_) :
AXE (xset, "ARTICLE_PRICE_INFO4", tax)
AXE (xset, "ARTICLE_PRICE_INFO5", round (tax_amount, 2))
AXE (xset, "ARTICLE_PRICE_INFO6", round (price + tax_amount, 2))
breakpoint ()
OR = pathlib.Path (self.config.directories.order_ready)
AR = pathlib.Path (self.config.directories.sim_root) / "Archive"
## first patch the XML in the archive directory
@ -324,16 +323,65 @@ class Order_List (_With_Table_Widget_) :
row_data = self._view.selectedItems ()
if row_data :
bno = row_data [0].text ()
self.L.error ("Reset order in webshop %s", bno)
dlg = QtWidgets.QMessageBox(self)
dlg.setWindowTitle ("Auftrag zurücksetzen")
dlg.setText (f"Wollen sie Auftrag {bno} wirklich zurücksetzen?")
dlg.setStandardButtons \
(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
button = dlg.exec ()
if button != QtWidgets.QMessageBox.Yes :
return
code = self.config.shop_secret
url = f"{self.config.shop_url}/vue/basket/{bno}/reset/{code}/"
r = requests.post (url)
if r.status_code == 200 :
r = r.json ()
if r ["status"] :
self._move_order_files (bno, "reseted")
self.L.info ("Auftrag %s zurückgesetzt", bno)
else :
self.L.error \
( "Fehler beim zurücksetzen von %s:\n %s"
, bno, r ["message"]
)
else :
self.L.error \
("Fehler beim zurüpcksetzen von %s:\n %s", bno, r.text)
# end def _reset_order_in_webshop
def _cancel_order (self) :
row_data = self._view.selectedItems ()
if row_data :
bno = row_data [0].text ()
self.L.error ("Cancel Order %s", bno)
bno = row_data [0].text ()
dlg = QtWidgets.QMessageBox(self)
dlg.setWindowTitle ("Auftrag stornieren ?")
dlg.setText (f"Wollen sie Auftra {bno} wirklich stornieren?")
dlg.setStandardButtons \
(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
button = dlg.exec ()
if button != QtWidgets.QMessageBox.Yes :
return
self._move_order_files (bno, "canceld")
self.L.info ("Auftrag %s storniert von %s", bno, App_State.User)
# end def _cancel_order
def _move_order_files (self, bno, target_dir) :
D = self.config.directories
oready = pathlib.Path (D.order_ready)
ddir = oready / target_dir
ddir.mkdir (parents = True, exist_ok = True)
now = App_State.snow ()
for ext in ".xml", ".txt" :
sf = oready / f"{bno}{ext}"
df = ddir / f"{bno}-{now}{ext}"
sf.rename (df)
sf = pathlib.Path (D.sim_root) / "Archive" / f"{bno}.xml"
df = ddir / f"{bno}-ar-{now}.xml"
sf.rename (df)
# end def _move_order_files
def _send_oder_to_odoo (self) :
row_data = self._view.selectedItems ()
if row_data :
@ -343,8 +391,8 @@ class Order_List (_With_Table_Widget_) :
D = self.config.directories
factory = pathlib.Path (D.factory_root)
for ext in ".xml", ".txt" :
sf = factory / D.order_ready / f"{bno}{ext}"
df = factory / D.pgiq_dir / f"{bno}{ext}"
sf = pathlib.Path (D.order_ready) / f"{bno}{ext}"
df = factory / "OrderXML" / f"{bno}{ext}"
sf.rename (df)
self.L.info ("Auftrag %s für Odoo freigegeben", bno)
# end def _send_oder_to_odoo

View File

@ -98,16 +98,15 @@ class Order_Handler (Directory_Handler, App_State) :
class Order_Watch (App_State) :
order_incomming_dir = r"n:\glueck\watch-me\inbox"
def __init__ (self, config_file) :
self.load_config (config_file)
self.client = self.connect_to_db ()
# end def __init__
def _start_watchdog (self) :
order_incomming_dir = self.config.directories.order_ready
handler = Order_Handler \
(self.order_incomming_dir, self.client, self.config)
(order_incomming_dir, self.client, self.config)
return WindowsApiObserverExcpetionHandler.Start_Directory_Watcher \
(handler)
# end def _start_watchdog

View File

@ -42,7 +42,7 @@ class WindowsApiObserverExcpetionHandler (Observer, _Logger_) :
return observer
except Exception as e :
if getattr (e, "errno", None) == 2 :
L.error ("%s does not exists, retry", path)
L.error ("%s does not exists, retry", handler.directory)
observer.stop ()
time.sleep (retry_wait)
else :

3
logs/test.log Normal file
View File

@ -0,0 +1,3 @@
2024-05-23 10:55:53 - INFO - Hello
2024-05-23 10:55:53 - WARNING - Hello
2024-05-23 10:55:53 - DEBUG - Hello

View File

@ -11,7 +11,7 @@ database: redis
users: users.yaml
directories:
order_ready: n:\glueck\watch-me\inbox
factory_root: n:\IMOS\Live-System\Factory
sim_root: n:\IMOS\Live-System\SIM
pgiq_dir: n:\glueck\watch-me\odoo
order_ready: n:\IMOS\Test-System\Orders
factory_root: n:\IMOS\Test-System\Factory
sim_root: n:\IMOS\Test-System\SIM
pgiq_dir: n:\IMOS\Test-System\Factory\OrderXml

18
test_order_watch.yaml Normal file
View File

@ -0,0 +1,18 @@
mqtt:
broker: odoo-test
port: 1883
user: imos
password: gAAAAABmTy4fipVAw10oKCE2aLWq79BF9Id5H8-lEEm8tOgcoaGgIJRWwBdR0nj-lrN-70hcLMHVqNudk7FTJjOvE0KOCkDr0A==
topic-root: imos-order
redis:
host: odoo-test
database: redis
users: users.yaml
directories:
order_ready: c:\IMOS\Test-System\Orders
factory_root: c:\IMOS\Test-System\Factory
sim_root: c:\IMOS\Test-System\SIM
shop_url: https://test-portal.tzaustria.info
shop_secret: vkI3ky5ifHCs6uRhC5o2jWmKV5mgnDrBQ46ZO3dd4T4we8Y70fSwGAmdkAIhDh7uecNYJMBKn9AUF9IPEMATvnjnjOl02hoVoueih4JqbRi7WpocoDfjIiYwcn0ELvGJ