# -*- coding: utf-8 -*- from openerp import models, fields, tools, api import openerp.addons.decimal_precision as dp class AccountSaleTerm(models.Model): _name = 'account.sale.term' '''Sale Interest ''' sale_amount = fields.Float('Amount Sale', digits_compute=dp.get_precision('Account'), default=0.0) ## Valor de la Venta sale_payments_init = fields.Float('Amount Payments', digits_compute=dp.get_precision('Account'), default=0.0) ## Payment Initial sale_residual = fields.Float('Amount Residual', digits_compute=dp.get_precision('Account'), default=0.0)## interest_qty = fields.Float('Interés %', digits=(3,6), digits_compute=dp.get_precision('Interest'), help="Interés %") interest_amount = fields.Float('Amount Interest', digits_compute=dp.get_precision('Account'), default=0.0) amount_total = fields.Float('Amount Residual + Interest ', digits_compute=dp.get_precision('Account'), default=0.0) '''Quota''' date_init = fields.Date() ## Date Initial Quota term_type_id = fields.Many2one('account.payment.term.type', string='Invoice', ondelete='restrict', index=True) ## Type term Payments quota_amount = fields.Float('Amount Quota', digits_compute=dp.get_precision('Account'), default=0.0) ## Amount Quota quota_qty = fields.Integer(string='Qty Quota', default=0) ## QTY Quota state = fields.Selection([('draft','Borrador'),('posted', 'Fijado')], default='draft') lines = fields.One2many('account.sale.term.line', 'sale_term_id', string='sale term line') sale_id = fields.Many2one('sale.order', string='Sale Orden', ondelete='restrict', index=True) class AccountSaleTermLine(models.Model): _name = 'account.sale.term.line' sale_term_id = fields.Many2one('account.sale.term', string='Sale term', ondelete='cascade', index=True) sale_id = fields.Many2one('sale.order', string='Sale Orden', ondelete='restrict', index=True) number = fields.Integer(string='number', default=0) cuota_number = fields.Char('number Cuota') date = fields.Date() amount = fields.Float('Amount Quota', digits_compute=dp.get_precision('Account'), default=0.0) days = fields.Integer(string='days', default=0) value = fields.Char('Type') class saleOrderTermConfig(models.Model): _inherit = 'sale.order' sale_term = fields.One2many('account.sale.term', 'sale_id', string=' Account Interest') sale_term_line = fields.One2many('account.sale.term.line', 'sale_id', string=' Account Interest') class saleOrderLineTermConfig(models.Model): _inherit = 'sale.order.line' is_discount_sale_term = fields.Boolean('',default=False) amount_line_interest = fields.Float('Amount Interest', digits_compute=dp.get_precision('Account'), default=0.0)