mirror of
https://github.com/brmlab/brmbar.git
synced 2025-06-07 21:04:00 +02:00
brmbar v3 ItemEdit: Support for adding barcodes to items
This commit is contained in:
parent
4e1681cb94
commit
ffd0ca29c9
2 changed files with 25 additions and 4 deletions
|
@ -102,6 +102,10 @@ class ShopAdapter(QtCore.QObject):
|
||||||
def itemList(self):
|
def itemList(self):
|
||||||
return [ self.acct_inventory_map(a) for a in shop.account_list("inventory") ]
|
return [ self.acct_inventory_map(a) for a in shop.account_list("inventory") ]
|
||||||
|
|
||||||
|
@QtCore.Slot('QVariant', 'QVariant', result='QVariant')
|
||||||
|
def addBarcode(self, dbid, barcode):
|
||||||
|
return brmbar.Account.load(db, id = dbid).add_barcode(barcode)
|
||||||
|
|
||||||
db = psycopg2.connect("dbname=brmbar")
|
db = psycopg2.connect("dbname=brmbar")
|
||||||
shop = brmbar.Shop.new_with_defaults(db)
|
shop = brmbar.Shop.new_with_defaults(db)
|
||||||
currency = shop.currency
|
currency = shop.currency
|
||||||
|
|
|
@ -10,6 +10,24 @@ Item {
|
||||||
property variant dbid: ""
|
property variant dbid: ""
|
||||||
property variant info: ""
|
property variant info: ""
|
||||||
|
|
||||||
|
property string barcode: ""
|
||||||
|
|
||||||
|
BarcodeInput {
|
||||||
|
color: "#00ff00" /* just for debugging */
|
||||||
|
onAccepted: {
|
||||||
|
var acct = shop.barcodeInput(text)
|
||||||
|
barcode = text
|
||||||
|
text = ""
|
||||||
|
if (typeof(acct) != "undefined") {
|
||||||
|
status_text.setStatus("Existing barcode: " + acct.name, "#ff4444")
|
||||||
|
/* TODO: Allow override. */
|
||||||
|
return
|
||||||
|
}
|
||||||
|
shop.addBarcode(dbid, barcode)
|
||||||
|
status_text.setStatus("Barcode added.", "#ffff7c")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: item_name
|
id: item_name
|
||||||
x: 65
|
x: 65
|
||||||
|
@ -138,12 +156,11 @@ Item {
|
||||||
text: "Restock"
|
text: "Restock"
|
||||||
}
|
}
|
||||||
|
|
||||||
BarButton {
|
BarTextHint {
|
||||||
id: add_barcode
|
|
||||||
x: 65
|
x: 65
|
||||||
y: 476
|
y: 476
|
||||||
width: 360
|
hint_goal: "Add barcode:"
|
||||||
text: "Add Barcode"
|
hint_action: "Scan item now"
|
||||||
}
|
}
|
||||||
|
|
||||||
BarButton {
|
BarButton {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue