Work on native gui. Display records and add missing tasks and measurements.
This commit is contained in:
+30
-1
@@ -11,6 +11,7 @@ class ProvisionsView(View):
|
||||
|
||||
def __init__(self, context):
|
||||
super().__init__(context, _("Provisions"), "provisions.ui")
|
||||
self.context = context
|
||||
|
||||
self.prov = provision.Provision(context.db) # current record
|
||||
self.newrecord = False
|
||||
@@ -21,7 +22,7 @@ class ProvisionsView(View):
|
||||
sql = (
|
||||
"SELECT p.provid, p.provname, p.number, p.unit, p.storedate, p.shelflife "
|
||||
"FROM provisions AS p LEFT OUTER JOIN storage AS s USING (sid) "
|
||||
"WHERE s.vid=%s"
|
||||
"WHERE s.vid=%s OR vid IS NULL"
|
||||
)
|
||||
self.db.dcur.execute(sql, (context.vessel.vid,))
|
||||
for row in self.db.dcur.fetchall():
|
||||
@@ -55,7 +56,18 @@ class ProvisionsView(View):
|
||||
self.topwidget.set_visible_child(self.box['prov_edit'])
|
||||
|
||||
def on_but_detail_clicked(self, widget):
|
||||
provid = treeview.get_value(self.tree['provisions'], 0)
|
||||
self.prov.load(provid)
|
||||
self.display_record()
|
||||
self.topwidget.set_visible_child(self.box['prov_detail'])
|
||||
self.button['close'].grab_focus()
|
||||
|
||||
def on_tvw_provisions_row_activated(self, widget, path, column):
|
||||
provid = treeview.get_value(widget, 0)
|
||||
self.prov.load(provid)
|
||||
self.display_record()
|
||||
self.topwidget.set_visible_child(self.box['prov_detail'])
|
||||
self.button['close'].grab_focus()
|
||||
|
||||
# buttons on detail page
|
||||
# edit2 uses edit callback
|
||||
@@ -71,3 +83,20 @@ class ProvisionsView(View):
|
||||
|
||||
def on_but_cancel_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['provisions'])
|
||||
|
||||
def display_record(self):
|
||||
print(self.prov)
|
||||
self.label['name'].set_text(self.prov.provname)
|
||||
self.label['category'].set_text(str(self.prov.provcat))
|
||||
self.label['storage'].set_text(str(self.prov.sid))
|
||||
self.label['box'].set_text(str(self.prov.boxid))
|
||||
self.label['number'].set_text(str(self.prov.number))
|
||||
self.label['unit'].set_text(str(self.prov.unit))
|
||||
self.label['target'].set_text(str(self.prov.target))
|
||||
self.label['weight'].set_text(self.format_float(self.prov.weight, 2, suffix='kg'))
|
||||
self.label['weight_net'].set_text(self.format_float(self.prov.weight_net, 2, suffix='kg'))
|
||||
self.label['price'].set_text(self.format_float(self.prov.price, 2, suffix='€'))
|
||||
self.label['remarks'].set_text(self.prov.remarks or '')
|
||||
|
||||
def edit_record(self):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user