Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
4 Risposte
32560 Visualizzazioni

I'm trying to add change the text displayed on a template. The template allready inherits the inherits the main shop template and adds a feature. I want to change the text and add a div. But I cannot get the element. It throws the cannot find element error.

Template:

<template id="products" inherit_id="website_sale.products" priority="15">
	<xpath expr="//div[hasclass('o_wsale_products_main_row')]" position="before">
		<t t-if="some condition">
			<t t-if="some condition">
				<div class="col-12">
					<h5 class="mb-3">Categories</h5>

I want to replace the h5 element:

<xpath expr="//h5[@class='mb-3']" position="replace">

Tried also with:

<xpath expr="//h5[hasclass('mb-3')]" position="replace">

But it throws the same error

Element '<xpath expr="//h5[@class='mb-3']">' cannot be located in parent view



Avatar
Abbandona
Risposta migliore

Hi,

Please try using the below line of code

example:


<template id="products" inherit_id="website_sale.products" priority="15">

    <xpatth expr = "//t[@t-if='some condition']//t[@t-if='some condition']//div[hasclass('col-12')]//h5" position="replace">


  //Your value


</xpath>



Avatar
Abbandona
Risposta migliore

Hi,

Sometimes its better to give the complete xpath , here you need not mention the complete path, just try giving the div class oe_website_sale  before  o_wsale_products_main_row ,

<xpath expr="//div[hasclass('oe_website_sale')]/div[hasclass('o_wsale_products_main_row')]" position="before">    
    your conditions, div,  etc

</xpath>

                                                                    or 

<xpath expr="//div[hasclass('oe_website_sale')]" position="inside"> 

    your conditions, div,  etc
</xpath>


Hope it helps,

Thanks

Avatar
Abbandona
Risposta migliore

Hi ,

This h5 tag is in template "products" in your custom module

so to replace or to make any changes you have to inherit "Custom_module.products".

Hope this helps

regards

Avatar
Abbandona
Autore

I do inherit the custom module template. But cannot even select the xpath node to replace the whole one.

Please make sure that you have added custom_module to depends in manifest

Autore

It is. Working with odoo more than 3 years so lets assume that those basic things are correct. This is the 1st time I needed to change something that is in xpath, and I thought it will be as easy like you suggested but it doesn't work

Well that's how we make changes on an Xpath element. If you are still getting an error, then one have to look to the basics.I am sure that a person with over 3yr experience in odoo will be able to figure that out by himself.

Post correlati Risposte Visualizzazioni Attività
1
mar 24
4774
1
ott 20
13277
2
mar 24
2814
1
gen 24
1611
0
ott 23
1558