[IMP] payment: Remove ugly render() hack

- Removed an ugly hack that renders s2s forms then display them using t-raw, we're now providing the xml_id of the s2s forms and uses t-call instead.
This commit is contained in:
tbe-odoo
2017-08-29 17:11:23 +02:00
parent 194d52e8fd
commit 11bc680ae9
5 changed files with 14 additions and 27 deletions
+4 -4
View File
@@ -12,13 +12,13 @@ class WebsitePayment(http.Controller):
partner = request.env.user.partner_id
payment_tokens = partner.payment_token_ids
payment_tokens |= partner.commercial_partner_id.sudo().payment_token_ids
return_url = request.params.get('redirect', '/my/payment_method')
values = {
'pms': payment_tokens,
'acquirers': acquirers
'acquirers': acquirers,
'return_url': return_url,
'bootstrap_formatting': True
}
return_url = request.params.get('redirect', '/my/payment_method')
for acquirer in acquirers:
acquirer.form = acquirer.sudo()._registration_render(request.env.user.partner_id.id, {'error': {}, 'error_message': [], 'return_url': return_url, 'json': False, 'bootstrap_formatting': True})
return request.render("payment.pay_methods", values)
@http.route(['/website_payment/pay'], type='http', auth='public', website=True)
+5 -10
View File
@@ -355,16 +355,11 @@ class PaymentAcquirer(models.Model):
return self.view_template_id.render(values, engine='ir.qweb')
@api.multi
def _registration_render(self, partner_id, qweb_context=None):
if qweb_context is None:
qweb_context = {}
qweb_context.update(id=self.ids[0], partner_id=partner_id)
method_name = '_%s_registration_form_generate_values' % (self.provider,)
if hasattr(self, method_name):
method = getattr(self, method_name)
qweb_context.update(method(qweb_context))
return self.registration_view_template_id.render(qweb_context, engine='ir.qweb')
def get_s2s_form_name(self):
if self.registration_view_template_id:
model_data = self.env['ir.model.data'].search([('model', '=', 'ir.ui.view'), ('res_id', '=', self.registration_view_template_id.id)])
return ('%s.%s') % (model_data.module, model_data.name)
return False
@api.multi
def s2s_process(self, data):
+1 -1
View File
@@ -61,7 +61,7 @@
</div>
<div t-attf-id="o_payment_add_token_acq_{{acq.id}}" t-attf-class="panel-footer {{'hidden' if (len(s2s_acquirers)&gt;1 and len(pms)==0 and s2s_acquirers[0]!=acq) else 'hidden' if len(pms)&gt;0 else ''}}">
<div class="clearfix">
<t t-raw="acq.form" t-att-data-acquirer-id="acquirer.id"/>
<t t-call="{{acq.sudo().get_s2s_form_name()}}"/>
</div>
</div>
</t>
+2 -6
View File
@@ -61,6 +61,8 @@ class sale_quote(http.Controller):
'tx_post_msg': Transaction.acquirer_id.post_msg if Transaction else False,
'need_payment': order_sudo.invoice_status == 'to invoice' and Transaction.state in ['draft', 'cancel', 'error'],
'token': token,
'return_url': '/shop/payment/validate',
'bootstrap_formatting': True
}
if order_sudo.require_payment or values['need_payment']:
@@ -81,12 +83,6 @@ class sale_quote(http.Controller):
'partner_id': order_sudo.partner_id.id,
})
for acq in values['s2s_acquirers']:
acq.form = acq._registration_render(order_sudo.partner_id.id, {
'return_url': '/shop/payment/validate',
'bootstrap_formatting': True
})
history = request.session.get('my_quotes_history', [])
values.update(get_records_pager(history, order_sudo))
return request.render('website_quote.so_quotation', values)
+2 -6
View File
@@ -708,6 +708,8 @@ class WebsiteSale(http.Controller):
partner=order.partner_id.id,
order=order,
payment_action_id=request.env.ref('payment.action_payment_acquirer').id,
return_url= '/shop/payment/validate',
bootstrap_formatting= True
)
acquirers = request.env['payment.acquirer'].search(
@@ -732,12 +734,6 @@ class WebsiteSale(http.Controller):
}
)
for acq in values['s2s_acquirers']:
acq.form = acq._registration_render(order.partner_id.id, {
'return_url': '/shop/payment/validate',
'bootstrap_formatting': True
})
return values
@http.route(['/shop/payment'], type='http', auth="public", website=True)