Adding sequence numbering column to Qweb reports - odoo

I need to add a sequence numbering column to order lines table in QWeb reports like [SO, Quotations, POs, delivery Slip &, etc..].
<table class="table table-condensed mt48" t-if="not o.move_line_ids">
<thead>
<tr>
<th><strong>Product</strong></th>
<th><strong>Ordered Quantity</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td t-foreach="not o.move_line_ids" t-as="i">
<t t-set="i" t-value="1" />
<span t-esc="i"/>
<t t-set="i" t-value="i+1"/>
</td>
<td><span t-field="move.product_id"/></td>
<td>
<span t-field="move.ordered_qty"/>
<span t-field="move.product_uom"/>
</td>
</tr>
</tbody>
</table>
Sadly, I couldn't make it work. It gives me an empty error.

<t t-set="i" t-value="1" />
<table class="table table-condensed mt48" t-if="o.move_line_ids">
<thead>
<tr>
<th><strong>#</strong></th>
<th><strong>Product</strong></th>
<th><strong>Ordered Quantity</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td t-foreach="o.move_line_ids" t-as="move">
<span t-esc="i"/>
<t t-set="i" t-value="i+1"/>
</td>
<td><span t-field="move.product_id.name"/></td>
<td>
<span t-field="move.ordered_qty"/>
<span t-field="move.product_uom"/>
</td>
</tr>
</tbody>
</table>

Related

Table columns are out of bounds

odoo users.
This is part of my Qweb report:
<table class="table-metal">
<thead>
<tr>
<th style="text-transform: none;width:20%">Name</th>
<th style="text-transform: none;width:30%">Width</th>
<th style="text-transform: none;width:20%">Mark</th>
<th style="text-transform: none;width:20%">Standard</th>
<th style="text-transform: none;width:10%">Number</th>
</tr>
</thead>
<tbody>
<t t-set="node_name_value" t-value="noname"/>
<t t-foreach="doc.passport_metal_ids" t-as="metal_ids">
<tr>
<t t-if="metal_ids.product_name.name != node_name_value">
<t t-set="count" t-value="doc.get_count_row(metal_ids.product_name.name)"/>
<td valign="top" t-att-rowspan="count"><span t-field="metal_ids.product_name.name" /></td>
</t>
<t t-if="metal_ids.brand_id.name[0] == 'S'">
<td>Лист S=<span t-esc="metal_ids.size_id.name.split('x')[0]" /></td>
</t>
<t t-else="">
<td>Лист B-PN-0 S=<span t-esc="metal_ids.size_id.name.split('x')[0]" /><br></br>ГОСТ 19903-74 </td>
</t>
<td><span t-field="metal_ids.brand_id.name" /></td>
<td><span t-field="metal_ids.gost_id.name" /></td>
<td><span t-field="metal_ids.certificate" /></td>
<t t-set="node_name_value" t-value="metal_ids.product_name.name"/>
</tr>
</t>
</tbody>
<tfoot>
<tr>
<td colspan="5"></td>
</tr>
</tfoot>
</table>
<p style="page-break-after:always;"></p>
Because of the dynamic column:
<td valign="top" t-att-rowspan="count"><span t-field="metal_ids.product_name.name" /></td>
I get the following:
I added , but it did not help
Table columns are out of bounds. How to fix it?

Select all tables and exclude the div

