Пример #1
0
 def render(self):
     self.win.clear()
     curses.curs_set(0)
     self.win.addstr(0, 0, "Netforce Terminal",
                     curses.A_BOLD | curses.color_pair(1))
     self.win.addstr(1, 0, "Check Product Stock", curses.A_BOLD)
     opts = {
         "win": self.win.subwin(1, 80, 3, 0),
         "key": 1,
         "string": "Product",
         "name": "product_id",
         "relation": "product",
         "data": self.data,
     }
     self.subviews["product_id"] = make_view("field_m2o", opts)
     opts = {
         "win": self.win.subwin(1, 80, 4, 0),
         "key": 2,
         "string": "Location",
         "name": "location_id",
         "relation": "stock.location",
         "condition": [["type", "=", "internal"]],
         "data": self.data,
     }
     self.subviews["location_id"] = make_view("field_m2o", opts)
     self.win.addstr(5, 0, "3.", curses.A_BOLD | curses.color_pair(2))
     self.win.addstr(5, 3, "Check Stock")
     self.win.refresh()
     h, w = self.win.getmaxyx()
     self.list_win = self.win.subwin(h - 7, w, 7, 0)
     self.render_items()
     for n, view in self.subviews.items():
         view.render()
Пример #2
0
 def focus(self):
     while True:
         c = self.win.getch()
         try:
             if c == 27:
                 return
             elif c == ord("1"):
                 self.subviews["product_id"].focus()
                 self.render()
             elif c == ord("2"):
                 self.subviews["lot_no"].focus()
                 self.render()
             elif c == ord("3"):
                 self.subviews["qty"].focus()
                 self.render()
             elif c == ord("4"):
                 if not self.data["product_id"]:
                     raise Exception("Missing product")
                 if not self.data["qty"]:
                     raise Exception("Missing qty")
                 return self.data
             elif c == ord("5"):
                 self.data["product_id"] = self.data["prev_product_id"]
                 self.render()
         except Exception as e:
             make_view("error", {"message": str(e)}).focus()
             self.render()
Пример #3
0
 def focus(self):
     while True:
         c=self.win.getch()
         try:
             if c==27:
                 return
             elif c==ord("1"):
                 self.subviews["product_id"].focus()
                 self.data["lines"]=[]
                 self.render()
             elif c==ord("2"):
                 self.subviews["location_id"].focus()
                 self.data["lines"]=[]
                 self.render()
             elif c==ord("3"):
                 self.check_stock()
             elif c==curses.KEY_DOWN:
                 if self.pos<len(self.data["lines"])-1:
                     self.pos+=1
                     self.render_items()
             elif c==curses.KEY_UP:
                 if self.pos>0:
                     self.pos-=1
                     self.render_items()
         except Exception as e:
             make_view("error",{"message": str(e)}).focus()
             self.render()
Пример #4
0
 def validate(self):
     with Transaction():
         if not self.data["location_id"]:
             raise Exception("Missing location")
         vals = {
             "location_id": self.data["location_id"][0],
             "lines": [],
         }
         for line in self.data["lines"]:
             prod_id = line["product_id"][0]
             prod = get_model("product").browse(prod_id)
             line_vals = {
                 "product_id": prod.id,
                 "prev_qty": line["prev_qty"],
                 "new_qty": line["new_qty"],
                 "uom_id": prod.uom_id.id,
             }
             vals["lines"].append(("create", line_vals))
         if not vals["lines"]:
             raise Exception("Empty stock count")
         count_id = get_model("stock.count").create(vals)
         get_model("stock.count").validate([count_id])
         count = get_model("stock.count").browse(count_id)
         msg = "Stock count %s created successfully" % count.number
         make_view("message", {"message": msg}).focus()
         self.render()
Пример #5
0
 def focus(self):
     while True:
         c=self.win.getch()
         try:
             if c==27:
                 return
             elif c==ord("1"):
                 self.subviews["product_id"].focus()
                 self.render()
             elif c==ord("2"):
                 self.subviews["lot_no"].focus()
                 self.render()
             elif c==ord("3"):
                 self.subviews["qty"].focus()
                 self.render()
             elif c==ord("4"):
                 if not self.data["product_id"]:
                     raise Exception("Missing product")
                 if not self.data["qty"]:
                     raise Exception("Missing qty")
                 return self.data
             elif c==ord("5"):
                 self.data["product_id"]=self.data["prev_product_id"]
                 self.render()
         except Exception as e:
             make_view("error",{"message": str(e)}).focus()
             self.render()
