Skip to content

Commit

Permalink
Merge pull request #430 from trojikman/12.0-website_sale_checkout_sto…
Browse files Browse the repository at this point in the history
…re-fix-bug
  • Loading branch information
ilmir-k committed Oct 17, 2019
2 parents 08bd313 + 1237768 commit 54a1a47
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 23 deletions.
2 changes: 1 addition & 1 deletion website_sale_checkout_store/__manifest__.py
Expand Up @@ -8,7 +8,7 @@
'summary': """Simplify checkout process by excluding shipping and/or payment information""",
'category': 'eCommerce',
'images': ['images/1.png'],
'version': '12.0.1.0.4',
'version': '12.0.1.0.5',

'author': 'IT-Projects LLC',
"support": "apps@it-projects.info",
Expand Down
15 changes: 9 additions & 6 deletions website_sale_checkout_store/controllers/main.py
Expand Up @@ -52,20 +52,23 @@ def payment_get_status(self, sale_order_id, **post):
else:
return super(WebsiteSaleExtended, self).payment_get_status(sale_order_id, **post)

def _get_mandatory_fields(self):
def _get_mandatory_fields(self, shipping=None):
order = request.website.sale_get_order()
if not order.buy_way or 'nobill' not in order.buy_way and 'noship' not in order.buy_way:
return ["name", "phone", "email", "street", "city", "country_id"]
fields = ["name", "phone", "street", "city", "country_id"]
elif 'noship' in order.buy_way:
if 'nobill' in order.buy_way:
return ["name", "phone", "email"]
fields = ["name", "phone"]
else:
return ["name", "phone", "email", "country_id"]
fields = ["name", "phone", "country_id"]
else:
return ["name", "phone", "email", "street", "city"]
fields = ["name", "phone", "street", "city"]
if not shipping:
fields.append('email')
return fields

def _get_mandatory_billing_fields(self):
return self._get_mandatory_fields()

def _get_mandatory_shipping_fields(self):
return self._get_mandatory_fields()
return self._get_mandatory_fields(shipping=True)
5 changes: 5 additions & 0 deletions website_sale_checkout_store/doc/changelog.rst
@@ -1,3 +1,8 @@
`1.0.5`
-------

- FIX: Redirection error on the address page

`1.0.4`
-------

Expand Down
34 changes: 18 additions & 16 deletions website_sale_checkout_store/templates.xml
Expand Up @@ -123,6 +123,9 @@
</template>

<template id="address" name="my_checkout" inherit_id="website_sale.address">
<xpath expr="//t[@t-if=&quot;partner_id == website_sale_order.partner_shipping_id.id == website_sale_order.partner_invoice_id.id&quot;]" position="attributes">
<attribute name="t-if">partner_id == website_sale_order.partner_shipping_id.id == website_sale_order.partner_invoice_id.id and ship_enabled == '1'</attribute>
</xpath>
<xpath expr="//div[hasclass('container','oe_website_sale')]" position="attributes">
<attribute name="t-attf-ship_enabled">#{ship_enabled}</attribute>
<attribute name="t-attf-bill_enabled">#{bill_enabled}</attribute>
Expand All @@ -149,10 +152,6 @@
<xpath expr="//input[@name='company_name']/.." position="attributes">
<attribute name="ship">1</attribute>
</xpath>

<xpath expr="//select[@name='state_id']/.." position="attributes">
<attribute name="bill">1</attribute>
</xpath>
<xpath expr="//input[@name='vat']/.." position="attributes">
<attribute name="style">display: none</attribute>
</xpath>
Expand Down Expand Up @@ -183,18 +182,21 @@
</tbody>
</table>
</xpath>
<xpath expr="//div[hasclass('oe_cart')]/div[hasclass('card', 'mt-3')]/div[hasclass('card-body')]/div" position="replace">
<t t-if="order.buy_way == 'bill_noship'">
<div><b>Billing : </b><span t-esc='order.partner_id' t-options="dict(widget='contact', fields=['address'], no_marker=True, separator=' ')" class="address-inline"/></div>
</t>
<t t-if="order.buy_way == 'nobill_ship'">
<div><b><t t-if="same_shipping and not only_services">Shipping</t>: </b><span t-esc='order.partner_id' t-options="dict(widget='contact', fields=['address'], no_marker=True, separator=', ')" class="address-inline"/></div>
<div t-if="not same_shipping and not only_services" groups="sale.group_delivery_invoice_address"><b>Shipping: </b><span t-esc='order.partner_shipping_id' t-options="dict(widget='contact', fields=['address'], no_marker=True, separator=', ')" class="address-inline"/></div>
</t>
<t t-if="order.buy_way == 'bill_ship'">
<div><b>Billing <t t-if="same_shipping and not only_services"> &amp; Shipping</t>: </b><span t-esc='order.partner_id' t-options="dict(widget='contact', fields=['address'], no_marker=True, separator=', ')" class="address-inline"/></div>
<div t-if="not same_shipping and not only_services" groups="sale.group_delivery_invoice_address"><b>Shipping: </b><span t-esc='order.partner_shipping_id' t-options="dict(widget='contact', fields=['address'], no_marker=True, separator=', ')" class="address-inline"/></div>
</t>
<xpath expr="//div[hasclass('oe_cart')]/div[hasclass('card', 'mt-3')]/div[hasclass('card-body')]/." position="replace">
<div class="card-body">
<t t-set="same_shipping" t-value="bool(order.partner_shipping_id==order.partner_id or only_services)" />
<t t-if="order.buy_way == 'bill_noship'">
<div><b>Billing : </b><span t-esc='order.partner_id' t-options="dict(widget='contact', fields=['address'], no_marker=True, separator=' ')" class="address-inline"/></div>
</t>
<t t-if="order.buy_way == 'nobill_ship'">
<div t-if="same_shipping and not only_services"><b>Shipping: </b><span t-esc='order.partner_id' t-options="dict(widget='contact', fields=['address'], no_marker=True, separator=', ')" class="address-inline"/></div>
<div t-if="not same_shipping and not only_services" groups="sale.group_delivery_invoice_address"><b>Shipping: </b><span t-esc='order.partner_shipping_id' t-options="dict(widget='contact', fields=['address'], no_marker=True, separator=', ')" class="address-inline"/></div>
</t>
<t t-if="order.buy_way == 'bill_ship'">
<div><b>Billing <t t-if="same_shipping and not only_services"> &amp; Shipping</t>: </b><span t-esc='order.partner_id' t-options="dict(widget='contact', fields=['address'], no_marker=True, separator=', ')" class="address-inline"/></div>
<div t-if="not same_shipping and not only_services" groups="sale.group_delivery_invoice_address"><b>Shipping: </b><span t-esc='order.partner_shipping_id' t-options="dict(widget='contact', fields=['address'], no_marker=True, separator=', ')" class="address-inline"/></div>
</t>
</div>
</xpath>
</template>
</odoo>

0 comments on commit 54a1a47

Please sign in to comment.