summaryrefslogtreecommitdiff
path: root/addons/website_sale_coupon/views/website_sale_templates.xml
blob: 5d67838fab47871b18efa2d66ec061e6d6824af2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<template id="assets_tests" name="Website Sale Coupon Assets Tests" inherit_id="web.assets_tests">
    <xpath expr="." position="inside">
        <script type="text/javascript" src="/website_sale_coupon/static/tests/tours/website_sale_coupon.js"></script>
    </xpath>
</template>
<template id="website_sale_coupon_cart_summary_show_img" inherit_id="website_sale.cart_summary">
    <xpath expr="//td[hasclass('td-img')]/span" position="attributes">
        <attribute name="t-if">not line.is_reward_line or not line.sudo().product_id.image_128</attribute>
    </xpath>
    <xpath expr="//td[hasclass('td-img')]/span" position="after">
        <span t-if="line.is_reward_line and line.sudo().product_id.image_128">
            <img t-att-src="image_data_uri(line.sudo().product_id.image_128)" class="img o_image_64_max rounded"/>
        </span>
    </xpath>
</template>
<template id="website_sale_coupon_cart_hide_qty" inherit_id="website_sale.cart_lines">
    <xpath expr="//td[hasclass('td-img')]/span" position="replace">
        <t t-if="line.is_reward_line and line.sudo().product_id.image_128">
            <span>
                <img t-att-src="image_data_uri(line.sudo().product_id.image_128)" class="img o_image_64_max rounded" t-att-alt="line.name_short"/>
            </span>
        </t>
        <t t-else="">
            <t>$0</t>
        </t>
    </xpath>
    <xpath expr="//td[hasclass('td-qty')]/div" position="attributes">
        <attribute name="t-att-style">line.is_reward_line and "display:none;"</attribute>
    </xpath>
    <xpath expr="//table[@id='cart_products']/tbody//tr//td[hasclass('td-product_name')]//div" position="attributes">
    <!-- Can't xpath "//table[@id='cart_products']/tbody//tr" since optional_product already xpath that one.
         There will be the same xpath attribute class on the same element. Last installed module will only be taken into account -->
        <attribute name="t-att-class">'reward_product' if line.is_reward_line else None</attribute>
    </xpath>
    <xpath expr="//td[hasclass('td-qty')]/div" position="after">
        <t t-if="line.is_reward_line">
            <span class="js_quantity text-muted" t-esc="int(line.product_uom_qty)"/>
        </t>
    </xpath>
    <xpath expr="//del" position="attributes">
        <attribute name="t-if">not line.is_reward_line</attribute>
    </xpath>
</template>
<template id="cart_popover" inherit_id="website_sale.cart_popover" name="Cart Popover">
    <xpath expr="//div[hasclass('cart_line')]/div[1]/span" position="replace">
        <t t-if="line.is_reward_line and line.sudo().product_id.image_128">
            <span>
                <img t-att-src="image_data_uri(line.sudo().product_id.image_128)" class="img o_image_64_max rounded" t-att-alt="line.name_short"/>
            </span>
        </t>
        <t t-else="">
            <t>$0</t>
        </t>
    </xpath>
</template>
<template id="sale_coupon_result" inherit_id="website_sale.coupon_form">
    <xpath expr="//form[@name='coupon_code']" position="after">
        <t t-if="website_sale_order and website_sale_order.applied_coupon_ids">
            <t t-foreach="website_sale_order.applied_coupon_ids" t-as="coupon">
                <div class="alert alert-success text-left mt16" role="alert">
                    You have successfully applied following promo code: <strong t-esc="coupon.code"/>
                </div>
            </t>
        </t>
        <t t-if="website_sale_order and website_sale_order.promo_code">
            <div class="alert alert-success text-left mt16" role="alert">
                You have successfully applied following promo code: <strong t-esc="website_sale_order.promo_code"/>
            </div>
        </t>
        <t t-if="website_sale_order and website_sale_order.generated_coupon_ids">
            <t t-foreach="website_sale_order.generated_coupon_ids.filtered(lambda c: c.state != 'expired')" t-as="coupon">
                <div class="alert alert-success text-left mt16" role="alert">
                    Your reward <strong t-esc="coupon.discount_line_product_id.name"/> is available on a next order with this promo code: <strong t-esc="coupon.code"/>
                </div>
            </t>
        </t>
        <t t-if="request.params.get('code_not_available')">
            <div class="alert alert-danger text-left mt16" role="alert">
                Invalid or expired promo code.
            </div>
        </t>
        <t t-if="website_sale_order.get_promo_code_error(delete=False)">
            <div class="alert alert-danger text-left mt16" role="alert">
                <t t-esc="website_sale_order.get_promo_code_error()"/>
            </div>
        </t>
    </xpath>
    <xpath expr="//t[@name='code_not_available']" position="replace"/>
</template>

<template id="cart_discount" name="Show Discount in Subtotal" customize_show="True" active="False" inherit_id="website_sale.total">
    <xpath expr="//tr[@id='order_total_untaxed']" position="before">
        <tr t-if="website_sale_order and website_sale_order.reward_amount">
          <td class="text-right border-0 text-muted" title="Discounted amount">Discount:</td>
          <td class="text-xl-right border-0 text-muted">
               <span t-field="website_sale_order.reward_amount" style="white-space: nowrap;"
                 class="monetary_field"
                 t-options='{
                          "widget": "monetary",
                          "display_currency": website_sale_order.currency_id,
                 }'/>
          </td>
        </tr>
    </xpath>
</template>

<template id="reduction_coupon_code" inherit_id="website_sale.reduction_code">
    <xpath expr="//t[@t-set='force_coupon']" position="replace">
        <t t-set='force_coupon' t-value="website_sale_order.pricelist_id.code or request.params.get('code_not_available') or website_sale_order.promo_code or website_sale_order.generated_coupon_ids or website_sale_order.applied_coupon_ids or website_sale_order.get_promo_code_error(delete=False)"/>
    </xpath>
</template>

<template id="cart_summary" name="Payment" inherit_id="website_sale.cart_summary">
    <xpath expr="//table[@id='cart_products']/tbody/tr/td[hasclass('td-price')]/child::*" position="attributes">
        <attribute name="t-att-style">'display: None;' if free_shipping_lines and line in free_shipping_lines else ''</attribute>
    </xpath>
</template>
</odoo>