Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
14720 Lượt xem

I want to validate order before finalize sale through odoo website. If order is not validated based on some conditions I want to show a warning message. What is the approach to show the warning message on website? 
Note: Warning is not on address form validation but right before finalize sale.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất
# Set Valid/invalid flag to show/hide warning
@http.route(['/shop/cart'], type='http', auth="public", website=True)
def cart(self, **post):
order = request.website.sale_get_order()

valid = True
if :
valid = False

values = {
'website_sale_order': order,
'compute_currency': compute_currency,
'suggested_products': [],
'valid':valid,
}
return request.render("website_sale.cart", values)
# fallback to "/shop/cart" if order not valid
@http.route(['/shop/checkout'], type='http', auth="public", website=True)
def checkout(self, **post):
order = request.website.sale_get_order()
if order.company_id.sale_freight_warning == 's' and len(set([line.product_id.has_frete for line in order.order_line if line.product_id])) > 1:
return request.redirect("/shop/cart")
else:
return super(CorreiosL10nBrWebsiteSale, self).checkout(**post)

<!-- Add warning on website cart page -->
<template id="payment" inherit_id="website_sale.cart">
<xpath expr="//h1" position="after">
<t t-if="not valid">
<div class="alert alert-danger">
<strong>Wraning!</strong>
You can't buy product with freight &amp; no freight together.
</div>
</t>
</xpath>
</template>
Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 9 17
5746
0
thg 9 17
4034
2
thg 2 21
7645
0
thg 9 17
2881
2
thg 7 25
4773