|
|
@@ -2,17 +2,19 @@
|
|
|
from openerp import models, fields, api
|
|
|
import math
|
|
|
|
|
|
+from openerp import models, fields, api
|
|
|
+
|
|
|
|
|
|
class AccountVoucher(models.Model):
|
|
|
_inherit = 'account.voucher'
|
|
|
|
|
|
- comision = fields.Integer(
|
|
|
+ comision = fields.Float(
|
|
|
string='Comisión',
|
|
|
compute='_compute_comision',
|
|
|
store=True
|
|
|
)
|
|
|
|
|
|
- @api.depends('amount', 'state')
|
|
|
+ @api.depends('amount')
|
|
|
def _compute_comision(self):
|
|
|
|
|
|
param = self.env['ir.config_parameter'].get_param(
|
|
|
@@ -22,12 +24,7 @@ class AccountVoucher(models.Model):
|
|
|
porcentaje = float(param)
|
|
|
|
|
|
for rec in self:
|
|
|
- if rec.state == 'posted' and rec.amount:
|
|
|
-
|
|
|
- valor = rec.amount * porcentaje / 100
|
|
|
-
|
|
|
- # ✔ redondeo sin decimal estable
|
|
|
- rec.comision = int(valor + 0.5)
|
|
|
-
|
|
|
+ if rec.state == 'posted'
|
|
|
+ rec.comision = rec.amount * porcentaje / 100 if rec.amount else 0
|
|
|
else:
|
|
|
rec.comision = 0
|