I'm trying to do some stuff with python and selenium but I can't get my xpath to work. I have the following code :
<div id="ctl00_Main_treeCategories">
<table>
<tbody>
<tr>
<td><a id="ctl00_Main_treeCategoriesn0">Online Catalogus</a></td>
</tr>
</tbody>
</table>
<div id="ctl00_Main_treeCategoriesn0Nodes" style="display:block;">
<table cellpadding="0" cellspacing="0" style="border-width:0;">
<tbody>
<tr>
<td>
<div style="width:20px;height:1px"></div>
</td>
<td>
<a id="ctl00_Main_treeCategoriesn1">Dakraam</a>
</td>
</tr>
</tbody>
</table>
<div id="ctl00_Main_treeCategoriesn1Nodes" style="display:block;">
<table cellpadding="0" cellspacing="0" style="border-width:0;">
<tbody>
<tr>
<td><div style="width:20px;height:1px"></div></td>
<td><div style="width:20px;height:1px"></div></td>
<td></td>
<td class="treeNode ctl00_Main_treeCategories_2"><a class="ctl00_Main_treeCategories_0 treeNode ctl00_Main_treeCategories_1">Dakraam Duette® & Plissé Saaaaahade</a></td>
</tr>
</tbody>
</table>
</div>
<table cellpadding="0" cellspacing="0" style="border-width:0;">
<tbody><tr>
<td><div style="width:20px;height:1px"></div></td>
<td></td>
<td class="treeNode ctl00_Main_treeCategories_2" style="white-space:nowrap;">
<a class="ctl00_Main_treeCategories_0 treeNode ctl00_Main_treeCategories_1">Duette® Fixé & Plissé Shadeeeee</a>
</td>
</tr>
</tbody>
</table>
</div>
I try to select all tables within the ctl00_Main_treeCategoriesn0Nodes div, and exclude the div on the first level within (ctl00_Main_treeCategoriesn1Nodes).
I tried :
//*[contains(#id, "ctl00_Main_treeCategoriest")]/div/table/
but this gives a syntax error.
You had two errors on the XPath:
Mispelling of the id (that t at the end)
Trailing / (not necessary)
//*[contains(#id, "ctl00_Main_treeCategories")]/div[not(#id="ctl00_Main_treeCategoriesn1Nodes")]/table
Demo: https://3v4l.org/SusIZ
Edit: Excluded inside ctl00_Main_treeCategoriesn1Nodes divs

Quanitiy Shipped in odoo Invoice report

I'm trying to get the value qty of products shipped to display as an additional column in the invoice report. Not sure if its as simple as finding out what variable it is or what. Is there any easy way to reference what variables are available for the current views?
<table class="table table-condensed">
<thead>
<tr>
<th>Description</th>
<th class="hidden">Source Document</th>
<th class="text-right">Ordered</th>
<th class="text-right">Shipped</th>
<th class="text-right">Backorder</th>
<th class="text-right">Unit Price</th>
<th t-if="display_discount" class="text-right">Disc.(%)</th>
<th class="text-right">Extended Price</th>
</tr>
</thead>
<tbody class="invoice_tbody">
<tr t-foreach="o.invoice_line_ids" t-as="l">
<td><span t-field="l.name"/></td>
<td class="hidden"><span t-field="l.origin"/></td>
<td class="text-right">
<span t-field="l.quantity"/>
<span t-field="l.uom_id" groups="product.group_uom"/>
</td>
<td class="text-right">
<span t-field="o.delivery_count"/>
</td>
<td class="text-right">
</td>
<td class="text-right">
<span t-field="l.price_unit"/>
</td>
<td t-if="display_discount" class="text-right">
<span t-field="l.discount"/>
</td>
<td class="text-right">
<span t-field="l.price_subtotal" t-options="{"widget": "monetary", "display_currency": o.currency_id}"/>
</td>
</tr>
</tbody>
I don't exactly know what you mean with "products shipped" but you can get the quantity of the invoice lines to your report like this:
<t t-foreach="o.invoice_line_ids" t-as="l">
<span t-field="l.quantity"/>
</t>
Same for the stock picking lines quantity:
<t t-foreach="o.move_lines" t-as="l">
<span t-field="l.product_uom_qty"/>
</t>
One easy way to get the variable names is to activate the develop mode and placing the cursor over a field label.
You can also go to Settings->Database Structure->Models then just pick your needed model to see the variable names (field names).

Add sum in qweb report

