# -*- coding: utf-8 -*- from openerp import models, fields, tools, api import openerp.addons.decimal_precision as dp from datetime import datetime class AccountInterest(models.Model): _name = 'account.interest' name = fields.Char() date = fields.Date('Date', help="Fecha de operación") state = fields.Selection([('cancel', 'Cancelado'),('open', 'Abierto'),('paid', 'Pagado')],'Estado del pago', default="open", help="Estado") comment = fields.Text('Comment', help="Información adicional") ## Cliente customer_id = fields.Many2one('res.partner', string="customer") ## factura invoice_id = fields.Many2one('account.invoice', string='Invoice Reference', ondelete='restrict', index=True) reference = fields.Char(string='Invoice Reference', help="Invoice Reference") ## Currency currency_id = fields.Many2one('res.currency', string="Currency", help="Moneda de la operación") ## Line lines_ids = fields.One2many('account.interest.line', 'interest_id', string='interest line') ''' Create ''' @api.model def create(self, vals): interest = super(AccountInterest, self).create(vals) interest.write({'name':("INTEREST/%06d" % (interest.id))}) return interest ''' Invoice ''' class accountInvoiceInterest(models.Model): _inherit = 'account.invoice' interest_ids = fields.One2many('account.interest', 'invoice_id', string=' Account Interest') is_interest = fields.Boolean('Factura de interés', default=False, help="Indica si esta factura fue generado por un interés.") ''' partner ''' class ResPartnerInterest(models.Model): _inherit = 'res.partner' interest_ids = fields.One2many('account.interest', 'customer_id', string=' Account Interest') class AccountInterestLine(models.Model): _name = 'account.interest.line' ## Interest interest_id = fields.Many2one('account.interest', string='Account Interest', ondelete='cascade', index=True, required=True) move_line_id = fields.Many2one('account.move.line', string="Registros del diario", help="Registros del diario") amount = fields.Float('amount', digits_compute=dp.get_precision('Account'), required=True, help="Monto del pago") amount_residual = fields.Float('amount', digits_compute=dp.get_precision('Account'), required=True, help="Monto del pago") amount_interest = fields.Float('amount', digits_compute=dp.get_precision('Account'), required=True, help="Monto del pago") date_maturity = fields.Date() expired_days = fields.Integer('Expired Days ') invoice = fields.Many2one('account.invoice', string='Invoice Reference', index=True) reference = fields.Char(string='Invoice Reference', help="Invoice Reference") state = fields.Selection([('cancel','Cancelado'),('open','Abierto'),('invoiced','Facturado')],'Estado del pago', default="open") amount_dicount = fields.Float('amount disconut', digits_compute=dp.get_precision('Account'), help="Monto del descuento") ''' Move Line ''' class accountMoveLineInterest(models.Model): _inherit = 'account.move.line' interest_line_ids = fields.One2many('account.interest.line', 'move_line_id', string=' Account Interest Line') date_interest = fields.Date("Date interés", help="Fecha de la facturación de os interés")