12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- # -*- coding: utf-8 -*-
- from openerp.http import request as r
- def get_dashboard_objective_widget():
- user_store = r.env.user.store_id.id
- query = '''
- SELECT user_id,
- store_id,
- date,
- sale_objective
- FROM salesman_objective
- WHERE TO_CHAR(date,'YYYY-MM') = TO_CHAR(current_date,'YYYY-MM')
- AND store_id = ''' + str(user_store) + '''
- '''
- r.cr.execute(query)
- return [
- {
- 'user_id': j[0],
- 'store_id': j[1],
- 'date': j[2],
- 'sale_objective': j[3],
- } for j in r.cr.fetchall()
- ]
- def get_own_objective():
- user_id = r.env.user.id
- user_store = r.env.user.store_id.id
- query = '''
- SELECT user_id,
- store_id,
- date,
- sale_objective
- FROM salesman_objective
- WHERE TO_CHAR(date,'YYYY-MM') = TO_CHAR(current_date,'YYYY-MM')
- AND store_id = ''' + str(user_store) + ''' AND user_id = ''' + str(user_id) + '''
- '''
- r.cr.execute(query)
- return [
- {
- 'user_id': j[0],
- 'store_id': j[1],
- 'date': j[2],
- 'sale_objective': j[3],
- } for j in r.cr.fetchall()
- ]
|