models.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. # -*- coding: utf-8 -*-
  2. from openerp import models, fields, api
  3. class AccountInvoice(models.Model):
  4. _inherit = 'account.invoice'
  5. @api.model
  6. def getAccountInvoicePagare(self,domain):
  7. AccountInvoice = self.env['account.invoice'].search(domain)
  8. values = []
  9. for invoice in AccountInvoice:
  10. values.append({
  11. # ID
  12. 'id': invoice.id,
  13. 'number': invoice.number,
  14. 'origin': invoice.origin,
  15. 'date_invoice': invoice.date_invoice or "",
  16. 'user_name': invoice.user_id.name,
  17. 'amount_untaxed': invoice.amount_untaxed,
  18. 'amount_tax': invoice.amount_untaxed,
  19. 'amount_total': invoice.amount_total,
  20. 'date_due': invoice.date_due or "",
  21. # PARTNER INFO
  22. 'partner_id':[{
  23. 'id': invoice.partner_id.id,
  24. 'name': invoice.partner_id.name or "",
  25. 'ruc': invoice.partner_id.ruc or "",
  26. 'address': invoice.partner_id.street or "",
  27. 'city': invoice.partner_id.city or "",
  28. 'barrio': invoice.partner_id.street2 or "",
  29. 'email': invoice.partner_id.email,
  30. 'estado_civil': invoice.partner_id.estado_civil or "",
  31. 'phone': invoice.partner_id.phone,
  32. 'mobile': invoice.partner_id.mobile,
  33. 'name_deudor': invoice.partner_id.name_deudor or "",
  34. 'cin_deudor': invoice.partner_id.cin_deudor or "",
  35. 'tel_deudor': invoice.partner_id.tel_deudor or "",
  36. 'dir_deudor': invoice.partner_id.dir_deudor or "",
  37. }],
  38. # COMPANY INFO
  39. 'company_id': [{
  40. 'id':invoice.user_id.company_id.id,
  41. 'name': invoice.user_id.company_id.name,
  42. 'logo': invoice.user_id.company_id.logo,
  43. 'phone': invoice.user_id.company_id.phone,
  44. }],
  45. # CURRENCY INFO
  46. 'currency_id':[{
  47. 'id': invoice.currency_id.id,
  48. 'name': invoice.currency_id.name,
  49. 'symbol': invoice.currency_id.symbol,
  50. 'thousands_separator': invoice.currency_id.thousands_separator,
  51. 'decimal_separator': invoice.currency_id.decimal_separator,
  52. 'decimal_places': invoice.currency_id.decimal_places,
  53. 'symbol_position': invoice.currency_id.symbol,
  54. }],
  55. })
  56. return values
  57. # @api.model
  58. # def getAccountInvoicePagareQuota(self,domain):
  59. # AccountInvoice = self.env['account.invoice'].search(domain)
  60. # AccountMoveLine = self.env['account.move.line'].search([('move_id','=',AccountInvoice.number),('debit','>',0),('date_maturity','!=', False)],order='date_maturity')
  61. #
  62. # i = 1
  63. # x = len(AccountMoveLine)
  64. # values = []
  65. #
  66. # for line in AccountMoveLine:
  67. # amount = 0
  68. # value = 0
  69. # state = 'No pagado'
  70. # if(line.reconcile_ref != False):
  71. # if(line.amount_residual == 0):
  72. # state = 'Pagado'
  73. #
  74. # if(line.amount_residual > 0):
  75. # value = line.debit - line.amount_residual
  76. # state = 'Amortizado'
  77. #
  78. # values.append({
  79. # 'date': line.date_maturity,
  80. # 'name': 'Cuota ' + str(i) + ' / ' + str(x),
  81. # 'state': state,
  82. # 'value': value,
  83. # 'amount': line.debit,
  84. # 'residual': line.amount_residual,
  85. # 'tot_cuota': str(x),
  86. # })
  87. # i = i + 1
  88. #
  89. # return values
  90. class AccountInvoiceLine(models.Model):
  91. _inherit = 'account.invoice.line'
  92. @api.model
  93. def getAccountInvoiceLinePagare(self,domain):
  94. AccountInvoiceLine = self.env['account.invoice.line'].search(domain)
  95. values = []
  96. for line in AccountInvoiceLine:
  97. values.append({
  98. 'id': line.id,
  99. 'name': line.name,
  100. 'quantity': line.quantity,
  101. 'price_unit': line.price_unit,
  102. 'price_subtotal': line.price_subtotal,
  103. })
  104. return values