I'm developing a Qweb report in Odoo and I need to use xpath expressions for replacing some content.
This is the main template where is needed to make the replace of the content:
<template id="report_saleorder2_template">
<t t-name="report_saleorder2_template">
<t t-call="web.external_layout">
<div class="page">
<div class="oe_structure" />
<div class="row" id="report_data_0">
<h1>Annual voluntary contribution to Fecoas - Alcaste school</h1>
//more code
This is the other template where I'm tying to use the xpath expression for replacing the content:
<template id="report_saleorder3_template">
<t t-name="report_saleorder3_template">
<t t-call="custom_v12_reports.report_saleorder2_template" t-lang="doc.partner_id.lang" />
<xpath expr="//div[#id='report_data_0']/h1[1]" position="replace">
<h1>Annual AMPA's member fee Alcaste school</h1>
</xpath>
</t>
</t>
</template>
This is not working. Someone knows why?
Thanks for reading!
You have to inherit the origin template with inherit_id. Then you're able to use XPath expressions to change or add new code.
<template id="report_saleorder3_template"
inherit_id="module_name.report_saleorder2_template">
<xpath expr="//div[#id='report_data_0']/h1[1]" position="replace">
<h1>Annual AMPA's member fee Alcaste school</h1>
</xpath>
<!-- and other XPath expressions -->
</template>
I add internal reference of product to the sale form and I want it in the invoice report also
the sale code is :
class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'
_name = 'sale.order.line'
x_field = fields.Float('Unit cost')
internal_ref=fields.Char(related='product_id.default_code',string='Internal
reference product',store=True,default=100)
partner_name=fields.Many2one('res.partner','partner_id.name')
this is my code but did not work
the python code:
class invoiceLineField(models.Model):
_inherit='account.invoice.line'
internal_ref=fields.Char(related='product_id.default_code',string='Internal
reference product',store=True)
and this is xml report:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="report_invoice_document_itemnumber"
inherit_id="account.report_invoice_document">
<xpath expr="//div[contains(#class, 'page')]/table[1]/thead/tr/th[1]"
position="before">
<th>Internal reference</th>
</xpath>
<xpath expr="//div[contains(#class, 'page')]/table[1]/tbody/tr/td[1]"
position="before">
<td>
<span t-field="l.internal_ref"/>
</td>
</xpath>
</template>
</data>
</odoo>
no error but the internal reference of product did not appear in the result
If you want the 'default_code' field just to print in report then you can achieve it by 'product_id.default_code'.
<span t-field="l.product_id.default_code"/>
I've added the field 'limit' in 'res.partner' model in 'Sales'. Now, I want to inherit the same in my POS module during the Customer Creation.
I've included all my files(xml and js) in manifest.py with proper syntax.
My '.js' file is working completely fine. The problem shows in 'static/src/xml/pos.xml' file.
Here's my code of pos.xml file. No syntax error, still cant get 'limit' field in POS.
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template_test" xml:space="preserve">
<t t-extend="ClientDetailsEdit">
<t t-jquery=".client-details-right" t-operation="append">
<div class='client-detail'>
<span class='label'>Limit</span>
<input class='detail limit' name='limit' value="5000" readonly="True" t-att-value='partner.limit || ""'></input>
</div>
</t>
</t>
</templates>
Please, tell me if anything is wrong or missing!
I am developing one spring-boot application. I have to print Hashmap resultset as a table. For that I have created table using thymeleaf. The table has sometimes over 100k records. I want pagination for this table every 10 or 50 records.
My html using thymeleaf code snippet:
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
xmlns:dt="http://www.thymeleaf.org/dandelion/datatables">
<head lang="en">
.
.
<div id="myDivTable">
<table class="table table-bordered" id="bomTable" id="bomTable"
dt:table="true" dt:displaylength="10">
<span th:each="row, iter : ${result}" pages:paginate="5">
<tr th:classappend="${iter.first} ? header-style">
<span th:each="cell : ${row.value}">
<td th:classappend="${#strings.contains(cell,'difference')}?set-difference-bg-color" >
<div th:switch="${cell}">
<div th:case="'Only in WC'" >
<span class="set-green-text-bold" th:text="${cell}">
</span>
</div>
<div th:case="'New in XLSX'" >
<span class="set-red-text-bold" th:text="${cell}">
</span>
</div>
<div th:case="'No'" >
<span class="set-red-text-bold" th:text="${cell}">
</span>
</div>
<div th:case="'Yes'" >
<span class="set-green-text-bold" th:text="${cell}">
</span>
</div>
<div th:case="*" >
<div th:if="${#strings.contains(cell,'difference')}">
<span
th:text="${#strings.substring(cell,0,#strings.indexOf(cell,'difference'))}">
</span>
</div>
<div th:unless="${#strings.contains(cell,'difference')}">
<span th:text="${cell}"></span>
</div>
</div>
</div>
</td>
</span>
</tr>
</span>
</table>
</div>
.
.
Recently it is printing all the records on one single page. I am checking for 120 records. How I can split the records 10 or 50 on each page. I am using Thymeleaf.
I have tried to use dandelion datatables, I have added dependencies in pom.xml, create dandelinConfig class etc but still it is not reflecting in result.
You can do it with using Dandelion Datatables.
Sample usage like this :
<dependency>
<groupId>com.github.dandelion</groupId>
<artifactId>datatables-thymeleaf</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>com.github.dandelion</groupId>
<artifactId>datatables-spring3</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>com.github.dandelion</groupId>
<artifactId>dandelion-thymeleaf</artifactId>
<version>1.1.1</version>
</dependency>
And Configuration class is :
#Configuration
public class DandelionConfig {
#Bean
public DandelionDialect dandelionDialect() {
return new DandelionDialect();
}
#Bean
public DataTablesDialect dataTablesDialect(){
return new DataTablesDialect();
}
#Bean
public Filter dandelionFilter() {
return new DandelionFilter();
}
#Bean
public ServletRegistrationBean dandelionServletRegistrationBean() {
return new ServletRegistrationBean(new DandelionServlet(), "/dandelion-assets/*");
}
}
The you should add dandelion folder under resources folder : /resources/dandelion/. And then create /resources/dandelion/sample.json file like below :
{
"bundle" : "custom",
"assets": [
{
"name": "bootstrap4-datatables-css",
"type": "css",
"locations": {
"classpath": "static/css/dataTables.bootstrap4.min.css"
}
},
{
"name": "jquery-datatables-js",
"type": "js",
"locations": {
"classpath": "static/js/jquery.dataTables.min.js"
}
},
{
"name": "bootstrap4-datatables-js",
"type": "js",
"locations": {
"classpath": "static/js/dataTables.bootstrap4.min.js"
}
},
}
]
}
and create /resources/dandelion/dandelion.properties file :
components.standalone=ddl-dt
bundle.includes=custom
add aplication properties file components.standalone = ddl-dt
.Finally example html file :
<html xmlns:th="http://www.thymeleaf.org"
xmlns:dt="http://www.thymeleaf.org/dandelion/datatables"
>
<table id="paging-simple" dt:table="true" dt:pagingType="simple" class="display">
<thead>
<tr>
<th>Id</th>
<th>Firstname</th>
<th>Lastname</th>
<th>City</th>
<th>Mail</th>
</tr>
</thead>
<tbody>
<tr th:each="person : ${persons}">
<td th:text="${person?.id}">1</td>
<td th:text="${person?.firstName}">John</td>
<td th:text="${person?.lastName}">Doe</td>
<td th:text="${person?.address?.town?.name}">Nobody knows!</td>
<td th:text="${person?.mail}">john#doe.com</td>
</tr>
</tbody>
</table>
.Finally if you want to add pagination your project you will do it ajax request.Detail is Dandelion Datatables Ajax
im using springboot, java, thymeleaf, foundation(js) and mysql, idontknow about dandelion, but with spring Pageable i can do this
public String listadoProductos(Pageable pageable, Model model) {
if(pageable.getPageSize() > PAGE_SIZE_INITIAL) {
pageable = new PageRequest(0,PAGE_SIZE_INITIAL);
}
Page<Productos> productos = productosRepository.findByEnabled(true, pageable);//trae todos los productos habilitados
model.addAttribute("productos", productos);
modelPaginacion(model, productos, pageable.getPageNumber());
return tiendaFolder+"listaProductos";}
and with thyeleaf and foundation do this:
<div class="row">
<ul class="paginacion text-center">
<li class="previous" th:if="${previo}">
<a th:href="#{/tienda/productos/admin?page={pa}&size={ps}(pa=${paginaActual-1},ps=${size})}"></a>
</li>
<li class="previa" th:if="${previo}">
<a th:href="#{/tienda/productos/admin?page={pa}&size={ps}(pa=${paginaActual-1},ps=${size})}" th:text="${paginaActual-1}"></a>
</li>
<li class="actual" th:text="${paginaActual}">
</li>
<li class="siguiente" th:if="${siguiente}">
<a th:href="#{/tienda/productos/admin?page={pa}&size={ps}(pa=${paginaActual+1},ps=${size})}" th:text="${paginaActual+1}"></a>
</li>
<li class="next" th:if="${siguiente}">
<a th:href="#{/tienda/productos/admin?page={pa}&size={ps}(pa=${paginaActual+1},ps=${size})}"></a>
</li>
</ul>
</div>
is only the block o number of pages
In Odoo system, If you set the product_code (interal reference) in product template, the note also be showed on the qweb report. I would like to get only the product's name in sale order qweb report, Is it possible to remove(or hide) the product_code field report? If it is, please help me to specific the right steps to solve it. Thank you
my qweb code :
</tr>
<t t-set="index" t-value="0"/>
<t t-set="product" t-value="0"/>
<t t-foreach="doc.handle_orderline(doc.order_line)" t-as="product_line">
<t t-set="product_num" t-value="0"/>
<t t-set="index" t-value="index + 1"/>
<t t-foreach="product_line" t-as="l">
<t t-set="product_num" t-value="product_num+1"/>
<t t-if="not l.product_uom_qty">
<t t-set="index" t-value="index - 1"/>
</t>
<tr t-if="l.product_uom_qty">
<t t-if="product_num == 1">
<td class="text-center" t-att-rowspan="len(product_line)">
<span t-esc="index"/>
</td>
<td class="text-center" t-att-rowspan="len(product_line)">
<strong><span t-field="l.name"/></strong>
<br/>
<t t-if="l.width_id">( <span style="font-style:italic" t-field="l.width_id.name"/> )</t>
</td>
</t>
In sale.order.line object name field store value in combination of product name and code. name field value set on onchange of Product field.
So in QWEB report, we need to get value from product_id field to display product name.
Replace following code:
<strong><span t-field="l.name"/></strong>
with
<strong><span t-field="l.product_id.name"/></strong>