计算时附加电缆产品信息
This commit is contained in:
@@ -1,8 +1,36 @@
|
||||
from models import Product, Session
|
||||
import uuid
|
||||
from config import *
|
||||
class ProductManager:
|
||||
def __init__(self, parent=None):
|
||||
super().__init__()
|
||||
self.cur_product_id = ""
|
||||
|
||||
config = read_config()
|
||||
if config.get('product_id', '') == "":
|
||||
try:
|
||||
products = self.getInfo("all")
|
||||
if products == []:
|
||||
print("no product found in database")
|
||||
else:
|
||||
config.update(product_id = products[0]["id"])
|
||||
save_config(config)
|
||||
except:
|
||||
pass
|
||||
|
||||
def setCurProductId(self, id):
|
||||
self.cur_product_id = id
|
||||
config = read_config()
|
||||
if config.get('product_id', '') == id:
|
||||
return
|
||||
config.update(product_id = id)
|
||||
save_config(config)
|
||||
|
||||
def getCurProductId(self):
|
||||
return self.cur_product_id
|
||||
|
||||
def getCurrentProduct(self):
|
||||
return self.getInfo(self.cur_product_id)
|
||||
|
||||
def create(self, info):
|
||||
data = {
|
||||
|
||||
Reference in New Issue
Block a user