accont_payments_term_config.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. # -*- coding: utf-8 -*-
  2. from openerp import models, fields, tools, api
  3. import openerp.addons.decimal_precision as dp
  4. class AccontPaymentsTermConfig(models.Model):
  5. _name = 'accont.payments.term.config'
  6. name = fields.Char('Name', required=True, readonly=True)
  7. interest_rate = fields.Float('Tasa de interés', digits=(3,6), digits_compute=dp.get_precision('Interest'), required=True, help="Tasa de interés %")
  8. message_default = fields.Char('Message', default='La tasa de interés por defecto es 4% mensual, tasa diaria (4 / 30 = 0,1333).')
  9. compute = fields.Boolean(help="Indica si sera calculado los interés")
  10. comment = fields.Text('Comment', help="Información adicional")
  11. @api.model
  12. def _create_default_config(self):
  13. config = {
  14. 'name': 'Interés por cambio de fecha de cuota',
  15. 'interest_rate': '0.1333',
  16. 'compute': True,
  17. }
  18. termConfig = self.env['accont.payments.term.config'].search([('name','=', config['name'])])
  19. if (not termConfig):
  20. self.env['accont.payments.term.config'].create({
  21. 'name': config['name'],
  22. 'interest_rate': config['interest_rate'],
  23. 'compute': config['compute'],
  24. })
  25. class SaleOrderLineInterest(models.Model):
  26. _inherit = 'sale.order.line'
  27. is_interest = fields.Boolean('Is Interest',default=False)