'Prepare values to create an account.invoice.tax line
The line parameter is an account.invoice.line, and the
tax parameter is the output of account.tax.compute_all().'

def _prepare_tax_line_vals(self, line, tax):

    vals = {'invoice_id': self.id, 'name': tax['name'], 'tax_id': tax['id'], 'amount': tax['amount'], 'base': tax['base'], 'manual': False, 'sequence': tax['sequence'], 'account_analytic_id': ((tax['analytic'] and line.account_analytic_id.id) or False), 'account_id': (((self.type in ('out_invoice', 'in_invoice')) and (tax['account_id'] or line.account_id.id)) or (tax['refund_account_id'] or line.account_id.id))}
    if ((not vals.get('account_analytic_id')) and line.account_analytic_id and (vals['account_id'] == line.account_id.id)):
        vals['account_analytic_id'] = line.account_analytic_id.id
    return vals
