Inheriting template tags and adding custom fields? - odoo-8

I am working on POS module in "POS.xml" file it was containing below template code which I have to inherit that template tag to my module.
Exsiting code:
<templates id="template" xml:space="preserve">
<t t-name="OrderWidget">
<div class="order-container">
<div class="order-scroller touch-scrollable">
<div class="order">
<ul class="orderlines">
<t t-if="orderlines.length === 0">
<li class="orderline empty">
Your shopping cart is empty
</li>
</t>
</ul>
<div class="summary clearfix">
<div t-attf-class="line #{orderlines.length === 0 ? 'empty' : ''}">
<div class='entry total'>
<span class="label">Total: </span> <span class="value">0.00 €</span>
<div class='subentry'>Taxes: <span class="value">0.00€</span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</t>
<templates>
In my module gst_view.xml:
<template id="contact" inherit_id="point_of_sale.template">
<xpath expr="//form/t/div/div/div/div/div/div/div/[#class='subentry']" position="after">
<h1>FOO 2</h1>
</xpath>
</template>
I tried with this code but it was showing Internal server error.I have to add my content under "Total:","Taxes:".Please check and guide me.

The inheritance of a template and view it's not the same, you need to use:
To your case it's a template inheritance:
<t t-extend="OrderWidget">
<t t-jquery="div[class='subentry']" t-operation="after">
<h1>FOO 2</h1>
</t>
</t>
I hope this answer can be helful for you.

Related

footer is not visible in qweb report

I have used the custom header & footer in qweb report ,In my report header is visible,but footer is not visible.Please help me
Odoo version-8.00, wkhtmltopdf version-0.12.2.1(with patched qt)
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_myreport">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<div class="header">
<div class="row" style="border-bottom: 1px solid black;">
<div class="col-xs-2">
<img t-if="company.logo" t-att-src="'data:image/png;base64,%s' % company.logo" style="height:120px; width:180px;"/>
</div>
</div>
</div>
<div class="page">
This is my Page
</div>
<div class="footer">
<div class="text-center" style="border-top: 1px solid black;">
<p class="list-inline">
this my footer
</p>
<p>Phone: +917455462155 | Email: example#gmail.com </p>
</div>
</div>
</t>
</t>
</template>
</data>
</openerp>
Have you tried the recommended wkhtmltopdf version?
https://www.odoo.com/documentation/8.0/setup/install.html
wkhtmltopdf ... The recommended version is 0.12.1

append div with another div content using xpath

I want to append div using xpath inheriting a parent template.
for ex.
this is parent template
<template id="parent_id">
<div id="header">
<div class="container">
<h1> HEADER </h1>
</div>
</div>
<div id="product">
<div class="container">
<!-- THERE IS SOME CONTENT -->
</div>
</div>
</template>
i want to change like this,
<template id="parent_id">
<div id="product">
<div class="inner">
<div class="container">
<!-- THERE IS SOME CONTENT -->
</div>
</div>
</div>
</template>
i try this,
<template id="product_custom" inherit_id="parent_id">
<xpath expr="//div[#id='product']" position="after">
<div class="inner">
</xpath>
</template>
while replace all content is easy or copy all content to custom template, but it not proper way. i want to wrap a div on content.
I think you cannot do that, because you are going either to override the content or to place your <div/> before, after on inside the selected element.
A simple solution will be to give the id="product" div the class inner by using position="attributes". Or if you really need this, a possible solution is:
replace id="product" with class="inner" with one override using attributes position
define your own template in a second override and call the original one inside it
You will end up with something like this:
<template id="my_parent" inherit_id="foo.parent_id">
<div id="product">
<t t-call="foo.parent_id" />
</div>
</template>
plus the override of the attributes. Never done something like this and the code above is not tested but it could work ;)

How to override default odoo 8 website header section

