def get_totals():
        response.generic_patterns = ['json']
        query=(db.item.id==db.sale.id_items)
        total_price = 0
        total_cost = 0
        total_items = 0
        rows = 
db(query).select(db.item.base_price,db.item.price,db.sale.total_items)
        for r in rows:
                total_price += r.item.price * r.sale.total_items
                total_cost += r.item.base_price * r.sale.total_items
                total_items += r.sale.total_items
        profit =  total_price - total_cost

        return dict(total_price = str(total_price) , total_profit =
str(profit) , total_items = str(total_items))

This is waht i am doing. and i am getting this :

Traceback (most recent call last):
  File 
"/base/data/home/apps/s~herspos/1.354149753338895814/gluon/restricted.py",
line 192, in restricted
    exec ccode in environment
  File 
"/base/data/home/apps/s~herspos/1.354149753338895814/applications/HersPOS/controllers/default.py:get_totals",
line 218, in <module>
  File "/base/data/home/apps/s~herspos/1.354149753338895814/gluon/globals.py",
line 145, in <lambda>
    self._caller = lambda f: f()
  File 
"/base/data/home/apps/s~herspos/1.354149753338895814/applications/HersPOS/controllers/default.py:get_totals",
line 168, in get_totals
  File "/base/data/home/apps/s~herspos/1.354149753338895814/gluon/dal.py",
line 5481, in select
    return self.db._adapter.select(self.query,fields,attributes)
  File "/base/data/home/apps/s~herspos/1.354149753338895814/gluon/dal.py",
line 3292, in select
    (items, tablename, fields) = self.select_raw(query,fields,attributes)
  File "/base/data/home/apps/s~herspos/1.354149753338895814/gluon/dal.py",
line 3240, in select_raw
    tablename = self.get_table(query)
  File "/base/data/home/apps/s~herspos/1.354149753338895814/gluon/dal.py",
line 1052, in get_table
    raise RuntimeError, "Too many tables selected"
RuntimeError: Too many tables selected

How to not use 2 tables to make a relationship ? Just no relationship
at all GRR! ?

Reply via email to