[IMP] website_sale_delivery: only display delivery cost in cart if already set

This commit is contained in:
Jeremy Kersten
2015-06-10 20:48:50 +02:00
parent 1243937e10
commit 4a7fed2745
3 changed files with 20 additions and 3 deletions
+2 -2
View File
@@ -1221,7 +1221,7 @@
<!-- Page Shop my cart and payment total -->
<template id="total">
<t t-if="website_sale_order">
<div id="cart_total" t-if="website_sale_order">
<div class="row" id="order_total_untaxed">
<span class="col-xs-6 text-right text-muted">Subtotal:</span>
<span class="col-xs-6 text-muted">
@@ -1252,7 +1252,7 @@
}'/>
</span>
</div>
</t>
</div>
</template>
<!-- payment acquirer information -->
@@ -33,6 +33,15 @@ class SaleOrder(orm.Model):
res[order.id]['amount_delivery'] = currency_pool.round(cr, uid, currency, line_amount)
return res
def _has_delivery(self, cr, uid, ids, field_name, arg, context=None):
result = dict.fromkeys(ids, False)
for so in self.browse(cr, uid, ids, context=context):
for line in so.order_line:
if line.is_delivery:
result[so.id] = True
break
return result
def _get_order(self, cr, uid, ids, context=None):
result = {}
for line in self.pool.get('sale.order.line').browse(cr, uid, ids, context=context):
@@ -49,6 +58,14 @@ class SaleOrder(orm.Model):
},
multi='sums', help="The amount without tax.", track_visibility='always'
),
'has_delivery': fields.function(
_has_delivery, type='boolean', string='Has delivery',
store={
'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10),
'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),
},
help="Has an order line set for delivery"
),
'website_order_line': fields.one2many(
'sale.order.line', 'order_id',
string='Order Lines displayed on Website', readonly=True,
@@ -4,7 +4,7 @@
<template id="cart_delivery" name="Delivery Costs" inherit_id="website_sale.total">
<xpath expr="//div[@id='order_total_taxes']" position="after">
<div class="row" id="order_delivery">
<div class="row" id="order_delivery" t-if="website_sale_order and website_sale_order.has_delivery">
<span class="col-xs-6 text-right text-muted" title="Delivery will be updated after choosing a new delivery method"> Delivery:</span>
<span class="col-xs-6 text-muted">
<span t-field="website_sale_order.amount_delivery" style="white-space: nowrap;" t-field-options='{