Пример #6
0
 def validate(self):
     with Transaction():
         if not self.data["location_id"]:
             raise Exception("Missing location")
         vals={
             "location_id": self.data["location_id"][0],
             "lines": [],
         }
         for line in self.data["lines"]:
             prod_id=line["product_id"][0]
             prod=get_model("product").browse(prod_id)
             line_vals={
                 "product_id": prod.id,
                 "prev_qty": line["prev_qty"],
                 "new_qty": line["new_qty"],
                 "uom_id": prod.uom_id.id,
             }
             vals["lines"].append(("create",line_vals))
         if not vals["lines"]:
             raise Exception("Empty stock count")
         count_id=get_model("stock.count").create(vals)
         get_model("stock.count").validate([count_id])
         count=get_model("stock.count").browse(count_id)
         msg="Stock count %s created successfully"%count.number
         make_view("message",{"message":msg}).focus()
         self.render()
Пример #7
0
 def render(self):
     self.win.clear()
     curses.curs_set(0)
     self.win.addstr(0,0,"Netforce Terminal",curses.A_BOLD|curses.color_pair(1))
     self.win.addstr(1,0,"Check Product Stock",curses.A_BOLD)
     opts={
         "win": self.win.subwin(1,80,3,0),
         "key": 1,
         "string": "Product",
         "name": "product_id",
         "relation": "product",
         "data": self.data,
     }
     self.subviews["product_id"]=make_view("field_m2o",opts)
     opts={
         "win": self.win.subwin(1,80,4,0),
         "key": 2,
         "string": "Location",
         "name": "location_id",
         "relation": "stock.location",
         "condition": [["type","=","internal"]],
         "data": self.data,
     }
     self.subviews["location_id"]=make_view("field_m2o",opts)
     self.win.addstr(5,0,"3.",curses.A_BOLD|curses.color_pair(2))
     self.win.addstr(5,3,"Check Stock")
     self.win.refresh()
     h,w=self.win.getmaxyx()
     self.list_win=self.win.subwin(h-7,w,7,0)
     self.render_items()
     for n,view in self.subviews.items():
         view.render()
Пример #8
0
 def focus(self):
     while True:
         c = self.win.getch()
         try:
             if c == 27:
                 return
             elif c == ord("1"):
                 self.subviews["product_id"].focus()
                 self.data["lines"] = []
                 self.render()
             elif c == ord("2"):
                 self.subviews["location_id"].focus()
                 self.data["lines"] = []
                 self.render()
             elif c == ord("3"):
                 self.check_stock()
             elif c == curses.KEY_DOWN:
                 if self.pos < len(self.data["lines"]) - 1:
                     self.pos += 1
                     self.render_items()
             elif c == curses.KEY_UP:
                 if self.pos > 0:
                     self.pos -= 1
                     self.render_items()
         except Exception as e:
             make_view("error", {"message": str(e)}).focus()
             self.render()
Пример #9
0
 def focus(self):
     while True:
         c=self.win.getch()
         try:
             if c==27:
                 return
             elif c==ord("1"):
                 self.subviews["purchase_id"].focus()
                 self.render()
             elif c==ord("2"):
                 self.subviews["invoice_id"].focus()
                 inv_id=self.data.get("invoice_id")
                 if inv_id:
                     with Transaction():
                         inv=get_model("account.invoice").browse(inv_id)
                         rel=inv.related_id
                         if rel and rel._model=="purchase.order":
                             self.data["purchase_id"]=rel.id
                 self.render()
             elif c==ord("3"):
                 self.subviews["location_id"].focus()
                 self.render()
             elif c==ord("4"):
                 opts={
                     "window": self.win,
                     "prev_product_id": self.prev_product_id,
                 }
                 v=make_view("add_product",opts)
                 v.render()
                 res=v.focus()
                 if res:
                     self.data["lines"].append(res)
                     self.prev_product_id=res["product_id"]
                 self.render()
             elif c==ord("5"):
                 self.validate()
                 return
             elif c==curses.KEY_DOWN:
                 if self.pos<len(self.data["lines"])-1:
                     self.pos+=1
                     self.render_items()
             elif c==curses.KEY_UP:
                 if self.pos>0:
                     self.pos-=1
                     self.render_items()
             elif c==curses.KEY_BACKSPACE or c==curses.KEY_DC:
                 if self.data["lines"]:
                     del self.data["lines"][self.pos]
                 self.render_items()
         except Exception as e:
             make_view("error",{"message": str(e)}).focus()
             self.render()
