More Shipstation integrations(warehouses)

This commit is contained in:
2026-08-31 15:00:37 -05:00
parent 4c172c1fd5
commit 9651b82415
12 changed files with 337 additions and 139 deletions
+15 -13
View File
@@ -25,11 +25,10 @@ from PyQt6.QtWidgets import (
QFileDialog,
)
from app import config
from app.services import SERVICE_REGISTRY
from app.services.odoo_export import export_orders_to_csv
from app.services.shipstation_send import export_order_to_shipstation_csv
from app.status_rules import parse_status_list, find_new_cancellations
from app.status_rules import get_cancelled_statuses, find_new_cancellations
from app.ui.settings_dialog import SettingsDialog
from app.ui.widgets.orders_table import OrdersTableView
from app.ui.widgets.dashboard import DashboardWidget
@@ -37,7 +36,7 @@ from app.ui.widgets.order_detail_dialog import OrderDetailDialog
from app.workers import (
FetchOrdersWorker,
SendToShipStationWorker,
load_active_and_done_orders,
load_orders_by_view,
get_dashboard_stats,
)
@@ -65,10 +64,13 @@ class MainWindow(QMainWindow):
self.dashboard = DashboardWidget()
self.orders_table = OrdersTableView()
self.orders_table.order_double_clicked.connect(self._on_order_double_clicked)
self.cancelled_table = OrdersTableView()
self.cancelled_table.order_double_clicked.connect(self._on_order_double_clicked)
self.done_table = OrdersTableView()
self.done_table.order_double_clicked.connect(self._on_order_double_clicked)
self.tabs.addTab(self.dashboard, "Dashboard")
self.tabs.addTab(self.orders_table, "Active Orders")
self.tabs.addTab(self.cancelled_table, "Cancelled")
self.tabs.addTab(self.done_table, "Done")
layout.addWidget(self.tabs)
@@ -91,13 +93,13 @@ class MainWindow(QMainWindow):
toolbar.addSeparator()
export_action = QAction("Export Visible Orders to Odoo CSV", self)
export_action.setToolTip("Exports from whichever of Active Orders / Done is open")
export_action.setToolTip("Exports from whichever tab is currently open")
export_action.triggered.connect(self._on_export_clicked)
toolbar.addAction(export_action)
toolbar.addSeparator()
emergency_action = QAction("Send to ShipStation (Emergency)", self)
emergency_action = QAction("Send to ShipStation", self)
emergency_action.setToolTip("Select a ticket in Active Orders first")
emergency_action.triggered.connect(self._on_emergency_send_clicked)
toolbar.addAction(emergency_action)
@@ -186,10 +188,7 @@ class MainWindow(QMainWindow):
)
def _notify_new_cancellations(self, status_changes: list) -> None:
cancelled_statuses = parse_status_list(
config.get("CANCELLED_STATUSES", config.DEFAULT_CANCELLED_STATUSES)
)
newly_cancelled = find_new_cancellations(status_changes, cancelled_statuses)
newly_cancelled = find_new_cancellations(status_changes, get_cancelled_statuses())
if not newly_cancelled:
return
@@ -217,7 +216,7 @@ class MainWindow(QMainWindow):
QMessageBox.information(
self,
"Nothing to export",
"Switch to the Active Orders or Done tab first, then export.",
"Switch to Active Orders, Cancelled, or Done first, then export.",
)
return
@@ -333,13 +332,15 @@ class MainWindow(QMainWindow):
)
def _refresh_everything(self) -> None:
active_orders, done_orders = load_active_and_done_orders()
active_orders, cancelled_orders, done_orders = load_orders_by_view()
self.orders_table.set_orders(active_orders)
self.cancelled_table.set_orders(cancelled_orders)
self.done_table.set_orders(done_orders)
self.dashboard.update_stats(get_dashboard_stats())
if not hasattr(self, "_suppress_ready_status"):
self.status_label.setText(
f"{len(active_orders)} active order(s), {len(done_orders)} done."
f"{len(active_orders)} active, {len(cancelled_orders)} cancelled, "
f"{len(done_orders)} done."
)
@@ -351,7 +352,8 @@ class MainWindow(QMainWindow):
# _on_import_clicked, and it can eventually replace/augment odoo_export.py.
# - Emailed-label SKU: these tickets won't get tracking numbers pulled via
# the normal ShipStation flow - once its handling is defined, it likely
# needs its own terminal status and its own "mark as sent" action here.
# needs its own status/action here so it doesn't get stuck in Active
# forever with nothing to trigger its move to Done.
# - Pipeline actions ("mark fulfilled manually", "void a label"): add
# toolbar actions gated on table selection.
# - If the window grows too much, split each tab's toolbar into its own