How add SUM for etc. id field bottom on table without .py file and function?
<table class="table table-condensed">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Quantity</th>
</tr>
</thead>
<tr>
<t t-foreach="docs" t-as="o">
<tr>
<td><t t-esc="o.id"/></td>
<td><t t-esc="o.name"/></td>
<td><t t-esc="o.quantity"/></td>
</tr>
</t>
</tr>
<tr>
<td colspan="3" class="text-right"> SUM (o.quantity) </td>
</tr>
</table>
Is it possible in this situation?
You can create one variable and sum quantity in every loop iteration and print it at last.
So you should try as following :
<table class="table table-condensed">
<t t-set="qty" t-value="0">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Quantity</th>
</tr>
</thead>
<tr>
<t t-foreach="docs" t-as="o">
<tr>
<td><t t-esc="o.id"/></td>
<td><t t-esc="o.name"/></td>
<td><t t-esc="o.quantity"/></td>
<t t-set="qty" t-value="qty + o.quantity"/>
</tr>
</t>
</tr>
<tr>
<td colspan="3" class="text-right"> <span t-esc="qty"></span> </td>
</tr>
</table>
try below code
<table class="table table-condensed">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Quantity</th>
</tr>
</thead>
<tr>
<t t-foreach="docs" t-as="o">
<tr>
<td><t t-esc="o.id"/></td>
<td><t t-esc="o.name"/></td>
<td><t t-esc="o.quantity"/></td>
</tr>
</t>
</tr>
<tr>
<span t-esc="sum(line.quantity for line in docs)"/>
</tr>
</table>

Print all lines from account.invoice.line model

I created a new template for printing, and i want to customize it so it prints all the lines from account.invoice.line model. Is there a way you can do that. Here is the code of the template so far.
<t t-name="account.specifikacioni_report_document">
<t t-call="report.external_layout">
<div class="page">
<table class="table table-condensed">
<thead>
<tr>
<th>Description</th>
<th>Quantity</th>
<th class="text-right">Unit Price</th>
<th class="text-right" groups="sale.group_discount_per_so_line">Discount (%)</th>
<th class="text-right">Taxes</th>
<th class="text-right">Amount</th>
</tr>
</thead>
<tbody class="invoice_tbody">
<tr t-foreach="o.invoice_line" t-as="l">
<td>
<span t-field="l.name"/>
</td>
<td>
<span t-field="l.quantity"/>
<span t-field="l.uos_id" groups="product.group_uom"/>
</td>
<td class="text-right">
<span t-field="l.price_unit"/>
</td>
<td class="text-right" groups="sale.group_discount_per_so_line">
<span t-field="l.discount"/>
</td>
<td class="text-right">
<span t-esc="', '.join(map(lambda x: x.name, l.invoice_line_tax_id))"/>
</td>
<td class="text-right">
<span t-field="l.price_subtotal" t-field-options="{"widget": "monetary", "display_currency": "o.currency_id"}"/>
</td>
</tr>
</tbody>
</table>
</div>
</t>
</t>
This prints invoice lines for one invoice cause I copied the account.report_invoice_document and just edited it, but how can I list all invoice lines here not only the invoice lines for an invoice
You can follow the report_invoice.xml to print the lines.
<table class="table table-condensed">
<thead>
<tr>
<th>Description</th>
<th>Quantity</th>
<th class="text-right">Unit Price</th>
<th class="text-right" groups="sale.group_discount_per_so_line">Discount (%)</th>
<th class="text-right">Taxes</th>
<th class="text-right">Amount</th>
</tr>
</thead>
<tbody class="invoice_tbody">
<tr t-foreach="o.invoice_line" t-as="l">
<td><span t-field="l.name"/></td>
<td>
<span t-field="l.quantity"/>
<span t-field="l.uos_id" groups="product.group_uom"/>
</td>
<td class="text-right">
<span t-field="l.price_unit"/>
</td>
<td class="text-right" groups="sale.group_discount_per_so_line"><span t-field="l.discount"/></td>
<td class="text-right">
<span t-esc="', '.join(map(lambda x: x.name, l.invoice_line_tax_id))"/>
</td>
<td class="text-right">
<span t-field="l.price_subtotal"
t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
</td>
</tr>
</tbody>
</table>