Reputation: 11143
I have successfully added textarea in website payment (/shop/payment) screen with following code.
<template id="payment_notes" name="PO" inherit_id="website_sale.payment">
<xpath expr="//div[@id='payment_method']" position="after">
<div class="mt32" method="post">
<textarea type="textarea" rows="5" name="po_notes" style="height:100px;width:800px" placeholder="Terms and conditions..."/>
</div>
</xpath>
</template>
What I have tried so far?
@http.route('/shop/payment/validate', type='http', auth="public", website=True)
def payment_validate(self, transaction_id=None, sale_order_id=None, **post):
print "\n=======res=paymentvalidate====", request.session.get('po_notes'), post.get('po_notes')
######
######
It's give me None, None
My question is that:
How can I get values in next level /shop/payment/validate ?
Upvotes: 0
Views: 2375
Reputation: 42
.......Template..........
<template id="shopping_note" inherit_id="website_sale.checkout" name="Shopping Note">
<xpath expr="//a[@href='/shop/cart']" position="before">
<div class="mt16 mb16">
<label>My Notes</label>
<input name="note" class='form-control' type="text" placeholder="Note about your order..." t-att-value="checkout.get('note')"/>
</div>
</xpath>
</template>
...Py......
def checkout_form_save(self, checkout):
order = request.website.sale_get_order(force_create=1, context=request.context)
if checkout.get('note'):
order.write({'note': checkout.get('note')})
return super(WebsiteSale, self).checkout_form_save(checkout=checkout)
def checkout_values(self, data=None):
res = super(WebsiteSale, self).checkout_values(data=data)
checkout = res.get('checkout',{})
order = request.website.sale_get_order(force_create=1, context=request.context)
if not data:
checkout.update({'note': order and order.note or None})
else:
checkout.update({'note': data and data.get('note') or None})
return res
Upvotes: -2
Reputation: 14746
If you want data of any html control inside controller while submit that form then you have to give one class "form-control" to each of the controls. So, just add class='form-control'
inside your textarea control.
Also seen that your control is not inside the html form. You have to put your control inside the form which is going to be submit and controller is going to call. So, you have to put your control inside form which you want to get. Below is just one of our idea.
<template id="payment_notes" name="PO" inherit_id="website_sale.payment">
<xpath expr="//div[@id='payment_method']/div[@class='col-sm-12']/form" position="inside">
<div class="mt32">
<textarea type="textarea" rows="5" name="po_notes" style="height:100px;width:800px" class="form-control" placeholder="Terms and conditions..."/>
</div>
</xpath>
</template>
Hope it is helpful to you.
Upvotes: 3