'Function used in other module to compute the taxes on a fresh invoice created (onchanges did not applied)'

@api.multi
def compute_taxes(self):

    account_invoice_tax = self.env['account.invoice.tax']
    ctx = dict(self._context)
    for invoice in self:
        self._cr.execute('DELETE    FROM    account_invoice_tax    WHERE    invoice_id=%s    AND    manual    is    False', (invoice.id,))
        self.invalidate_cache()
        tax_grouped = invoice.get_taxes_values()
        for tax in tax_grouped.values():
            account_invoice_tax.create(tax)
    return self.with_context(ctx).write({'invoice_line_ids': []})
