Skip to Content
Menu
This question has been flagged
2 Replies
5254 Views

Hi Guys, I'm trying to learn building websites in Odoo.  I have sort of got the hang of inheriting id's etc.. so have been able to add a new template and place it below the header for example. 


Im now looking to make changes to the product page ( Template ID: website_sale.product). 


if i make the changes in the front end, i can achieve what i need to do, but i understand i shouldn't do this?


Is it possible to me to create a new file ( product.xml for example), and pop it in my theme/views folder and manefest..

then copy everything from website_sale.product into it and make the changes -- then some how override the original template?


What do i need to do to override a whole page template like this?


Or, is it ok to edit the original files, as long as not in the front end? 

if so, where would i find website_sale.product so i can open it and edit it?


If any one can help that would be greatly appreciated.  been trying to figure this out for hours, and im sure its simple!!


Thanks.

Avatar
Discard
Best Answer

Hi,

You can inherit the website_sale.product as follows in your custom module,

<template id="product_add_to_wishlist" inherit_id="website_sale.product" customize_show="True" 
name="Wishlist Button" priority="20">
<xpath expr="//div[@id='product_option_block']" position="inside">
</xpath>
</template>

In the inherit_id you have to specify the id of the record that you need to inherit and apply the changes in the view using the xpath expression.

See a sample in the website_sale_wishlist module inheriting the same template.

<template id="product_add_to_wishlist" inherit_id="website_sale.product" customize_show="True" name="Wishlist Button" priority="20">
<xpath expr="//div[@id='product_option_block']" position="inside">
<t t-set="product_variant" t-value="product_variant or product._create_first_product_variant()"/>
<t t-set="in_wish" t-value="product_variant and product_variant._is_in_wishlist()"/>
<button t-if="product_variant" type="button" role="button" class="btn btn-link mt16 o_add_wishlist_dyn" t-att-disabled='in_wish or None' t-att-data-product-template-id="product.id" t-att-data-product-product-id="product_variant.id" data-action="o_wishlist"><span class="fa fa-heart" role="img" aria-label="Add to wishlist"></span> Add to wishlist</button>
</xpath>
</template>

As you are new into the odoo development, it is not recommended to edit inside the odoo source code, always try to customize by creating a custom module in odoo community, if you are using the enterprise you can use the studio tool also.


For Reference: Odoo Website Development Tutorials

Thanks

Avatar
Discard
Author Best Answer

Thanks for your reply Niyas. 

I have tried what you have above, but im getting an error: "Missing Record  - Error - Remaining: ['Gss product test']"  when i update the theme.

When i remove the code that causes the error, then update the theme, i still get the error. the only way to fix it is to make a new theme.. any idea what's happening?

my manefest:

<code>

{

    'name': 'GSS theme 4',
    'description': 'General theme for shop.',

    'version': '1.0',

    'author': 'sion',

    'category': 'Theme/Ecommerce',

    'depends': ['website', 'website_sale', ],

    'data': [ 'views/assets.xml','views/layout.xml','views/product.xml',

],

}


</code>

And my product.xml

 

<?xml version="1.0" encoding="utf-8" ?>

<odoo>

<template id="gss_product_test" inherit_id="website_sale.product" customize_show="True" 

          name="Gss product test" priority="20">

    <xpath expr="//div[@id='product_option_block']" position="inside">

    <div >does this work?</div>

    </xpath>

</template>

    </odoo>

 


Any help is greatly appreciated .

kind regards

Avatar
Discard
Related Posts Replies Views Activity
0
Nov 24
63
1
Nov 24
248
0
Oct 24
251
1
Oct 24
1491
1
Aug 24
325