product_template.py 1.7 KB

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