Explorar el Código

This module allows to add comision en voucher.

SEBAS hace 3 meses
padre
commit
77b67dc855
Se han modificado 1 ficheros con 6 adiciones y 9 borrados
  1. 6 9
      models/account_voucher.py

+ 6 - 9
models/account_voucher.py

@@ -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