Debian Codegraph @

addons/website_sale_comparison/views/website_sale_comparison_template.xml

raw
1 <?xml version="1.0" encoding="utf-8"?>
2 <odoo>
3
4 <!-- Inject the comparison button in products cards -->
5 <template
6 id="website_sale_comparison.add_to_compare"
7 inherit_id="website_sale.shop_product_buttons"
8 name="Comparison List Button"
9 priority="32"
10 >
11 <xpath expr="//div[hasclass('o_wsale_product_action_row')]" position="inside">
12 <t
13 t-set="isCompareAvailable"
14 t-value="product and product.valid_product_template_attribute_line_ids"
15 />
16
17 <t t-if="isCompareAvailable" t-call="website_sale.product_tile_element_visibility">
18 <t t-set="visible_element_class" t-value="'o_wsale_products_opt_has_comparison'"/>
19
20 <t
21 t-set="attrib_categories"
22 t-value="product.valid_product_template_attribute_line_ids._prepare_categories_for_display()"
23 />
24 <t t-set="product_variant_id" t-value="product._get_first_possible_variant_id()"/>
25 <button
26 t-if="product_variant_id and attrib_categories"
27 type="button"
28 class="btn o_add_compare"
29 title="Compare"
30 aria-label="Compare"
31 t-att-data-product-template-id="product.id"
32 t-att-data-product-product-id="product_variant_id"
33 data-action="o_comparelist"
34 >
35 <span class="fa fa-exchange fa-fw o_not-animable"/>
36 <span class="o_label small ms-2">Compare</span>
37 </button>
38
39 </t>
40 <t t-else="" t-call="website_sale.product_tile_element_visibility">
41 <!--
42 Render a placeholder to ensure alignment between entries with and without
43 comparison button
44 -->
45 <div class="o_add_compare_placeholder pe-none opacity-0 btn">
46 <span class="fa fa-exchange fa-fw"/>
47 </div>
48 </t>
49 </xpath>
50 </template>
51
52 <template
53 id="product_add_to_compare"
54 name="Add to comparison in product page"
55 inherit_id="website_sale.cta_wrapper"
56 priority="8"
57 >
58 <xpath expr="//div[@id='product_option_block']" position="inside">
59 <t t-set="attrib_categories" t-value="product.valid_product_template_attribute_line_ids._prepare_categories_for_display()"/>
60 <t t-set="product_variant_id" t-value="product._get_first_possible_variant_id()"/>
61 <t
62 t-set="_button_classes"
63 t-valuef="o_add_compare_dyn btn btn-outline-primary order-last flex-grow-1 flex-sm-grow-0"
64 />
65 <t
66 t-if="not is_view_active('website_sale_wishlist.product_add_to_wishlist') and not is_view_active('website_sale.cta_wrapper_default')"
67 t-set="_button_classes"
68 t-value="_button_classes + ' w-100'"
69 />
70 <t
71 t-if="is_view_active('website_sale.cta_wrapper_large')"
72 t-set="_button_classes"
73 t-value="_button_classes + ' btn-lg px-lg-0'"
74 />
75 <button
76 t-if="product_variant_id and attrib_categories"
77 type="button"
78 t-att-class="_button_classes"
79 aria-label="Add to compare"
80 title="Add to compare"
81 t-att-data-product-product-id="product_variant_id"
82 t-att-data-product-template-id="product.id"
83 data-action="o_comparelist"
84 >
85 <span class="fa fa-exchange"/>
86 <span t-att-class="'d-inline ms-2' + (' d-lg-none' if website.product_page_image_width == '50_pc' and not (is_view_active('website_sale.cta_wrapper_boxed') or is_view_active('website_sale.cta_wrapper_large')) or is_view_active('website_sale_wishlist.product_add_to_wishlist') else '')">Add to compare</span>
87 </button>
88 </xpath>
89 </template>
90
91 <template id="product_attributes_body" inherit_id="website_sale.product" name="Product attributes table">
92 <xpath expr="//div[@id='product_attributes_simple']" position="replace"/>
93 <xpath expr="//div[@id='product_full_description']" position="after">
94 <t t-set="attrib_categories" t-value="product.valid_product_template_attribute_line_ids._prepare_categories_for_display()"/>
95 <t t-if="attrib_categories">
96 <section class="pt32 pb32" id="product_full_spec">
97 <div class="container">
98 <div class="d-flex justify-content-between align-items-center mb-4">
99 <h3 class="m-0">Specifications</h3>
100 </div>
101 <div id="product_specifications">
102 <div class="row">
103 <t t-foreach="attrib_categories" t-as="category">
104 <div class="col-lg-6">
105 <t t-call="website_sale_comparison.specifications_table"/>
106 </div>
107 </t>
108 </div>
109 </div>
110 </div>
111 </section>
112 </t>
113 </xpath>
114 </template>
115
116 <template
117 id="accordion_specs_item"
118 name="Specifications Accordion Item"
119 inherit_id="website_sale.product_accordion"
120 active="False"
121 >
122 <xpath expr="//div[@id='more_information_accordion_item']" position="before">
123 <t
124 t-set="attrib_categories"
125 t-value="product.valid_product_template_attribute_line_ids._prepare_categories_for_display()"
126 />
127 <t
128 t-set="product_variant_id"
129 t-value="product._get_first_possible_variant_id()"
130 />
131 <t t-if="product.valid_product_template_attribute_line_ids._prepare_categories_for_display()">
132 <t t-foreach="attrib_categories" t-as="category">
133 <div class="accordion-item">
134 <div class="accordion-header my-0 h6">
135 <button
136 t-out="category.name"
137 class="accordion-button collapsed fw-medium"
138 type="button"
139 data-bs-toggle="collapse"
140 t-attf-data-bs-target="#category_accordion_{{category_index}}"
141 aria-expanded="false"
142 aria-controls="specifications"
143 >
144 <t t-if="category_size == 1">Specifications</t>
145 <t t-else="">Others</t>
146 </button>
147 </div>
148 <div
149 t-attf-id="category_accordion_{{category_index}}"
150 class="accordion-collapse collapse"
151 data-bs-parent="#product_accordion"
152 >
153 <div class="accordion-body pt-0">
154 <t t-call="website_sale_comparison.specifications_table">
155 <t t-set="is_accordion" t-value="True"/>
156 </t>
157 </div>
158 </div>
159 </div>
160 </t>
161 </t>
162 </xpath>
163 </template>
164
165 <template id="specifications_table" name="Specifications Table">
166 <table t-attf-class="table {{is_accordion and 'table-sm mb-0'}}">
167 <t t-if="len(attrib_categories) > 1 and not is_accordion">
168 <tr>
169 <th class="text-start" colspan="2">
170 <span t-if="category" t-field="category.name"/>
171 <span t-else="">Others</span>
172 </th>
173 </tr>
174 </t>
175 <tr
176 t-foreach="attrib_categories[category].filtered(lambda l: len(l.value_ids) > 1)"
177 t-as="ptal"
178 >
179 <t
180 t-set="hide_border_bottom_classes"
181 t-value="'border-bottom-0' if ptal_last and is_accordion else ''"
182 />
183 <td t-attf-class="w-25 {{hide_border_bottom_classes}} ps-0">
184 <span t-field="ptal.attribute_id.name"/>
185 </td>
186 <td t-attf-class="w-75 {{hide_border_bottom_classes}} pe-0 text-muted text-end">
187 <t t-foreach="ptal.value_ids" t-as="pav">
188 <span t-field="pav.name"/><t t-if="not pav_last">, </t>
189 </t>
190 </td>
191 </tr>
192 <t
193 t-set="single_value_attributes"
194 t-value="attrib_categories[category]._prepare_single_value_for_display()"
195 />
196 <tr t-foreach="single_value_attributes" t-as="attribute">
197 <t
198 t-set="hide_border_bottom_classes"
199 t-value="'border-bottom-0' if attribute_last and is_accordion else ''"
200 />
201 <td t-attf-class="w-25 {{hide_border_bottom_classes}} ps-0 ">
202 <span t-field="attribute.name"/>
203 </td>
204 <td t-attf-class="w-75 {{hide_border_bottom_classes}} pe-0 text-muted text-end">
205 <t t-foreach="single_value_attributes[attribute]" t-as="ptal">
206 <span t-field="ptal.product_template_value_ids._only_active().name"/><t t-if="not ptal_last">, </t>
207 </t>
208 </td>
209 </tr>
210 </table>
211 </template>
212
213 <template id="product_compare" name="Comparator Page">
214 <t t-call="website.layout">
215 <t t-set="additional_title">Shop Comparator</t>
216 <div id="wrap" class="js_sale o_wsale_comparison_page">
217 <div class="oe_structure oe_empty" id="oe_structure_website_sale_comparison_product_compare_1"/>
218 <div t-attf-class="oe_website_sale o_wsale_comparison_page pb-5 #{website.shop_page_container == 'fluid' and 'container-fluid' or 'container'}">
219 <h1 class="h4 mt-4 mb-3">Compare Products</h1>
220
221 <!-- Mini sticky product overview (initially hidden) -->
222 <div
223 class="o_wsale_comparison_mini_sticky fixed-top d-none bg-body"
224 id="miniStickyComparison"
225 >
226 <div t-attf-class="px-3 #{website.shop_page_container == 'fluid' and 'container-fluid' or 'container'}">
227 <div class="o_wsale_comparison_scroll_container overflow-x-auto">
228 <ul class="list-unstyled d-flex align-items-stretch mb-0 py-3">
229 <li
230 t-foreach="products"
231 t-as="product"
232 class="o_wsale_compare_table_column flex-shrink-0"
233 >
234 <a
235 t-att-href="product.website_url"
236 class="d-flex align-items-center gap-2 text-decoration-none text-truncate"
237 >
238 <t
239 t-set="combination_info"
240 t-value="product._get_combination_info_variant()"
241 />
242 <div class="o_mini_product_img_container flex-shrink-0">
243 <img
244 t-att-src="product._get_image_1024_url()"
245 class="img-fluid flex-shrink-0 w-100 h-100 rounded border object-fit-cover"
246 t-att-alt="combination_info['display_name']"
247 />
248 </div>
249 <div class="text-truncate">
250 <h6
251 class="flex-grow-1 text-truncate mb-0 small"
252 t-out="combination_info['display_name']"
253 />
254 <div
255 t-if="not combination_info['prevent_zero_price_sale']"
256 class="text-wrap"
257 >
258 <small
259 class="mb-0 h6 text-body"
260 t-out="combination_info['price']"
261 t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"
262 />
263 <del
264 t-if="combination_info.get('compare_list_price') and (combination_info['compare_list_price'] &gt; combination_info['price'])"
265 class="ms-1 mb-0 text-muted h6 small"
266 t-out="combination_info['compare_list_price']"
267 t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"
268 />
269 <del
270 t-else=""
271 t-attf-class="ms-1 mb-0 text-muted h6 small {{'' if combination_info['has_discounted_price'] else 'd-none'}}"
272 t-out="combination_info['list_price']"
273 t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"
274 />
275 </div>
276 </div>
277 </a>
278 </li>
279 </ul>
280 </div>
281 </div>
282 </div>
283
284 <div class="overflow-x-auto">
285 <div
286 class="table-comparator position-relative"
287 id="o_comparelist_table"
288 >
289 <t
290 t-set="attrib_categories"
291 t-value="products._prepare_categories_for_display()"
292 />
293 <ul class="list-unstyled d-flex mb-0">
294 <li
295 t-foreach="products"
296 t-as="product"
297 class="o_wsale_compare_table_column position-relative d-flex flex-column flex-shrink-0"
298 >
299 <t
300 t-set="combination_info"
301 t-value="product._get_combination_info_variant()"
302 />
303 <a t-att-href="product.website_url">
304 <img
305 t-att-src="product._get_image_1024_url()"
306 class="img img-fluid w-100 h-100 object-fit-cover border rounded"
307 alt="Product image"
308 />
309 </a>
310 <button
311 t-att-data-product-product-id="product.id"
312 class="o_comparelist_remove btn position-absolute top-0 end-0 mx-3 my-2 p-2 rounded-circle bg-white-75 lh-1"
313 aria-label="Remove product from comparison"
314 >
315 <i class="oi oi-close"/>
316 </button>
317 </li>
318 </ul>
319 <ul class="list-unstyled d-flex mb-0 pt-3 pb-5">
320 <li
321 t-foreach="products"
322 t-as="product"
323 class="o_wsale_compare_table_column position-relative d-flex flex-column flex-shrink-0"
324 >
325 <t
326 t-set="combination_info"
327 t-value="product._get_combination_info_variant()"
328 />
329 <div
330 id="o_comparelist_product_name"
331 class="product_summary d-flex flex-column h-100"
332 >
333 <a t-att-href="product.website_url">
334 <h6 t-out="product.display_name"/>
335 </a>
336 <span t-if="not combination_info['prevent_zero_price_sale']">
337 <span t-out="combination_info['price']"
338 t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"/>
339 <del
340 t-if="combination_info.get('compare_list_price') and (combination_info['compare_list_price'] &gt; combination_info['price'])"
341 class="me-2 text-muted text-nowrap"
342 t-out="combination_info['compare_list_price']"
343 t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"
344 />
345 <del
346 t-else=""
347 t-attf-class="text-muted me-2 text-nowrap {{'' if combination_info['has_discounted_price'] else 'd-none'}}"
348 t-out="combination_info['list_price']"
349 t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"
350 />
351 <small t-if="combination_info.get('base_unit_price')"
352 class="d-block text-muted">
353 <t t-call="website_sale.base_unit_price">
354 <t t-set="base_unit_price" t-value="combination_info['base_unit_price']"/>
355 </t>
356 </small>
357 </span>
358 <div class="mt-auto pt-3">
359 <a
360 t-if="combination_info['prevent_zero_price_sale']"
361 t-att-href="website.contact_us_button_url + '?subject=' + combination_info['display_name']"
362 class="btn btn-primary btn_cta"
363 >
364 Contact Us
365 </a>
366 <button
367 t-else=""
368 name="comparison_add_to_cart"
369 class="btn btn-primary"
370 t-att-data-product-product-id="product.id"
371 t-att-data-product-template-id="product.product_tmpl_id.id"
372 t-att-data-show-quantity="is_view_active('website_sale.product_quantity')"
373 >
374 <i class="fa fa-shopping-cart me-2" aria-hidden="true"/>Add to Cart
375 </button>
376 </div>
377 </div>
378 </li>
379 </ul>
380 <div t-foreach="attrib_categories" t-as="category">
381 <div class="w-100 py-3 bg-light bg-opacity-50">
382 <h6 class="d-table position-sticky start-0 mb-0 ps-2">
383 <span t-if="category" t-field="category.name"/>
384 <t t-else="">Uncategorized</t>
385 </h6>
386 </div>
387 <ul
388 t-foreach="attrib_categories[category]"
389 t-as="attribute"
390 t-att-class="'list-unstyled d-flex mb-0 py-3 o_ws_category_%d %s' % (category.id, 'border-bottom' if not attribute_last else '')"
391 >
392 <li
393 t-foreach="attrib_categories[category][attribute]"
394 t-as="product"
395 class="o_wsale_compare_table_column d-flex flex-column flex-shrink-0"
396 >
397 <div id="o_comparelist_attribute">
398 <t t-if="attrib_categories[category][attribute][product]">
399 <div
400 class="small text-muted"
401 t-field="attribute.name"
402 />
403 <t
404 t-foreach="attrib_categories[category][attribute][product]"
405 t-as="ptav"
406 >
407 <small t-field="ptav.name"/><t t-if="not ptav_last">, </t>
408 </t>
409 </t>
410 <t t-else="">
411 <div
412 class="small text-muted"
413 t-field="attribute.name"
414 />
415 <h6 class="small text-muted mb-0">-</h6>
416 </t>
417 </div>
418 </li>
419 </ul>
420 </div>
421 <t t-if="is_view_active('website_sale.product_tags') and any([product.all_product_tag_ids for product in products])">
422 <h6 class="d-table position-sticky start-0 mb-0">Tags</h6>
423 <ul class="list-unstyled d-flex border-bottom mb-0 py-3">
424 <li
425 t-foreach="products"
426 t-as="product"
427 class="o_wsale_compare_table_column d-flex flex-column align-items-center flex-shrink-0"
428 >
429 <div class="small text-muted">Tags</div>
430 <t t-call="website_sale.product_tags">
431 <t
432 t-set="all_product_tags"
433 t-value="product.all_product_tag_ids"
434 />
435 </t>
436 </li>
437 </ul>
438 </t>
439 </div>
440 </div>
441 </div>
442 <div class="oe_structure" id="oe_structure_website_sale_comparison_product_compare_2"/>
443 <div class="align-items-end bottom-0 d-flex end-0 justify-content-end o_not_editable p-0 position-absolute top-0 start-0 pe-none">
444 <div class="o_wsale_comparison_bottom_bar sticky-bottom flex-shrink-0 w-100 bg-body pe-auto">
445 <div t-attf-class="d-flex align-items-center py-3 #{website.shop_page_container == 'fluid' and 'container-fluid' or 'container'}">
446 <button
447 class="btn btn-link ps-0 text-decoration-none"
448 aria-label="Continue shopping"
449 name="comparison_back_button"
450 >
451 <i class="oi oi-chevron-left me-1"/> Back to shop </button>
452 <button
453 class="button btn btn-light ms-auto"
454 aria-label="Remove all products from comparison"
455 name="comparison_clear_all_button"
456 >
457 Remove all
458 </button>
459 </div>
460 </div>
461 </div>
462 </div>
463 </t>
464 </template>
465
466 </odoo>