Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Cantidades(ModelSQL, ModelView):
- 'Imprenta. Otras Cantidades'
- _name = 'sale_imprenta.cantidad'
- _description = 'Otras Cantidades'
- cantidad = fields.Integer('Cantidad', required=True)
- utilidad = fields.Integer('Porcentaje de Utilidad', required=True)
- sale_id = fields.Many2One('sale.sale','Venta')
- total = fields.Function(fields.Numeric('Total', digits=(16, 2), depends=['cantidad'], on_change_with=['cantidad', 'utilidad', 'sale_id']), 'get_total_amount')
- def default_utilidad(self):
- return 0
- def on_change_with_total(self, vals):
- 'On change With Campo Total'
- if vals.get('sale_id'):
- ## I would like to call get_total_amount()
- def get_total_amount(self, ids, name):
- 'Total para Otras Cantidades'
- currency_obj = Pool().get('currency.currency')
- amounts = {}
- for cantidades in self.browse(ids):
- sale = cantidades.sale_id
- amount_fijo = sum((l.amount for l in sale.lines if l.type == 'line' and l.fijo),
- Decimal(0))
- factor = Decimal(float(cantidades.cantidad) / sale.cantidad)
- amount_variable = sum((l.amount * factor for l in sale.lines if l.type == 'line' and not l.fijo),
- Decimal(0))
- amounts[cantidades.id] = currency_obj.round(sale.currency, (amount_fijo + amount_variable)*(100+cantidades.utilidad)/100)
- return amounts
- Cantidades()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement