def get_goods(cache={}): if not cache: for g in get_by_type(Good): gid = g._id.rpartition('-')[2] cache[gid] = g return cache
def prepare_customers_selector(self): self.customers_completion = Completion(gtk.ListStore(str, int, object)) self.customers_completion.on_fill = self.fill_customers self.customers_completion.on_select = self.select_customer column = self.customers_completion.column cell = gtk.CellRendererText() column.pack_start(cell) column.set_attributes(cell, text=0, weight=1) self.customers_completion.attach_to_entry(self.customer_selector) self.customers = [] for c in get_by_type(Customer): for p in c.points: self.customers.append((c.name + ' ' + p['name'], c.get_point_id(p['id']))) self.customers.sort(key=lambda r:r[0]) self.today_customers = {}
def make_goods(): db = Good.get_db() db.bulk_delete(get_by_type(Good).all(), True) db.ensure_full_commit() group_tags = {'1':'bread', '2':'cake', '3':'good'} cat = {} for id_cat, name, id_group in traverse('TKategories.csv'): cat[id_cat] = name, id_group for id_cat, name, weight, real_time, id, visible in traverse('TGoods.csv'): good = Good() good._id = 'g-' + id if visible == '0': good.hidden = True good.weight = float(weight) good.sell_time = tounicode(real_time) good.name = u' '.join(map(unicode.strip, map(tounicode, [cat[id_cat][0], name]))) good.tags = [group_tags[cat[id_cat][1]]] good.save()