I want to create a new theme for odoo. I have done it by create a new module and install it. I see in this document here which said that odoo support template inheritance by using t-extend keyword. However I can't make it.
This is my customized template:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="website.homepage" name="Homepage" page="True">
<div class="header">
<h1>FOO<h1>
<div class="main">
</div>
</div>
</template>
<template id="website.contact" name="Homepage" page="True">
<t t-extend="website.homepage">
<t t-jquery="div.main" t-operation="inner">
<h1>FOO 2</h1>
</t>
</t>
</template>
</data>
</openerp>
Template website.contact should have showed FOO and FOO 2 but it only showed FOO 2.
Please help me explain it. Thanks.
You use a syntax for client side templates, but those are server side templates. You use inheritance with server side templates this:
<template id="contact" inherit_id="website.homepage">
<xpath expr="//div[#class='main']" position="inside">
<h1>FOO 2</h1>
</xpath>
</template>
You can read more in the official documentation.
You are trying to create new theme.? and are you using odoo 8.0.? I am asking this because the link you posted is for OpenERP 7.0
So for Odoo 8.0 new documentation is available see here and for QWEB you can find it here QWEB.
Now Main thing if you are trying to create new theme for CMS or Website module then you must go through these steps.
Using Xpath here you can Inherit and make changes on parent tempaltes, examples follows.
<template id="homepage_extend" inherit_id="website.homepage">
<xpath expr="//div[#class='main']" position='inside'>
<h1>FOO 2</h1>
</xpath>
</template>
or try
<template id="homepage_extend" inherit_id="website.homepage">
<xpath expr="//div[#class='header']" position='replace'>
<div class="header">
<h1>FOO<h1>
<div class="main">
<h1>FOO 2</h1>
</div>
</div>
</xpath>
</template>
You can also try these by overriding that template like:
<template id="website.homepage">
<div class="header">
<h1>FOO<h1>
<div class="main">
<h1>FOO 2<h1>
</div>
</div>
</template>
while overriding don't forget to gave the exact id followed by module name.
Cheers !
In parent template, add <t t-raw="0"/> or <t t-raw="name"/>, template: ...code html...
https://www.odoo.com/documentation/9.0/reference/qweb.html
Hello Minh-Hung Nguyen,
Try this code,
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="website.homepage" name="Homepage" page="True">
<div class="header">
<h1>FOO<h1>
<div class="main">
</div>
</div>
</template>
<template id="website.contact" name="Homepage" page="True">
<t t-extend="website.homepage">
<!-- Use 'append' to add the h1 tag inside main div -->
<t t-jquery="main" t-operation="append">
<h1>FOO 2</h1>
</t>
</t>
</template>
</data>
</openerp>
I hope my answer is helpfull for you.
Related
I am trying to extend a qweb template view. But it's not working.
Here is my code.
my_module/static/src/xml/website.xml
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-extend="website.homepage_editor_welcome_message" >
<t t-jquery=".lead" t-operation="replace">
<p class="lead second_head">Let's start designing.</p>
</t>
</t>
</templates>
Here is the original code from the website module.
<div t-name="website.homepage_editor_welcome_message" class="container text-center o_homepage_editor_welcome_message">
<h2 class="mt0">Welcome to your <b>Homepage</b>!</h2>
<p class="lead">Let's start designing.</p>
<div class="o_tooltip_container">Follow all the <div class="o_tooltip bottom"/> signs to get your website ready in no time.</div>
</div>
And add the XML file in __manifest__.py like below.
'qweb': ['static/src/xml/website.xml'],
But no change in website.
How can i do it?
The only way I was able to find to be able to inherit a Qweb template declared with t-name is to redefine it in your custom module, change the code directly. You will be overriding the existing one.
How to open tree view when click on kanban card when use
oe_kanban_global_click
It goes to form view but i want on click, goes to tree view. Below code i used:
<templates>
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_color_#{kanban_getcolor(record.color.raw_value)} oe_kanban_card oe_kanban_global_click">
<div class="o_kanban_record_bottom">
<div class="oe_kanban_bottom_left">
<span><strong>Weather: </strong><t t-esc="record.weather_type.value"/></span>
</div>
<div class="oe_kanban_bottom_right">
<span><strong>Humidity: </strong><t t-esc="record.humidity.value"/>%</span>
</div>
</div>
</div>
</t>
</templates>
I am using odoo 9 enterprise version.
I have to customize header and footer of accounting reports e.g. Profit and loss, Balance Sheet in PDF file.
I searched a lot but seems helpless to customized header and footer.
Thanks in advance.
in Account reports where ever header and footer is not coming there odoo using to call report.internal_layout.by inheriting those report change report.external_layout.
this is my code for custom header and footer by inheriting odoo header and footer.
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<template id="external_layout_header_inherit_cr"
inherit_id="report.external_layout_header">
<xpath expr="//div[#class='header']" position="replace">
<div class="header">
<!-- you're code here -->
</div>
</xpath>
</template>
<template id="external_layout_footer_inherit_cr"
inherit_id="report.external_layout_footer">
<xpath expr="//div[#class='footer']" position="replace">
<div class="footer">
<!-- you're code here -->
</div>
</xpath>
</template>
</data>
</odoo>
now i'm changing odoo financial report by inherting it.
<template id="report_financial_inherit"
inherit_id="module_name.inherit_id">
<xpath expr="//t[#t-call='report.internal_layout']" position="replace">
<!-- here they are calling internal report only but i'm using
external layout becoz in external layout i have header and footer -->
<t t-call="report.external_layout">
<div class="page">
<!--add oddo financial report code/ your custom code-->
</div>
</t>
</xpath>
</template>
I hope you understand what actually work..or do.
I created a custom snippet on Odoo 8. Basically it is a slideshow component from uikit that I want to insert as a content inside .row bootstrap elements, that is, inside another snippet. Below is my code. However, when I try to remove the slideshow snippet via the Website builder (not the HTML Editor), it still appears after saving. The only way I can remove it is by editing it from the HTML Editor. What could be wrong?
<openerp>
<data>
<template id="snippet_blocks" inherit_id="website.snippets" name="Snippet Blocks">
<!-- Create new group called Essentials-->
<xpath expr="div[1]/ul" position="inside">
<li>
Essentials
</li>
</xpath>
<xpath expr="div/div/div[#id='snippet_effect']" position="after">
<div id="snippet_essentials" class="tab-pane">
<!-- Slideshow Snippet -->
<div class="we_snippet">
<!-- Snippet thumnail-->
<div class="oe_snippet_thumbnail">
<img class="oe_snippet_thumbnail_img"
src="/sci5_website_essentials/static/img/slideshow.png"/>
<span class="oe_snippet_thumbnail_title">Slideshow</span>
</div>
<!-- Snippet code to insert-->
<div class="oe_snippet_body we_slideshow col-md-8 mb128">
<t t-call="sci5_website_essentials.snippet_slideshow"/>
</div>
</div>
</div>
</xpath>
</template>
<template id="snippet_options" inherit_id="website.snippet_options" name="Snippet Options">
<xpath expr="." position="inside">
<div data-snippet-option-id='snippet_essentials'
data-selector=".we_slideshow"
data-selector-siblings=".row > [class*='col-md-']"
data-selector-children=".row">
</div>
</xpath>
</template>
</data>
</openerp>
This is the snippet body:
<openerp>
<data>
<template id="snippet_slideshow" name="Slideshow">
<section class="snippet_slideshow">
<ul class="uk-slideshow" data-uk-slideshow="{autoplay:true}">
<li>
<img src="/website/static/src/img/library/business_conference.jpg"/>
</li>
<li>
<img src="/website/static/src/img/library/gears.png"/>
</li>
<li>
<img src="/website/static/src/img/library/engineer.jpg"/>
</li>
</ul>
</section>
</template>
</data>
</openerp>
I recently solved it by placing the snippet block's template to the snippets template itself. Apparently there is a problem with calling the subtemplate.
When I drag the snippet inside another snippet, I'm actually dragging the <t t-call="template_name"> tag into another snippet. It means that one cannot change the template right in where it is dragged but only by editing the subtemplate itself, which means that when it is dragged into some other template, the changes is inherited, and which is very unlikely expected.
Go to Settings, and clear all those snippet things from particular view file.
Settings -> General Settings -> User Interface -> Views
Then,
Find your
view & edit it
.
Clear template code which you cant to clear.
Note : Before delete any section please correct one time it.
I'm writing a module on Odoo (OpenERP) v.8 to allow timesheet's print.
I'm using QWeb report type, but I can't use the fields that I need to use.
If I call a field from res_company module, it works correctly.
<template id="report_timesheet_document">
<t t-call="report.external_layout">
<div class="page">
<div class="row">
<div>
<span t-esc="res_company.name"/>
</div>
</div>
If I call a field from other modules, like res_partner, it doesn't work.
I can't use fields from the current object (timesheet, inherited from hr_timesheet_sheet.sheet).
If I use t-esc:
<span t-esc="o.date_from"/>
QWebException: "'NoneType' object has no attribute 'date_from'" while
evaluating 'o.date_from'
If I use t-field
<span t-field="o.date_from"/>
QWebException: 'NoneType' object has no attribute '_all_columns'
How can I resolve? Thanks.
Fixed:
<template id="report_timesheet">
<t t-call="report.html_container">
<t t-foreach="doc_ids" t-as="doc_id">
<t t-raw="translate_doc(doc_id, doc_model, 'user_id.partner_id.lang', 'hr_timesheet_print.report_timesheet_document')"/>
</t>
</t>
</template>