Пример #10
0
 def focus(self):
     while True:
         c = self.win.getch()
         try:
             if c == 27:
                 return
             elif c == ord("1"):
                 self.subviews["purchase_id"].focus()
                 self.render()
             elif c == ord("2"):
                 self.subviews["invoice_id"].focus()
                 inv_id = self.data.get("invoice_id")
                 if inv_id:
                     with Transaction():
                         inv = get_model("account.invoice").browse(inv_id)
                         rel = inv.related_id
                         if rel and rel._model == "purchase.order":
                             self.data["purchase_id"] = rel.id
                 self.render()
             elif c == ord("3"):
                 self.subviews["location_id"].focus()
                 self.render()
             elif c == ord("4"):
                 opts = {
                     "window": self.win,
                     "prev_product_id": self.prev_product_id,
                 }
                 v = make_view("add_product", opts)
                 v.render()
                 res = v.focus()
                 if res:
                     self.data["lines"].append(res)
                     self.prev_product_id = res["product_id"]
                 self.render()
             elif c == ord("5"):
                 self.validate()
                 return
             elif c == curses.KEY_DOWN:
                 if self.pos < len(self.data["lines"]) - 1:
                     self.pos += 1
                     self.render_items()
             elif c == curses.KEY_UP:
                 if self.pos > 0:
                     self.pos -= 1
                     self.render_items()
             elif c == curses.KEY_BACKSPACE or c == curses.KEY_DC:
                 if self.data["lines"]:
                     del self.data["lines"][self.pos]
                 self.render_items()
         except Exception as e:
             make_view("error", {"message": str(e)}).focus()
             self.render()
Пример #11
0
 def validate(self):
     with Transaction():
         vals = {
             "lines": [],
         }
         if self.data["purchase_id"]:
             vals["related_id"] = "purchase.order,%d" % self.data[
                 "purchase_id"][0]
         res = get_model("stock.location").search(
             [["type", "=", "supplier"]], order="id")
         if not res:
             raise Exception("Supplier location not found")
         supp_loc_id = res[0]
         if not self.data["location_id"]:
             raise Exception("Missing location")
         to_loc_id = self.data["location_id"][0]
         for line in self.data["lines"]:
             lot_no = line["lot_no"]
             if lot_no:
                 res = get_model("stock.lot").search(
                     [["number", "=", lot_no]])
                 if res:
                     lot_id = res[0]
                 else:
                     lot_id = get_model("stock.lot").create(
                         {"number": lot_no})
             else:
                 lot_id = None
             prod_id = line["product_id"][0]
             prod = get_model("product").browse(prod_id)
             line_vals = {
                 "product_id": prod.id,
                 "lot_id": lot_id,
                 "qty": line["qty"],
                 "uom_id": prod.uom_id.id,
                 "location_from_id": supp_loc_id,
                 "location_to_id": to_loc_id,
             }
             vals["lines"].append(("create", line_vals))
         if not vals["lines"]:
             raise Exception("Empty goods receipt")
         pick_id = get_model("stock.picking").create(
             vals, context={"pick_type": "in"})
         get_model("stock.picking").set_done([pick_id])
         pick = get_model("stock.picking").browse(pick_id)
         msg = "Goods receipt %s created successfully" % pick.number
         make_view("message", {"message": msg}).focus()
         self.render()
Пример #12
0
 def render(self):
     self.win.clear()
     curses.curs_set(0)
     self.win.addstr(0, 0, "Netforce Terminal",
                     curses.A_BOLD | curses.color_pair(1))
     self.win.addstr(1, 0, "Receive From Supplier", curses.A_BOLD)
     opts = {
         "win": self.win.subwin(1, 80, 3, 0),
         "key": 1,
         "string": "Purchase Order",
         "name": "purchase_id",
         "relation": "purchase.order",
         "condition": [["state", "=", "confirmed"]],
         "data": self.data,
     }
     self.subviews["purchase_id"] = make_view("field_m2o", opts)
     opts = {
         "win": self.win.subwin(1, 80, 4, 0),
         "key": 2,
         "string": "Invoice",
         "name": "invoice_id",
         "relation": "account.invoice",
         "condition": [["state", "in", ["waiting_payment", "paid"]]],
         "data": self.data,
     }
     self.subviews["invoice_id"] = make_view("field_m2o", opts)
     opts = {
         "win": self.win.subwin(1, 80, 5, 0),
         "key": 3,
         "string": "To Location",
         "name": "location_id",
         "relation": "stock.location",
         "condition": [["type", "=", "internal"]],
         "data": self.data,
     }
     self.subviews["location_id"] = make_view("field_m2o", opts)
     self.win.addstr(6, 0, "4.", curses.A_BOLD | curses.color_pair(2))
     self.win.addstr(6, 3, "Add Product")
     self.win.addstr(7, 0, "5.", curses.A_BOLD | curses.color_pair(2))
     self.win.addstr(7, 3, "Validate Goods Receipt")
     self.win.addstr(9, 0, "Received Products:")
     self.win.refresh()
     h, w = self.win.getmaxyx()
     self.list_win = self.win.subwin(h - 11, w, 11, 0)
     self.render_items()
     for n, view in self.subviews.items():
         view.render()