I am trying to override default header section of odoo 8 website with my own design but am getting errors when i use xpath expression and do a replace. See code below :
header.xml code
<template id="layout_replace_menu_header" customize_show="True" inherit_id="website.layout" name="custom_header_replace">
<xpath expr="//div[#class='navbar navbar-default navbar-static-top']" position="replace">
<header>
<div class="header">
<div class="container">
<a class="site-logo" href="#"><img src="/themeotb2/static/otbassets/img/logo.png" alt="image" /></a>
<i class="fa fa-bars"></i>
<!-- BEGIN NAVIGATION -->
<div class="header-navigation pull-right font-transform-inherit">
<ul>
<t t-foreach="website.menu_id.child_id" t-as="submenu">
<li class="dropdown">
<t t-call="website.submenu"/>
</li>
</t>
<!-- BEGIN TOP SEARCH -->
<li class="menu-search">
<span class="sep"></span>
<i class="fa fa-search search-btn"></i>
<div class="search-box">
<form action="#">
<div class="input-group">
<input type="text" placeholder="Search" class="form-control" />
<span class="input-group-btn">
<button class="btn btn-primary" type="submit">Search</button>
</span>
</div>
</form>
</div>
</li>
<!-- END TOP SEARCH -->
</ul>
</div>
<!-- END NAVIGATION -->
</div>
</div>
</header>
</xpath>
</template>
When i use "inside" instead of replace the code will execute but when i do replace odoo complains with errors:
File "/opt/openerp/ttfa/projectdatabase/src/openerp/models.py", line 1270, in _validate_fields
raise ValidationError('\n'.join(errors))
ParseError: "ValidateError
Field(s) `arch` failed against a constraint: Invalid view definition
Error details:
Element '<xpath expr="//header//a[#class='navbar-brand']">' cannot be located in parent view
Error context:
View `Show Logo`
How can i solve this? Thank you.
Either You have to override template "layout_logo_show" or disable "Show Logo" from website Customize setting.
Thank You!

BEM naming for wrappers for repeated blocks

I am unsure of the best way to name my BEM blocks, where they require a wrapper.
For example, given the following markup:
<div class="products-list">
<div class="product__item">
<div class="product__item__title">Product 1</div>
<img class="product__item__image" />
</div>
<div class="product__item">
<div class="product__item__title">Product 2</div>
<img class="product__item__image" />
</div>
</div>
I feel that the top wrapper (products-list) is kind of lost.
It's obviously too deep to use something like:
products-list__product__item__image
So, how do we handle wrappers in BEM where the child elements are also wrappers?
With two blocks .product-list and product-item.
<div class="product-list">
<div class="product-list__item product-item">
<div class="product-item__title">Product 1</div>
<img class="product-item__image" />
</div>
<div class="product-list__item product-item">
<div class="product-item__title">Product 2</div>
<img class="product-item__image" />
</div>
</div>
Here the elements .product-list__item share the node with blocks .product-item.
Or, if the CSS rules for your list can be reused in your design, you can rename .product-list to a more generic .list:
<div class="list">
<div class="list__item product-item">
<div class="product-item__title">Product 1</div>
<img class="product-item__image" />
</div>
<div class="list__item product-item">
<div class="product-item__title">Product 2</div>
<img class="product-item__image" />
</div>
</div>

Login menu not appearing when created using meteor

I am new to Meteor of course for developing filed as well. I have created a login UI using meteor, but it is not visible. I am able to see through inspect element using console. Can some one tell me what went wrong.
<body>
<div class="container">
{{> header}}
<div id="main" class="row-fluid">
{{renderPage}}
</div>
</div>
</body>
<template name="header">
<header class="navbar">
<div class="navbar-inner">
<a class="brand" href="/">Jobboard</a>
<ul class="nav">
</ul>
<ul class="nav pull-right">
<li>{{loginButtons}}</li>
</ul>
</div>
</template>
You need to close your <header> tag. Use consistent indentation to make these issues more obvious:
<body>
<div class="container">
{{> header}}
<div id="main" class="row-fluid">
{{renderPage}}
</div>
</div>
</body>
<template name="header">
<header class="navbar">
<div class="navbar-inner">
<a class="brand" href="/">Jobboard</a>
<ul class="nav">
</ul>
<ul class="nav pull-right">
<li>{{loginButtons}}</li>
</ul>
</div>
</header>
</template>

Resources