<commit_before># -*- coding: utf-8 -*-
# © 2017 Comunitea
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models, fields, api, exceptions, _


class ApplyGlobalDiscount(models.TransientModel):

    _name = 'apply.global.discount'

    discount = fields.Float('Discount(%)')

    @api.multi
    def apply_discount(self):
        self.ensure_one()
        if not self._context.get('active_model'):
            return {'type': 'ir.actions.act_window_close'}
        obj = self.env[self._context['active_model']].browse(self._context.get('active_id', False))
        if self._context['active_model'] == 'sale.order':
            lines = obj.template_lines
        elif self._context['active_model'] == 'account.invoice':
            lines = obj.invoice_line_ids
        for line in lines:
            if (not line.product_id or not line.product_id.without_early_payment) and not line.promotion_line:
                if self.discount != 0:
                    if float(line.chained_discount) != 0:
                        line.chained_discount = line.chained_discount + ('+' if line.chained_discount else '') + str(self.discount)
                    else:
                        line.chained_discount = str(self.discount)
                else:
                    line.chained_discount = 0
        return {'type': 'ir.actions.act_window_close'}<commit_msg>[FIX] jim_sale. Fuerza calculo de impuestos tras aplicar descuento a todas las lineas<commit_after># -*- coding: utf-8 -*-
# © 2017 Comunitea
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields, api, exceptions, _


class ApplyGlobalDiscount(models.TransientModel):

    _name = 'apply.global.discount'

    discount = fields.Float('Discount(%)')

    @api.multi
    def apply_discount(self):
        self.ensure_one()
        if not self._context.get('active_model'):
            return {'type': 'ir.actions.act_window_close'}
        obj = self.env[self._context['active_model']].browse(self._context.get('active_id', False))
        if self._context['active_model'] == 'sale.order':
            lines = obj.template_lines
        elif self._context['active_model'] == 'account.invoice':
            lines = obj.invoice_line_ids
        for line in lines:
            if (not line.product_id or not line.product_id.without_early_payment) and not line.promotion_line:
                if self.discount != 0:
                    if float(line.chained_discount) != 0:
                        line.chained_discount = line.chained_discount + ('+' if line.chained_discount else '') + str(self.discount)
                    else:
                        line.chained_discount = str(self.discount)
                else:
                    line.chained_discount = 0
        if self._context['active_model'] == 'account.invoice':
            obj.compute_taxes()
        return {'type': 'ir.actions.act_window_close'}
{'fraction_non_alphanumeric': 0.12142857142857143, 'fraction_numerical': 0.006802721088435374, 'mean_word_length': 2.364988558352403, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6875006', 'n_tokens_mistral': 908, 'n_tokens_neox': 864, 'n_words': 177}