Пример #13
0
 def render(self):
     self.win.clear()
     curses.curs_set(0)
     self.win.addstr(0,0,"Netforce Terminal",curses.A_BOLD|curses.color_pair(1))
     self.win.addstr(1,0,"Receive From Supplier",curses.A_BOLD)
     opts={
         "win": self.win.subwin(1,80,3,0),
         "key": 1,
         "string": "Purchase Order",
         "name": "purchase_id",
         "relation": "purchase.order",
         "condition": [["state","=","confirmed"]],
         "data": self.data,
     }
     self.subviews["purchase_id"]=make_view("field_m2o",opts)
     opts={
         "win": self.win.subwin(1,80,4,0),
         "key": 2,
         "string": "Invoice",
         "name": "invoice_id",
         "relation": "account.invoice",
         "condition": [["state","in",["waiting_payment","paid"]]],
         "data": self.data,
     }
     self.subviews["invoice_id"]=make_view("field_m2o",opts)
     opts={
         "win": self.win.subwin(1,80,5,0),
         "key": 3,
         "string": "To Location",
         "name": "location_id",
         "relation": "stock.location",
         "condition": [["type","=","internal"]],
         "data": self.data,
     }
     self.subviews["location_id"]=make_view("field_m2o",opts)
     self.win.addstr(6,0,"4.",curses.A_BOLD|curses.color_pair(2))
     self.win.addstr(6,3,"Add Product")
     self.win.addstr(7,0,"5.",curses.A_BOLD|curses.color_pair(2))
     self.win.addstr(7,3,"Validate Goods Receipt")
     self.win.addstr(9,0,"Received Products:")
     self.win.refresh()
     h,w=self.win.getmaxyx()
     self.list_win=self.win.subwin(h-11,w,11,0)
     self.render_items()
     for n,view in self.subviews.items():
         view.render()
Пример #14
0
 def focus(self):
     while True:
         c = self.win.getch()
         try:
             if c == 27:
                 return
             elif c == ord("1"):
                 self.subviews["location_id"].focus()
                 self.render()
             elif c == ord("2"):
                 if not self.data["location_id"]:
                     raise Exception("Missing location")
                 opts = {
                     "window": self.win,
                     "data": self.data,
                 }
                 v = make_view("add_product", opts)
                 v.render()
                 line_vals = v.focus()
                 if line_vals:
                     line_vals["new_qty"] = line_vals["qty"]
                     with Transaction():
                         line_vals["prev_qty"] = get_model(
                             "stock.balance").get_qty_phys(
                                 self.data["location_id"][0],
                                 line_vals["product_id"][0])
                     self.data["lines"].append(line_vals)
                 self.render()
             elif c == ord("3"):
                 self.validate()
                 return
             elif c == curses.KEY_DOWN:
                 if self.pos < len(self.data["lines"]) - 1:
                     self.pos += 1
                     self.render_items()
             elif c == curses.KEY_UP:
                 if self.pos > 0:
                     self.pos -= 1
                     self.render_items()
             elif c == curses.KEY_BACKSPACE or c == curses.KEY_DC:
                 if self.data["lines"]:
                     del self.data["lines"][self.pos]
                 self.render_items()
         except Exception as e:
             make_view("error", {"message": str(e)}).focus()
             self.render()
Пример #15
0
 def render(self):
     with Transaction():
         self.win.clear()
         curses.curs_set(0)
         self.win.addstr(0, 0, "Netforce Terminal",
                         curses.A_BOLD | curses.color_pair(1))
         self.win.addstr(1, 0, "Add Product", curses.A_BOLD)
         opts = {
             "win": self.win.subwin(1, 80, 3, 0),
             "key": 1,
             "string": "Product",
             "name": "product_id",
             "relation": "product",
             "data": self.data,
             "name_field": "code",
         }
         self.subviews["product_id"] = make_view("field_m2o", opts)
         opts = {
             "win": self.win.subwin(1, 80, 4, 0),
             "key": "2",
             "string": "Lot Number",
             "name": "lot_no",
             "data": self.data,
         }
         self.subviews["lot_no"] = make_view("field_char", opts)
         opts = {
             "win": self.win.subwin(1, 80, 5, 0),
             "key": "3",
             "string": "Qty",
             "name": "qty",
             "data": self.data,
         }
         if self.data["product_id"]:
             prod_id = self.data["product_id"][0]
             prod = get_model("product").browse(prod_id)
             opts["string"] = "Qty (%s)" % prod.uom_id.name
         self.subviews["qty"] = make_view("field_decimal", opts)
         self.win.addstr(6, 0, "4.", curses.A_BOLD | curses.color_pair(2))
         self.win.addstr(6, 3, "Add Product")
         if self.data.get("prev_product_id"):
             self.win.addstr(7, 0, "5.",
                             curses.A_BOLD | curses.color_pair(2))
             self.win.addstr(7, 3, "Select Previous Product")
         for n, view in self.subviews.items():
             view.render()
