account_invoice_move_line.py 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. # -*- coding: utf-8 -*-
  2. from openerp import models, fields, api
  3. from openerp.osv import osv
  4. class invoice_interes(models.Model):
  5. _inherit = "account.invoice"
  6. _name = "account.invoice"
  7. move_line_debt = fields.One2many('account.move.line', inverse_name="invoice", string="id Move line", domain=['&', ('reconcile_id', '=', False), '&', ('account_id.active','=', True), '&', ('account_id.type', '=', 'receivable'), ('state', '!=', 'draft')])
  8. state_move_line= fields.Boolean(readonly=True, default=False)
  9. #
  10. #
  11. # @api.multi
  12. # def update_ammount_move(self):
  13. # # Variables
  14. # total_voucher=0
  15. # monto_residual=0
  16. # cuota_dividida=0
  17. # estado =None
  18. # cambio_py=0
  19. #
  20. # if len(self.payment_ids) < 1:
  21. # raise osv.except_osv('Advertencia','No es posible continuar con la operación, para generar la división del saldo es necesario que pague su primera entrega')
  22. # return
  23. # #Verifica si existe mas de una linea en move live
  24. # if len(self.move_line_debt) > 1:
  25. # # Actulizar estado del journal cuando tipo es venta
  26. # datos_journal = self.env['account.journal'].search([('type', '=', 'sale')])
  27. # datos_journal.write({'entry_posted' : True})
  28. #
  29. # # rate_model = self.env['res.currency.rate'].search([('currency_id', '=', 166)])
  30. # # rate_py = rate_model[len(rate_model)-1]
  31. # # cambio_py =rate_py.rate
  32. #
  33. # if self.currency_id.id == 3:
  34. # monto_residual = self.residual
  35. # else:
  36. # monto_residual = self.residual/self.currency_id.rate_ids.rate
  37. #
  38. # # Calular la divicion la cuota
  39. # cuota_dividida = (monto_residual / len(self.move_line_debt))
  40. # print(monto_residual)
  41. # print(cuota_dividida)
  42. # for move_line in self.move_line_debt:
  43. # move_dato = self.env['account.move'].search([('id', 'in', move_line.move_id.ids)])
  44. # if move_dato:
  45. # estado = move_dato.state
  46. # move_dato.write({'state' : 'draft'})
  47. #
  48. # line_voucher = self.env['account.voucher.line'].search([('move_line_id', '=', move_line.id), ('amount', '>', 0)],order='id')
  49. # print(line_voucher)
  50. # if line_voucher:
  51. # for voucher in line_voucher:
  52. #
  53. # if voucher.voucher_id.payment_rate_currency_id.id == 3:
  54. # print("moneda Dolar ")
  55. # total_voucher += voucher.amount
  56. # else:
  57. # print("ota moneda")
  58. # print("Cambio "+str(voucher.voucher_id.payment_rate_currency_id))
  59. # total_voucher +=(voucher.amount / voucher.voucher_id.payment_rate_currency_id.rate_ids.rate)
  60. #
  61. # print("cuota "+str(cuota_dividida))
  62. # print("pagado " +str(total_voucher))
  63. # print('total '+str(cuota_dividida + total_voucher))
  64. # move_line_dato = self.env['account.move.line'].search([('id', '=', move_line.id)])
  65. # move_line_dato.write({'debit' : (cuota_dividida + total_voucher)})
  66. #
  67. # # move_line_dato.write({'amount_currency' : ((move_line_dato.debit - move_line_dato.credit)*cambio_py)})
  68. #
  69. # if estado == None:
  70. # estado='draft'
  71. # move_dato.write({'state' : estado})
  72. #
  73. # # move_line_dato._amount_residual(move_line_dato.amount_residual_currency)
  74. #
  75. # datos_journal.write({'entry_posted' : False})
  76. # incoice_datos = self.env['account.invoice'].search([('id', '=',self.id )])
  77. # incoice_datos.write({'state_move_line' : True})
  78. #
  79. # move_line_state = self.env['account.move.line'].search([('ref', '=', self.number)])
  80. # move_line_state.write({'state' : 'valid'})
  81. #
  82. # else:
  83. # raise osv.except_osv('Advertencia','No es posible generar la división del saldo sobre una única linea')
  84. # return