Added Upstream Patch for website_sale_delivery

This commit is contained in:
az-flectra 2018-07-19 18:13:46 +05:30
parent b851be6ef5
commit 02f2d71f38
2 changed files with 8 additions and 1 deletions

View File

@ -37,7 +37,9 @@ class WebsiteSaleDelivery(WebsiteSale):
def _get_shop_payment_values(self, order, **kwargs): def _get_shop_payment_values(self, order, **kwargs):
values = super(WebsiteSaleDelivery, self)._get_shop_payment_values(order, **kwargs) values = super(WebsiteSaleDelivery, self)._get_shop_payment_values(order, **kwargs)
if not order._get_delivery_methods(): has_stockable_products = any(line.product_id.type in ['consu', 'product'] for line in order.order_line)
if not order._get_delivery_methods() and has_stockable_products:
values['errors'].append( values['errors'].append(
(_('Sorry, we are unable to ship your order'), (_('Sorry, we are unable to ship your order'),
_('No shipping method is available for your current order and shipping address. ' _('No shipping method is available for your current order and shipping address. '
@ -54,6 +56,7 @@ class WebsiteSaleDelivery(WebsiteSale):
delivery_carriers = order._get_delivery_methods() delivery_carriers = order._get_delivery_methods()
values['deliveries'] = delivery_carriers.sudo() values['deliveries'] = delivery_carriers.sudo()
values['delivery_has_stockable'] = has_stockable_products
values['delivery_action_id'] = request.env.ref('delivery.action_delivery_carrier_form').id values['delivery_action_id'] = request.env.ref('delivery.action_delivery_carrier_form').id
return values return values

View File

@ -57,6 +57,10 @@
</a> </a>
</div> </div>
</xpath> </xpath>
<!-- we shouldn't be able to pay if there is no way to deliver -->
<xpath expr="//div[@id='payment_method']" position="attributes">
<attribute name="t-att-style">'display: none!important' if not deliveries and delivery_has_stockable else ''</attribute>
</xpath>
</template> </template>
<template id="portal_order_page_shipping_tracking" name="Shipping tracking on orders followup" inherit_id="website_sale_stock.portal_order_page_shipping"> <template id="portal_order_page_shipping_tracking" name="Shipping tracking on orders followup" inherit_id="website_sale_stock.portal_order_page_shipping">