Пример #16
0
 def render(self):
     with Transaction():
         self.win.clear()
         curses.curs_set(0)
         self.win.addstr(0,0,"Netforce Terminal",curses.A_BOLD|curses.color_pair(1))
         self.win.addstr(1,0,"Add Product",curses.A_BOLD)
         opts={
             "win": self.win.subwin(1,80,3,0),
             "key": 1,
             "string": "Product",
             "name": "product_id",
             "relation": "product",
             "data": self.data,
             "name_field": "code",
         }
         self.subviews["product_id"]=make_view("field_m2o",opts)
         opts={
             "win": self.win.subwin(1,80,4,0),
             "key": "2",
             "string": "Lot Number",
             "name": "lot_no",
             "data": self.data,
         }
         self.subviews["lot_no"]=make_view("field_char",opts)
         opts={
             "win": self.win.subwin(1,80,5,0),
             "key": "3",
             "string": "Qty",
             "name": "qty",
             "data": self.data,
         }
         if self.data["product_id"]:
             prod_id=self.data["product_id"][0]
             prod=get_model("product").browse(prod_id)
             opts["string"]="Qty (%s)"%prod.uom_id.name
         self.subviews["qty"]=make_view("field_decimal",opts)
         self.win.addstr(6,0,"4.",curses.A_BOLD|curses.color_pair(2))
         self.win.addstr(6,3,"Add Product")
         if self.data.get("prev_product_id"):
             self.win.addstr(7,0,"5.",curses.A_BOLD|curses.color_pair(2))
             self.win.addstr(7,3,"Select Previous Product")
         for n,view in self.subviews.items():
             view.render()
Пример #17
0
 def validate(self):
     with Transaction():
         production_id = self.data["production_id"][0]
         production = get_model("production.order").browse(production_id)
         vals = {
             "related_id": "production.order,%d" % production_id,
             "lines": [],
         }
         if not self.data["location_id"]:
             raise Exception("Missing location")
         from_loc_id = self.data["location_id"][0]
         for line in self.data["lines"]:
             lot_no = line["lot_no"]
             if lot_no:
                 res = get_model("stock.lot").search(
                     [["number", "=", lot_no]])
                 if res:
                     lot_id = res[0]
                 else:
                     lot_id = get_model("stock.lot").create(
                         {"number": lot_no})
             else:
                 lot_id = None
             prod_id = line["product_id"][0]
             prod = get_model("product").browse(prod_id)
             line_vals = {
                 "product_id": prod.id,
                 "lot_id": lot_id,
                 "qty": line["qty"],
                 "uom_id": prod.uom_id.id,
                 "location_from_id": from_loc_id,
                 "location_to_id": production.production_location_id.id,
             }
             vals["lines"].append(("create", line_vals))
         if not vals["lines"]:
             raise Exception("Empty goods transfer")
         pick_id = get_model("stock.picking").create(
             vals, context={"pick_type": "internal"})
         get_model("stock.picking").set_done([pick_id])
         pick = get_model("stock.picking").browse(pick_id)
         msg = "Goods transfer %s created successfully" % pick.number
         make_view("message", {"message": msg}).focus()
         self.render()
Пример #18
0
 def focus(self):
     while True:
         c=self.win.getch()
         try:
             if c==27:
                 return
             elif c==ord("1"):
                 self.subviews["location_id"].focus()
                 self.render()
             elif c==ord("2"):
                 if not self.data["location_id"]:
                     raise Exception("Missing location")
                 opts={
                     "window": self.win,
                     "data": self.data,
                 }
                 v=make_view("add_product",opts)
                 v.render()
                 line_vals=v.focus()
                 if line_vals:
                     line_vals["new_qty"]=line_vals["qty"]
                     with Transaction():
                         line_vals["prev_qty"]=get_model("stock.balance").get_qty_phys(self.data["location_id"][0],line_vals["product_id"][0])
                     self.data["lines"].append(line_vals)
                 self.render()
             elif c==ord("3"):
                 self.validate()
                 return
             elif c==curses.KEY_DOWN:
                 if self.pos<len(self.data["lines"])-1:
                     self.pos+=1
                     self.render_items()
             elif c==curses.KEY_UP:
                 if self.pos>0:
                     self.pos-=1
                     self.render_items()
             elif c==curses.KEY_BACKSPACE or c==curses.KEY_DC:
                 if self.data["lines"]:
                     del self.data["lines"][self.pos]
                 self.render_items()
         except Exception as e:
             make_view("error",{"message": str(e)}).focus()
             self.render()
