product_template.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # -*- coding: utf-8 -*-
  2. from openerp.http import request as r
  3. def get_product_template_inmobiliaria():
  4. query = '''
  5. SELECT
  6. tpt.id,
  7. tpt.name,
  8. tpt.type,
  9. tpt.comision_vendedor,
  10. tpt.comision_inmobiliaria,
  11. tpt.comision_total,
  12. tpt.t_propietario,
  13. partner.name,
  14. tpt.t_tamanho,
  15. tpt.t_direccion,
  16. tpt.t_descripcion,
  17. tpt.list_price,
  18. tpt.categ_id,
  19. tpt.t_estado,
  20. estado.name
  21. FROM product_template AS tpt
  22. LEFT JOIN res_partner AS partner
  23. ON partner.id = tpt.t_propietario
  24. LEFT JOIN property_state AS estado
  25. ON estado.id = tpt.t_estado
  26. WHERE tpt.active = true AND tpt.sale_ok = true
  27. '''
  28. r.cr.execute(query)
  29. return [
  30. {
  31. 'id': j[0],
  32. 'name': j[1],
  33. 'type': j[2],
  34. 'comision_vendedor': j[3],
  35. 'comision_inmobiliaria.': j[4],
  36. 'comision_total': j[5],
  37. 'propietario_id': j[6],
  38. 'propietario_name': j[7],
  39. 'tamanho': j[8],
  40. 'direccion': j[9],
  41. 'descripcion': j[10],
  42. 'precio': j[11],
  43. 'categoria': j[12],
  44. 'estado_id': j[13],
  45. 'estado_name': j[14],
  46. } for j in r.cr.fetchall()
  47. ]
  48. def get_property_state_inmobiliaria():
  49. query = '''
  50. SELECT
  51. state.id,
  52. state.name
  53. FROM property_state AS state
  54. '''
  55. r.cr.execute(query)
  56. return [
  57. {
  58. 'id': j[0],
  59. 'name': j[1],
  60. } for j in r.cr.fetchall()
  61. ]