summaryrefslogtreecommitdiff
path: root/addons/website_sale_comparison/views/website_sale_comparison_template.xml
blob: 1f354b8f255340dc4df6757e97480471086b63ab (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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<?xml version="1.0" encoding="utf-8"?>
<odoo>

    <template id="assets_frontend" inherit_id="website.assets_frontend" name="Comparison assets frontend">
        <xpath expr="." position="inside">
            <link rel="stylesheet" type="text/scss" href="/website_sale_comparison/static/src/scss/website_sale_comparison.scss"/>
            <script type="text/javascript" src="/website_sale_comparison/static/src/js/website_sale_comparison.js"></script>
        </xpath>
    </template>

    <template id="assets_tests" inherit_id="web.assets_tests" name="Website Sale Comparison Assets Tests">
        <xpath expr="." position="inside">
            <script type="text/javascript" src="/website_sale_comparison/static/tests/tours/website_sale_comparison.js"></script>
        </xpath>
    </template>

    <template id="add_to_compare" inherit_id="website_sale.products_item" customize_show="True" name="Comparison List" priority="22">
        <xpath expr="//div[hasclass('o_wsale_product_btn')]" position="inside">
            <t t-set="product_variant_id" t-value="product._get_first_possible_variant_id()"/>
            <button t-if="product_variant_id" type="button" role="button" class="d-none d-md-inline-block btn btn-secondary o_add_compare" title="Compare" aria-label="Compare" t-att-data-product-product-id="product_variant_id" data-action="o_comparelist"><span class="fa fa-exchange"></span></button>
        </xpath>
    </template>

    <template id="product_add_to_compare" name='Add to comparison in product page' inherit_id="website_sale.product" priority="8">
        <xpath expr="//div[@id='product_option_block']" position="inside">
            <t t-if="is_view_active('website_sale_comparison.add_to_compare')">
                <t t-set="product_variant" t-value="product_variant or product._create_first_product_variant()"/>
                <button t-if="product_variant" type="button" role="button" class="d-none d-md-inline-block btn btn-link mt16 o_add_compare_dyn" aria-label="Compare" t-att-data-product-product-id="product_variant.id" data-action="o_comparelist"><span class="fa fa-exchange"></span> Add to compare</button>
            </t>
        </xpath>
    </template>

    <template id="product_attributes_body" inherit_id="website_sale.product" customize_show="True" name="Product attributes table">
        <xpath expr="//div[@id='product_attributes_simple']" position="replace"/>
        <xpath expr="//div[@id='product_full_description']" position="after">
            <section class="container pt-5" id="product_full_spec">
                <t t-set="categories" t-value="product.valid_product_template_attribute_line_ids._prepare_categories_for_display()"/>
                <t t-if="categories">
                    <h3 class="text-center mb32">Specifications for <t t-esc="product.name"/></h3>
                    <div class="row">
                        <div class='col-lg-8 offset-lg-2' id='product_specifications'>
                            <table class='table table-striped table-sm table-hover'>
                                <t t-foreach="categories" t-as="category">
                                    <t t-if="len(categories) > 1">
                                        <tr class="clickable" data-toggle="collapse" t-att-data-target="'.o_ws_category_%d' % category.id">
                                            <th class="text-left" t-att-colspan="2">
                                                <span t-if="category" t-field="category.name"/>
                                                <span t-else="">Uncategorized</span>
                                            </th>
                                        </tr>
                                    </t>
                                    <tr t-foreach="categories[category].filtered(lambda l: len(l.value_ids) > 1)" t-as="ptal" t-att-class="'collapse show o_ws_category_%d' % category.id">
                                        <td><span t-field="ptal.attribute_id.name"/></td>
                                        <td>
                                            <t t-foreach="ptal.value_ids" t-as="pav">
                                                <span t-field="pav.name"/><t t-if="not pav_last"> or</t>
                                            </t>
                                        </td>
                                    </tr>
                                    <t t-set="single_value_attributes" t-value="categories[category]._prepare_single_value_for_display()"/>
                                    <tr t-foreach="single_value_attributes" t-as="attribute" t-att-class="'collapse show o_ws_category_%d' % category.id">
                                        <td><span t-field="attribute.name"/></td>
                                        <td>
                                            <t t-foreach="single_value_attributes[attribute]" t-as="ptal">
                                                <span t-field="ptal.product_template_value_ids._only_active().name"/><t t-if="not ptal_last">, </t>
                                            </t>
                                        </td>
                                    </tr>
                                </t>
                            </table>
                        </div>
                    </div>
                </t>
            </section>
        </xpath>
    </template>

    <template id='recommended_product' inherit_id="website_sale.recommended_products" name="Alternative Products">
        <xpath expr="//h3" position="replace">
            <!--
                Create the first variant if it doesn't exist for the current
                product and every alternative product because the product
                comparator need the variants and not the templates.
            -->
            <t t-set="product_variant" t-value="product_variant or product._create_first_product_variant()"/>
            <t t-set="id_list" t-value="[product_variant.id] if product_variant else []"/>
            <t t-foreach="product.alternative_product_ids" t-as="alt_product">
                <t t-set="alt_product_variant_id" t-value="alt_product._create_first_product_variant().id"/>
                <t t-if="alt_product_variant_id" t-set="id_list" t-value="id_list + [alt_product_variant_id]"/>
            </t>
            <t t-set="ids" t-value="','.join([str(id) for id in id_list])"/>
            <div><span class='h3'>Suggested alternatives: </span><a t-if="len(id_list) > 1 and is_view_active('website_sale_comparison.add_to_compare')" role="button" class="btn btn-primary" t-attf-href="/shop/compare/?products=#{ids}"><i class="fa fa-exchange"></i> Compare</a></div>
        </xpath>
    </template>

    <template id="product_compare" name="Comparator Page">
        <t t-call="website.layout">
            <t t-set="additional_title">Shop Comparator</t>
            <div id="wrap" class="js_sale">
                <div class="oe_structure oe_empty" id="oe_structure_website_sale_comparison_product_compare_1"/>
                <div class="container oe_website_sale pt-3">
                    <section class="container">
                        <h3>Compare Products</h3>
                        <table class="table table-bordered table-hover text-center mt16 table-comparator" id="o_comparelist_table">
                            <t t-set="categories" t-value="products._prepare_categories_for_display()"/>
                            <thead>
                                <tr>
                                    <td t-if="len(categories)" class='o_ws_compare_image td-top-left border-bottom-0'/>
                                    <td t-foreach="products" t-as="product" class="o_ws_compare_image position-relative border-bottom-0">
                                        <a href="#" t-att-data-product_product_id="product.id" class="o_comparelist_remove" t-if="len(products) &gt; 2">
                                            <strong>x</strong>
                                        </a>
                                        <a t-att-href="product.website_url">
                                            <img t-attf-src="/web/image/product.product/#{product.id}/image_256" class="img img-fluid" style="margin:auto;" alt="Product image"/>
                                        </a>
                                    </td>
                                </tr>
                                <tr>
                                    <td t-if="len(categories)" class='td-top-left border-top-0'/>
                                    <td t-foreach="products" t-as="product" class="border-top-0">
                                        <t t-set="combination_info" t-value="product._get_combination_info_variant()"/>
                                        <div class='product_summary'>
                                            <a class="o_product_comparison_table" t-att-href="product.website_url">
                                                <span t-esc="combination_info['display_name']"></span><br/>
                                            </a>

                                            <span>
                                                <strong>Price:</strong>
                                                <del t-attf-class="text-danger mr8 {{'' if combination_info['has_discounted_price'] else 'd-none'}}" style="white-space: nowrap;" t-esc="combination_info['list_price']" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}" />
                                                <span t-esc="combination_info['price']" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"></span>
                                            </span>

                                            <form action="/shop/cart/update" method="post" class="text-center">
                                            <input type="hidden" name="csrf_token" t-att-value="request.csrf_token()" />
                                                <input name="product_id" t-att-value="product.id" type="hidden"/>
                                                <a role="button" class="btn btn-primary btn-block a-submit" href="#"><i class="fa fa-shopping-cart"></i>&amp;nbsp;Add to Cart</a>
                                            </form>
                                        </div>
                                    </td>
                                </tr>
                            </thead>
                            <tbody>
                                <t t-foreach="categories" t-as="category">
                                    <t t-if="len(categories) &gt; 1">
                                        <tr class="clickable" data-toggle="collapse" t-att-data-target="'.o_ws_category_%d' % category.id">
                                            <th class="text-left" t-att-colspan="len(products) + 1"><i class="fa fa-chevron-circle-down o_product_comparison_collpase" role="img" aria-label="Collapse" title="Collapse"></i><span t-if="category" t-field="category.name"/><span t-else="">Uncategorized</span></th>
                                        </tr>
                                    </t>
                                    <tr t-foreach="categories[category]" t-as="attribute" t-att-class="'collapse show o_ws_category_%d' % category.id">
                                        <td><span t-field="attribute.name"/></td>
                                        <td t-foreach="categories[category][attribute]" t-as="product">
                                            <t t-foreach="categories[category][attribute][product]" t-as="ptav">
                                                <span t-field="ptav.name"/><t t-if="not ptav_last">, </t>
                                            </t>
                                        </td>
                                    </tr>
                                </t>
                            </tbody>
                        </table>
                    </section>
                </div>
                <div class="oe_structure" id="oe_structure_website_sale_comparison_product_compare_2"/>
            </div>
        </t>
    </template>

    <template id="product_product" name="Comparator - Product row in comparator popover">
        <t t-set="combination_info" t-value="product._get_combination_info_variant()"/>
        <div class="row no-gutters align-items-center my-1 o_product_row" t-att-data-category_ids="product.public_categ_ids.ids">
            <div class="col-3 text-center">
                <img class="img o_image_64_max" t-att-src="website.image_url(product, 'image_128')" alt="Product image"/>
            </div>
            <div class="col-8 pl-2">
                <h6>
                    <a t-att-href="product.website_url"><t t-esc="combination_info['display_name']" /></a><br/>
                    <del t-attf-class="text-danger mr8 {{'' if combination_info['has_discounted_price'] else 'd-none'}}" style="white-space: nowrap;" t-esc="combination_info['list_price']" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}" />
                    <span t-esc="combination_info['price']" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"></span>
                </h6>
            </div>
            <div class="col-1 text-right">
                <a href='#' class="o_remove" title="Remove" t-att-data-product_product_id="product.id">
                    <i class="fa fa-trash" role="img" aria-label="Remove"></i>
                </a>
            </div>
        </div>
    </template>

</odoo>