account_interest.py 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # -*- coding: utf-8 -*-
  2. from openerp import models, fields, tools, api
  3. import openerp.addons.decimal_precision as dp
  4. from datetime import datetime
  5. class AccountInterest(models.Model):
  6. _name = 'account.interest'
  7. name = fields.Char()
  8. date = fields.Date('Date', help="Fecha de operación")
  9. state = fields.Selection([('cancel', 'Cancelado'),('open', 'Abierto'),('paid', 'Pagado')],'Estado del pago', default="open", help="Estado")
  10. comment = fields.Text('Comment', help="Información adicional")
  11. ## Cliente
  12. customer_id = fields.Many2one('res.partner', string="customer")
  13. ## factura
  14. invoice_id = fields.Many2one('account.invoice', string='Invoice Reference', ondelete='restrict', index=True)
  15. reference = fields.Char(string='Invoice Reference', help="Invoice Reference")
  16. ## Currency
  17. currency_id = fields.Many2one('res.currency', string="Currency", help="Moneda de la operación")
  18. ## Line
  19. lines_ids = fields.One2many('account.interest.line', 'interest_id', string='interest line')
  20. '''
  21. Create
  22. '''
  23. @api.model
  24. def create(self, vals):
  25. interest = super(AccountInterest, self).create(vals)
  26. interest.write({'name':("INTEREST/%06d" % (interest.id))})
  27. return interest
  28. '''
  29. Invoice
  30. '''
  31. class accountInvoiceInterest(models.Model):
  32. _inherit = 'account.invoice'
  33. interest_ids = fields.One2many('account.interest', 'invoice_id', string=' Account Interest')
  34. is_interest = fields.Boolean('Factura de interés', default=False, help="Indica si esta factura fue generado por un interés.")
  35. '''
  36. partner
  37. '''
  38. class ResPartnerInterest(models.Model):
  39. _inherit = 'res.partner'
  40. interest_ids = fields.One2many('account.interest', 'customer_id', string=' Account Interest')
  41. class AccountInterestLine(models.Model):
  42. _name = 'account.interest.line'
  43. ## Interest
  44. interest_id = fields.Many2one('account.interest', string='Account Interest', ondelete='cascade', index=True, required=True)
  45. move_line_id = fields.Many2one('account.move.line', string="Registros del diario", help="Registros del diario")
  46. amount = fields.Float('amount', digits_compute=dp.get_precision('Account'), required=True, help="Monto del pago")
  47. amount_residual = fields.Float('amount', digits_compute=dp.get_precision('Account'), required=True, help="Monto del pago")
  48. amount_interest = fields.Float('amount', digits_compute=dp.get_precision('Account'), required=True, help="Monto del pago")
  49. date_maturity = fields.Date()
  50. expired_days = fields.Integer('Expired Days ')
  51. invoice = fields.Many2one('account.invoice', string='Invoice Reference', index=True)
  52. reference = fields.Char(string='Invoice Reference', help="Invoice Reference")
  53. state = fields.Selection([('cancel','Cancelado'),('open','Abierto'),('invoiced','Facturado')],'Estado del pago', default="open")
  54. amount_dicount = fields.Float('amount disconut', digits_compute=dp.get_precision('Account'), help="Monto del descuento")
  55. '''
  56. Move Line
  57. '''
  58. class accountMoveLineInterest(models.Model):
  59. _inherit = 'account.move.line'
  60. interest_line_ids = fields.One2many('account.interest.line', 'move_line_id', string=' Account Interest Line')
  61. date_interest = fields.Date("Date interés", help="Fecha de la facturación de os interés")