'Renders the form template of the given acquirer as a qWeb template.
:param string reference: the transaction reference
:param float amount: the amount the buyer has to pay
:param currency_id: currency id
:param dict partner_id: optional partner_id to fill values
:param dict values: a dictionary of values for the transction that is
given to the acquirer-specific method generating the form values
All templates will receive:
- acquirer: the payment.acquirer browse record
- user: the current user browse record
- currency_id: id of the transaction currency
- amount: amount of the transaction
- reference: reference of the transaction
- partner_*: partner-related values
- partner: optional partner browse record
- \'feedback_url\': feedback URL, controler that manage answer of the acquirer (without base url) -> FIXME
- \'return_url\': URL for coming back after payment validation (wihout base url) -> FIXME
- \'cancel_url\': URL if the client cancels the payment -> FIXME
- \'error_url\': URL if there is an issue with the payment -> FIXME
- context: Odoo context'

@api.multi
def render(self, reference, amount, currency_id, partner_id=False, values=None):

    if (values is None):
        values = {}
    values.setdefault('reference', reference)
    amount = float_round(amount, 2)
    values.setdefault('amount', amount)
    currency_id = values.setdefault('currency_id', currency_id)
    if currency_id:
        currency = self.env['res.currency'].browse(currency_id)
    else:
        currency = self.env.user.company_id.currency_id
    values['currency'] = currency
    partner_id = values.get('partner_id', partner_id)
    billing_partner_id = values.get('billing_partner_id', partner_id)
    if partner_id:
        partner = self.env['res.partner'].browse(partner_id)
        if (partner_id != billing_partner_id):
            billing_partner = self.env['res.partner'].browse(billing_partner_id)
        else:
            billing_partner = partner
        values.update({'partner': partner, 'partner_id': partner_id, 'partner_name': partner.name, 'partner_lang': partner.lang, 'partner_email': partner.email, 'partner_zip': partner.zip, 'partner_city': partner.city, 'partner_address': _partner_format_address(partner.street, partner.street2), 'partner_country_id': partner.country_id.id, 'partner_country': partner.country_id, 'partner_phone': partner.phone, 'partner_state': partner.state_id, 'billing_partner': billing_partner, 'billing_partner_id': billing_partner_id, 'billing_partner_name': billing_partner.name, 'billing_partner_lang': billing_partner.lang, 'billing_partner_email': billing_partner.email, 'billing_partner_zip': billing_partner.zip, 'billing_partner_city': billing_partner.city, 'billing_partner_address': _partner_format_address(billing_partner.street, billing_partner.street2), 'billing_partner_country_id': billing_partner.country_id.id, 'billing_partner_country': billing_partner.country_id, 'billing_partner_phone': billing_partner.phone, 'billing_partner_state': billing_partner.state_id})
    if values.get('partner_name'):
        values.update({'partner_first_name': _partner_split_name(values.get('partner_name'))[0], 'partner_last_name': _partner_split_name(values.get('partner_name'))[1]})
    if values.get('billing_partner_name'):
        values.update({'billing_partner_first_name': _partner_split_name(values.get('billing_partner_name'))[0], 'billing_partner_last_name': _partner_split_name(values.get('billing_partner_name'))[1]})
    if (not values.get('partner_address')):
        values['address'] = _partner_format_address(values.get('partner_street', ''), values.get('partner_street2', ''))
    if ((not values.get('partner_country')) and values.get('partner_country_id')):
        values['country'] = self.env['res.country'].browse(values.get('partner_country_id'))
    if (not values.get('billing_partner_address')):
        values['billing_address'] = _partner_format_address(values.get('billing_partner_street', ''), values.get('billing_partner_street2', ''))
    if ((not values.get('billing_partner_country')) and values.get('billing_partner_country_id')):
        values['billing_country'] = self.env['res.country'].browse(values.get('billing_partner_country_id'))
    fees_method_name = ('%s_compute_fees' % self.provider)
    if hasattr(self, fees_method_name):
        fees = getattr(self, fees_method_name)(values['amount'], values['currency_id'], values.get('partner_country_id'))
        values['fees'] = float_round(fees, 2)
    cust_method_name = ('%s_form_generate_values' % self.provider)
    if hasattr(self, cust_method_name):
        method = getattr(self, cust_method_name)
        values = method(values)
    values.update({'tx_url': self._context.get('tx_url', self.get_form_action_url()), 'submit_class': self._context.get('submit_class', 'btn    btn-link'), 'submit_txt': self._context.get('submit_txt'), 'acquirer': self, 'user': self.env.user, 'context': self._context, 'type': (values.get('type') or 'form')})
    values.setdefault('return_url', False)
    return self.view_template_id.render(values, engine='ir.qweb')