Пример #19
0
 def validate(self):
     with Transaction():
         vals={
             "lines": [],
         }
         if self.data["purchase_id"]:
             vals["related_id"]="purchase.order,%d"%self.data["purchase_id"][0]
         res=get_model("stock.location").search([["type","=","supplier"]],order="id")
         if not res:
             raise Exception("Supplier location not found")
         supp_loc_id=res[0]
         if not self.data["location_id"]:
             raise Exception("Missing location")
         to_loc_id=self.data["location_id"][0]
         for line in self.data["lines"]:
             lot_no=line["lot_no"]
             if lot_no:
                 res=get_model("stock.lot").search([["number","=",lot_no]])
                 if res:
                     lot_id=res[0]
                 else:
                     lot_id=get_model("stock.lot").create({"number":lot_no})
             else:
                 lot_id=None
             prod_id=line["product_id"][0]
             prod=get_model("product").browse(prod_id)
             line_vals={
                 "product_id": prod.id,
                 "lot_id": lot_id,
                 "qty": line["qty"],
                 "uom_id": prod.uom_id.id,
                 "location_from_id": supp_loc_id,
                 "location_to_id": to_loc_id,
             }
             vals["lines"].append(("create",line_vals))
         if not vals["lines"]:
             raise Exception("Empty goods receipt")
         pick_id=get_model("stock.picking").create(vals,context={"pick_type":"in"})
         get_model("stock.picking").set_done([pick_id])
         pick=get_model("stock.picking").browse(pick_id)
         msg="Goods receipt %s created successfully"%pick.number
         make_view("message",{"message":msg}).focus()
         self.render()
Пример #20
0
 def focus(self):
     while True:
         c=self.win.getch()
         try:
             if c==27:
                 return
             elif c==ord("1"):
                 self.subviews["sale_id"].focus()
                 self.render()
             elif c==ord("2"):
                 self.subviews["location_id"].focus()
                 self.render()
             elif c==ord("3"):
                 opts={
                     "window": self.win,
                     "data": self.data,
                 }
                 v=make_view("add_product",opts)
                 v.render()
                 res=v.focus()
                 if res:
                     self.data["lines"].append(res)
                 self.render()
             elif c==ord("4"):
                 self.validate()
                 return
             elif c==curses.KEY_DOWN:
                 if self.pos<len(self.data["lines"])-1:
                     self.pos+=1
                     self.render_items()
             elif c==curses.KEY_UP:
                 if self.pos>0:
                     self.pos-=1
                     self.render_items()
             elif c==curses.KEY_BACKSPACE or c==curses.KEY_DC:
                 if self.data["lines"]:
                     del self.data["lines"][self.pos]
                 self.render_items()
         except Exception as e:
             make_view("error",{"message": str(e)}).focus()
             self.render()
Пример #21
0
 def focus(self):
     while True:
         c=self.win.getch()
         try:
             if c==27:
                 return
             elif c==ord("1"):
                 self.subviews["production_id"].focus()
                 self.render()
             elif c==ord("2"):
                 self.subviews["location_id"].focus()
                 self.render()
             elif c==ord("3"):
                 opts={
                     "window": self.win,
                     "data": self.data,
                 }
                 v=make_view("add_product",opts)
                 v.render()
                 res=v.focus()
                 if res:
                     self.data["lines"].append(res)
                 self.render()
             elif c==ord("4"):
                 self.validate()
                 return
             elif c==curses.KEY_DOWN:
                 if self.pos<len(self.data["lines"])-1:
                     self.pos+=1
                     self.render_items()
             elif c==curses.KEY_UP:
                 if self.pos>0:
                     self.pos-=1
                     self.render_items()
             elif c==curses.KEY_BACKSPACE or c==curses.KEY_DC:
                 if self.data["lines"]:
                     del self.data["lines"][self.pos]
                 self.render_items()
         except Exception as e:
             make_view("error",{"message": str(e)}).focus()
             self.render()
Пример #22
0
def main(stdscr):
    curses.init_pair(1, curses.COLOR_BLUE, curses.COLOR_BLACK)
    curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_BLACK)
    curses.init_pair(3, curses.COLOR_WHITE, curses.COLOR_RED)
    curses.init_pair(4, curses.COLOR_WHITE, curses.COLOR_BLUE)
    set_stdscr(stdscr)
    opts={
        "win": stdscr,
    }
    v=make_view("menu",opts)
    v.render()
    v.focus()
Пример #23
0
def main(stdscr):
    curses.init_pair(1, curses.COLOR_BLUE, curses.COLOR_BLACK)
    curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_BLACK)
    curses.init_pair(3, curses.COLOR_WHITE, curses.COLOR_RED)
    curses.init_pair(4, curses.COLOR_WHITE, curses.COLOR_BLUE)
    set_stdscr(stdscr)
    opts = {
        "win": stdscr,
    }
    v = make_view("menu", opts)
    v.render()
    v.focus()
