models.py 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. # -*- coding: utf-8 -*-
  2. from openerp import models, fields, api
  3. class RepairWorkorder(models.Model):
  4. _inherit = 'repair.workorderimproved'
  5. @api.model
  6. def getRepairWorkorder(self,domain):
  7. RepairWorkorder = self.env['repair.workorderimproved'].search(domain)
  8. values = []
  9. for workorder in RepairWorkorder:
  10. try:
  11. street = workorder.partner_id.street
  12. except Exception as e:
  13. street = ''
  14. values.append({
  15. # ID
  16. 'id': workorder.id,
  17. # WORKORDER INFO
  18. 'name': workorder.name or "",
  19. 'user_name': workorder.user_id.name or "",
  20. 'responsable': workorder.responsable or "",
  21. 'movil': workorder.movil or "",
  22. 'name_obra': workorder.name_obra or "",
  23. 'nro_factura': workorder.nro_factura or "",
  24. 'name_local': workorder.name_local or "",
  25. 'contacto_obra': workorder.contacto_obra or "",
  26. 'causes': workorder.causes or "",
  27. 'order_date': workorder.order_date or "",
  28. 'planned_start_date': workorder.planned_start_date or "",
  29. 'planned_end_date': workorder.planned_end_date or "",
  30. 'recommendations': workorder.recommendations or "",
  31. 'emergente': workorder.emergente or "",
  32. 'actions': workorder.actions or "",
  33. # PARTNER INFO
  34. 'partner_id': workorder.partner_id.id or "",
  35. 'partner_name': workorder.partner_id.name or "",
  36. 'partner_ruc': workorder.partner_id.ruc or "",
  37. 'partner_address': street or "",
  38. 'partner_phone': workorder.partner_id.phone or "",
  39. 'partner_mobile': workorder.partner_id.mobile or "",
  40. # COMPANY INFO
  41. 'company_id': workorder.user_id.company_id.id or "",
  42. 'company_name': workorder.user_id.company_id.name or "",
  43. 'company_logo': workorder.user_id.company_id.logo or "",
  44. 'company_address': workorder.user_id.company_id.street2 or "",
  45. 'company_phone': workorder.user_id.company_id.phone or "",
  46. 'vat': workorder.user_id.company_id.vat or "",
  47. })
  48. return values
  49. class RepairWorkorderLine(models.Model):
  50. _inherit = 'repair.workorderimproved.line'
  51. @api.model
  52. def getRepairWorkorderLine(self,domain):
  53. RepairWorkorderLine = self.env['repair.workorderimproved.line'].search(domain)
  54. values = []
  55. for line in RepairWorkorderLine:
  56. values.append({
  57. # ID
  58. 'id': line.id,
  59. # LINE INFO
  60. 'workorder_id': line.workorder_id.id,
  61. 'description': line.description or "",
  62. 'quantity': line.quantity or "",
  63. 'brand': line.brand or "",
  64. 'number': line.number or "",
  65. })
  66. return values
  67. class RepairPedidosorderLine(models.Model):
  68. _inherit = 'repair.pedidosorderimproved.line'
  69. @api.model
  70. def getRepairPedidosorderLine(self,domain):
  71. RepairPedidosorderLine = self.env['repair.pedidosorderimproved.line'].search(domain)
  72. values = []
  73. for line in RepairPedidosorderLine:
  74. values.append({
  75. # ID
  76. 'id': line.id,
  77. # LINE INFO
  78. 'workorder_id': line.workorder_id.id,
  79. 'description': line.description or "",
  80. 'quantity': line.quantity or "",
  81. 'brand': line.brand or "",
  82. 'number': line.number or "",
  83. })
  84. return values
  85. class RepairResumenorderLine(models.Model):
  86. _inherit = 'repair.resumenorderimproved.line'
  87. @api.model
  88. def getRepairResumenorderLine(self,domain):
  89. RepairResumenorderLine = self.env['repair.resumenorderimproved.line'].search(domain)
  90. values = []
  91. for line in RepairResumenorderLine:
  92. values.append({
  93. # ID
  94. 'id': line.id,
  95. # LINE INFO
  96. 'workorder_id': line.workorder_id.id,
  97. 'description': line.description or "",
  98. })
  99. return values
  100. class RepairCalidadorderLine(models.Model):
  101. _inherit = 'repair.calidadorderimproved.line'
  102. @api.model
  103. def getRepairCalidadorderLine(self,domain):
  104. RepairCalidadorderLine = self.env['repair.calidadorderimproved.line'].search(domain)
  105. values = []
  106. for line in RepairCalidadorderLine:
  107. values.append({
  108. # ID
  109. 'id': line.id,
  110. # LINE INFO
  111. 'workorder_id': line.workorder_id.id,
  112. 'description': line.description or "",
  113. 'brand': line.brand or "",
  114. 'number': line.number or "",
  115. })
  116. return values
  117. class RepairSugerenciaorderLine(models.Model):
  118. _inherit = 'repair.sugerenciaorderimproved.line'
  119. @api.model
  120. def getRepairSugerenciaorderLine(self,domain):
  121. RepairSugerenciaorderLine = self.env['repair.sugerenciaorderimproved.line'].search(domain)
  122. values = []
  123. for line in RepairSugerenciaorderLine:
  124. values.append({
  125. # ID
  126. 'id': line.id,
  127. # LINE INFO
  128. 'workorder_id': line.workorder_id.id,
  129. 'description': line.description or "",
  130. })
  131. return values
  132. class RepairWorkorderConsumed(models.Model):
  133. _inherit = 'repair.workorderimproved.consumed'
  134. @api.model
  135. def getRepairWorkorderConsumed(self,domain):
  136. RepairWorkorderConsumed = self.env['repair.workorderimproved.consumed'].search(domain)
  137. values = []
  138. for line in RepairWorkorderConsumed:
  139. values.append({
  140. # ID
  141. 'id': line.id,
  142. # LINE INFO
  143. 'workorder_id': line.workorder_id.id,
  144. 'product_id':[
  145. line.product_id.id,
  146. line.product_id.name,
  147. ],
  148. 'description': line.description or "",
  149. 'quantity': line.quantity or "",
  150. 'price_unit': line.price_unit or "",
  151. 'subtotal': line.subtotal or "",
  152. })
  153. return values