account_voucher.py 677 B

12345678910111213141516171819202122232425262728
  1. # -*- coding: utf-8 -*-
  2. from openerp import models, fields, api
  3. class AccountVoucher(models.Model):
  4. _inherit = 'account.voucher'
  5. comision = fields.Integer(
  6. string='Comisión',
  7. compute='_compute_comision',
  8. store=True
  9. )
  10. @api.depends('amount')
  11. def _compute_comision(self):
  12. param = self.env['ir.config_parameter'].get_param(
  13. 'voucher_comision.porcentaje', '2'
  14. )
  15. porcentaje = float(param)
  16. for rec in self:
  17. if rec.amount:
  18. valor = rec.amount * porcentaje / 100
  19. rec.comision = int(round(valor))
  20. else:
  21. rec.comision = 0