合约管理简化为选品种+填月份,系统自动拼接合约代码
This commit is contained in:
@@ -76,15 +76,21 @@ def create_product(
|
||||
def create_contract(
|
||||
request: Request,
|
||||
product_id: int = Form(...),
|
||||
code: str = Form(...),
|
||||
name: str = Form(...),
|
||||
month: str = Form(...),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
existing = db.query(Contract).filter(Contract.code == code.upper()).first()
|
||||
product = db.query(Product).filter(Product.id == product_id).first()
|
||||
if not product:
|
||||
return RedirectResponse("/admin/?tab=contract", status_code=303)
|
||||
|
||||
code = (product.code + month).upper()
|
||||
name = month.upper()
|
||||
|
||||
existing = db.query(Contract).filter(Contract.code == code).first()
|
||||
if not existing:
|
||||
c = Contract(
|
||||
product_id=product_id,
|
||||
code=code.upper(),
|
||||
code=code,
|
||||
name=name,
|
||||
is_active=True,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user