product_template.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. tpt.t_nro
  22. FROM product_template AS tpt
  23. LEFT JOIN res_partner AS partner
  24. ON partner.id = tpt.t_propietario
  25. LEFT JOIN property_state AS estado
  26. ON estado.id = tpt.t_estado
  27. WHERE tpt.active = true AND tpt.sale_ok = true
  28. '''
  29. r.cr.execute(query)
  30. return [
  31. {
  32. 'id': j[0],
  33. 'name': j[1],
  34. 'type': j[2],
  35. 'comision_vendedor': j[3],
  36. 'comision_inmobiliaria.': j[4],
  37. 'comision_total': j[5],
  38. 'propietario_id': j[6],
  39. 'propietario_name': j[7],
  40. 'tamanho': j[8],
  41. 'direccion': j[9],
  42. 'descripcion': j[10],
  43. 'precio': j[11],
  44. 'categoria': j[12],
  45. 'estado_id': j[13],
  46. 'estado_name': j[14],
  47. 't_nro': j[15],
  48. } for j in r.cr.fetchall()
  49. ]
  50. def get_property_state_inmobiliaria():
  51. query = '''
  52. SELECT
  53. state.id,
  54. state.name
  55. FROM property_state AS state
  56. '''
  57. r.cr.execute(query)
  58. return [
  59. {
  60. 'id': j[0],
  61. 'name': j[1],
  62. } for j in r.cr.fetchall()
  63. ]