Skip to content

Instantly share code, notes, and snippets.

@aek
Last active June 5, 2020 04:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aek/d8a3588e1f8c63f96be242f4d6d75b09 to your computer and use it in GitHub Desktop.
Save aek/d8a3588e1f8c63f96be242f4d6d75b09 to your computer and use it in GitHub Desktop.
Example of an Odoo Template XML rewrite using rare and non-documented inheritance extension
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="recommended_products_ext" inherit_id="website_sale.recommended_products">
<xpath expr="." position="replace">
<t name="Product" t-name="website_sale.recommended_products">
<xpath expr="//div[@id='product_small_description']" position="before">
<div class="container mt32" t-if="product.alternative_product_ids">
<h3>Alternative Products:</h3>
<div class="row mt16" style="">
<t t-foreach="product.alternative_product_ids" t-as="alt_product">
<div class="col-md-2 thumbnail" style="width: 170px; height:130px; float:left; display:inline; margin-right: 10px; overflow:hidden;">
<div class="mt16 text-center" style="height: 100%;">
<div t-field="alt_product.image_small" t-options="{'widget': 'image', 'class': 'img-rounded shadow o_alternative_product' }" />
<h5>
<a t-attf-href="/shop/product/#{ slug(alt_product) }" style="display: block">
<span t-att-title="alt_product.name" t-field="alt_product.name" class="o_text_overflow" style="display: block;" />
</a>
</h5>
</div>
</div>
</t>
</div>
</div>
</xpath>
</t>
</xpath>
</template>
</odoo>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment