brmbar v3 ItemEdit: Support for adding barcodes to items

This commit is contained in:
Petr Baudis 2012-09-26 03:32:11 +02:00
parent 4e1681cb94
commit ffd0ca29c9
2 changed files with 25 additions and 4 deletions

View file

@ -102,6 +102,10 @@ class ShopAdapter(QtCore.QObject):
def itemList(self):
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")
shop = brmbar.Shop.new_with_defaults(db)
currency = shop.currency

View file

@ -10,6 +10,24 @@ Item {
property variant dbid: ""
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 {
id: item_name
x: 65
@ -138,12 +156,11 @@ Item {
text: "Restock"
}
BarButton {
id: add_barcode
BarTextHint {
x: 65
y: 476
width: 360
text: "Add Barcode"
hint_goal: "Add barcode:"
hint_action: "Scan item now"
}
BarButton {