Пример #24
0
 def validate(self):
     with Transaction():
         production_id=self.data["production_id"][0]
         production=get_model("production.order").browse(production_id)
         vals={
             "related_id": "production.order,%d"%production_id,
             "lines": [],
         }
         if not self.data["location_id"]:
             raise Exception("Missing location")
         from_loc_id=self.data["location_id"][0]
         for line in self.data["lines"]:
             lot_no=line["lot_no"]
             if lot_no:
                 res=get_model("stock.lot").search([["number","=",lot_no]])
                 if res:
                     lot_id=res[0]
                 else:
                     lot_id=get_model("stock.lot").create({"number":lot_no})
             else:
                 lot_id=None
             prod_id=line["product_id"][0]
             prod=get_model("product").browse(prod_id)
             line_vals={
                 "product_id": prod.id,
                 "lot_id": lot_id,
                 "qty": line["qty"],
                 "uom_id": prod.uom_id.id,
                 "location_from_id": from_loc_id,
                 "location_to_id": production.production_location_id.id,
             }
             vals["lines"].append(("create",line_vals))
         if not vals["lines"]:
             raise Exception("Empty goods transfer")
         pick_id=get_model("stock.picking").create(vals,context={"pick_type":"internal"})
         get_model("stock.picking").set_done([pick_id])
         pick=get_model("stock.picking").browse(pick_id)
         msg="Goods transfer %s created successfully"%pick.number
         make_view("message",{"message":msg}).focus()
         self.render()
Пример #25
0
 def render(self):
     self.win.clear()
     curses.curs_set(0)
     self.win.addstr(0, 0, "Netforce Terminal",
                     curses.A_BOLD | curses.color_pair(1))
     self.win.addstr(1, 0, "Return To Supplier", curses.A_BOLD)
     opts = {
         "win": self.win.subwin(1, 80, 3, 0),
         "key": 1,
         "string": "Purchase Order",
         "name": "purchase_id",
         "relation": "purchase.order",
         "condition": [["state", "=", "confirmed"]],
         "data": self.data,
     }
     self.subviews["purchase_id"] = make_view("field_m2o", opts)
     opts = {
         "win": self.win.subwin(1, 80, 4, 0),
         "key": 2,
         "string": "From Location",
         "name": "location_id",
         "relation": "stock.location",
         "condition": [["type", "=", "internal"]],
         "data": self.data,
     }
     self.subviews["location_id"] = make_view("field_m2o", opts)
     self.win.addstr(5, 0, "3.", curses.A_BOLD | curses.color_pair(2))
     self.win.addstr(5, 3, "Add Product")
     self.win.addstr(6, 0, "4.", curses.A_BOLD | curses.color_pair(2))
     self.win.addstr(6, 3, "Validate Goods Issue")
     self.win.addstr(8, 0, "Returned Products:")
     self.win.refresh()
     h, w = self.win.getmaxyx()
     self.list_win = self.win.subwin(h - 10, w, 10, 0)
     self.render_items()
     for n, view in self.subviews.items():
         view.render()
Пример #26
0
 def render(self):
     self.win.clear()
     curses.curs_set(0)
     self.win.addstr(0,0,"Netforce Terminal",curses.A_BOLD|curses.color_pair(1))
     self.win.addstr(1,0,"Receive From Production",curses.A_BOLD)
     opts={
         "win": self.win.subwin(1,80,3,0),
         "key": 1,
         "string": "Production Order",
         "name": "production_id",
         "relation": "production.order",
         "condition": [["state","=","in_progress"]],
         "data": self.data,
     }
     self.subviews["production_id"]=make_view("field_m2o",opts)
     opts={
         "win": self.win.subwin(1,80,4,0),
         "key": 2,
         "string": "To Location",
         "name": "location_id",
         "relation": "stock.location",
         "condition": [["type","=","internal"]],
         "data": self.data,
     }
     self.subviews["location_id"]=make_view("field_m2o",opts)
     self.win.addstr(5,0,"3.",curses.A_BOLD|curses.color_pair(2))
     self.win.addstr(5,3,"Add Product")
     self.win.addstr(6,0,"4.",curses.A_BOLD|curses.color_pair(2))
     self.win.addstr(6,3,"Validate Goods Transfer")
     self.win.addstr(8,0,"Received Products:")
     self.win.refresh()
     h,w=self.win.getmaxyx()
     self.list_win=self.win.subwin(h-10,w,10,0)
     self.render_items()
     for n,view in self.subviews.items():
         view.render()
Пример #27
0
 def render(self):
     with Transaction():
         self.win.clear()
         curses.curs_set(1)
         self.win.addstr(0,0,"Netforce Terminal",curses.A_BOLD|curses.color_pair(1))
         s=get_model(self.model)._string
         self.win.addstr(1,0,"Select %s"%s,curses.A_BOLD)
         self.win.addstr(3,0,"Search:")
         opts={
             "win": self.win.subwin(1,21,3,8),
             "cols": 20,
         }
         self.tb=make_view("textbox",opts)
         h,w=self.win.getmaxyx()
         self.list_win=self.win.subwin(h-5,w,5,0)
         self.load_items()
         self.render_items()
Пример #28
0
 def render(self):
     with Transaction():
         self.win.clear()
         curses.curs_set(1)
         self.win.addstr(0, 0, "Netforce Terminal",
                         curses.A_BOLD | curses.color_pair(1))
         s = get_model(self.model)._string
         self.win.addstr(1, 0, "Select %s" % s, curses.A_BOLD)
         self.win.addstr(3, 0, "Search:")
         opts = {
             "win": self.win.subwin(1, 21, 3, 8),
             "cols": 20,
         }
         self.tb = make_view("textbox", opts)
         h, w = self.win.getmaxyx()
         self.list_win = self.win.subwin(h - 5, w, 5, 0)
         self.load_items()
         self.render_items()
Пример #29
0
 def focus(self):
     opts={
         "model": self.relation,
         "condition": self.condition, 
     }
     v=make_view("select_item",opts)
     v.render()
     res=v.focus()
     with Transaction():
         if res:
             obj_id=res["select_id"]
             if obj_id:
                 if self.name_field:
                     n=get_model(self.relation).read([obj_id],[self.name_field])[0][self.name_field]
                 else:
                     n=get_model(self.relation).name_get([obj_id])[0][1]
                 val=(obj_id,n)
             else:
                 val=None
             self.data[self.name]=val
Пример #30
0
 def focus(self):
     opts = {
         "model": self.relation,
         "condition": self.condition,
     }
     v = make_view("select_item", opts)
     v.render()
     res = v.focus()
     with Transaction():
         if res:
             obj_id = res["select_id"]
             if obj_id:
                 if self.name_field:
                     n = get_model(self.relation).read(
                         [obj_id], [self.name_field])[0][self.name_field]
                 else:
                     n = get_model(self.relation).name_get([obj_id])[0][1]
                 val = (obj_id, n)
             else:
                 val = None
             self.data[self.name] = val
Пример #31
0
 def focus(self):
     while True:
         c = self.win.getch()
         if c == ord("1"):
             opts = {
                 "win": self.win,
             }
             v = make_view("check_stock", opts)
             v.render()
             v.focus()
             self.render()
         elif c == ord("2"):
             opts = {
                 "win": self.win,
             }
             v = make_view("stock_count", opts)
             v.render()
             v.focus()
             self.render()
         elif c == ord("3"):
             opts = {
                 "win": self.win,
             }
             v = make_view("receive_sup", opts)
             v.render()
             v.focus()
             self.render()
         elif c == ord("4"):
             opts = {
                 "win": self.win,
             }
             v = make_view("return_sup", opts)
             v.render()
             v.focus()
             self.render()
         elif c == ord("5"):
             opts = {
                 "win": self.win,
             }
             v = make_view("issue_cust", opts)
             v.render()
             v.focus()
             self.render()
         elif c == ord("6"):
             opts = {
                 "win": self.win,
             }
             v = make_view("return_cust", opts)
             v.render()
             v.focus()
             self.render()
         elif c == ord("7"):
             opts = {
                 "win": self.win,
             }
             v = make_view("transfer_mfg", opts)
             v.render()
             v.focus()
             self.render()
         elif c == ord("8"):
             opts = {
                 "win": self.win,
             }
             v = make_view("receive_mfg", opts)
             v.render()
             v.focus()
             self.render()
         elif c == ord("9"):
             opts = {
                 "win": self.win,
             }
             v = make_view("transfer", opts)
             v.render()
             v.focus()
             self.render()
         elif c == ord("0"):
             return
Пример #32
0
 def focus(self):
     while True:
         c=self.win.getch()
         if c==ord("1"):
             opts={
                 "win": self.win,
             }
             v=make_view("check_stock",opts)
             v.render()
             v.focus()
             self.render()
         elif c==ord("2"):
             opts={
                 "win": self.win,
             }
             v=make_view("stock_count",opts)
             v.render()
             v.focus()
             self.render()
         elif c==ord("3"):
             opts={
                 "win": self.win,
             }
             v=make_view("receive_sup",opts)
             v.render()
             v.focus()
             self.render()
         elif c==ord("4"):
             opts={
                 "win": self.win,
             }
             v=make_view("return_sup",opts)
             v.render()
             v.focus()
             self.render()
         elif c==ord("5"):
             opts={
                 "win": self.win,
             }
             v=make_view("issue_cust",opts)
             v.render()
             v.focus()
             self.render()
         elif c==ord("6"):
             opts={
                 "win": self.win,
             }
             v=make_view("return_cust",opts)
             v.render()
             v.focus()
             self.render()
         elif c==ord("7"):
             opts={
                 "win": self.win,
             }
             v=make_view("transfer_mfg",opts)
             v.render()
             v.focus()
             self.render()
         elif c==ord("8"):
             opts={
                 "win": self.win,
             }
             v=make_view("receive_mfg",opts)
             v.render()
             v.focus()
             self.render()
         elif c==ord("9"):
             opts={
                 "win": self.win,
             }
             v=make_view("transfer",opts)
             v.render()
             v.focus()
             self.render()
         elif c==ord("0"):
             return