how to print several products on the same page with odoo - odoo

here is the template that I use but the products are printed each on its page whereas I want the product to be printed on a page once the page is full that it continues on a new page
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="stock_view_report_template">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="report.external_layout">
<div class="page">
<h2>Stock actuel</h2>
<table class="table table-condensed">
<thead>
<tr>
<th>product</th>
<th>Quantity</th>
<th>Location</th>
<th>Owner</th>
<th>Lot</th>
<th>Incoming Date</th>
<th>Inventory Value</th>
</tr>
</thead>
<tbody>
<td><span t-field="o.product_id.name"/></td>
<td><span t-field="o.qty"/></td>
<td><span t-field="o.location_id.name"/></td>
<td><span t-field="o.owner_id"/></td>
<td><span t-field="o.lot_id"/></td>
<td><span t-field="o.in_date"/></td>
<td><span t-field="o.inventory_value"/></td>
</tr>
</tbody>
</table>
</div>
</t>
</t>
</t>
</template>
</data>
</openerp>

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?

How Can Display Receipt In Quotation in odoo 12?

I using odoo 12 , I need display receipt similar point of sale receipt in quotation in sale module
Just replicate the Point of Sale Report in the sale.order model. The internal_layout may be useful in that case
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_saledetails">
<t t-call="web.html_container">
<t t-call="web.internal_layout">
<div class="page">
<div class="text-center">
<h2>Sales Details</h2>
<strong><t t-esc="date_start" t-options="{'widget': 'datetime'}"/> - <t t-esc="date_stop" t-options="{'widget': 'datetime'}"/></strong>
</div>
<!-- Orderlines -->
<h3>Products</h3>
<table class="table table-sm">
<thead><tr>
<th>Product</th>
<th>Quantity</th>
<th>Price Unit</th>
</tr></thead>
<tbody>
<tr t-foreach='products' t-as='line'>
<t t-set="internal_reference" t-value="line['code'] and '[%s] ' % line['code'] or ''" />
<td><t t-esc="internal_reference" /><t t-esc="line['product_name']" /></td>
<td>
<t t-esc="line['quantity']" />
<t t-if='line["uom"] != "Unit(s)"'>
<t t-esc='line["uom"]' />
</t>
</td>
<td>
<t t-esc='line["price_unit"]' />
<t t-if='line["discount"] != 0'>
Disc: <t t-esc='line["discount"]' />%
</t>
</td>
</tr>
</tbody>
</table>
<br/>
<h3>Payments</h3>
<table class="table table-sm">
<thead><tr>
<th>Name</th>
<th>Total</th>
</tr></thead>
<tbody>
<tr t-foreach='payments' t-as='payment'>
<td><t t-esc="payment['name']" /></td>
<td><t t-esc="payment['total']" t-options="{'widget': 'float', 'precision': currency_precision}"/></td>
</tr>
</tbody>
</table>
<br/>
<h3>Taxes</h3>
<table class="table table-sm">
<thead><tr>
<th>Name</th>
<th>Tax Amount</th>
<th>Base Amount</th>
</tr></thead>
<tbody>
<tr t-foreach='taxes' t-as='tax'>
<td><t t-esc="tax['name']" /></td>
<td><t t-esc="tax['tax_amount']" t-options="{'widget': 'float', 'precision': currency_precision}"/></td>
<td><t t-esc="tax['base_amount']" t-options="{'widget': 'float', 'precision': currency_precision}"/></td>
</tr>
</tbody>
</table>
<br/>
<br/>
<strong>Total: <t t-esc='total_paid' t-options="{'widget': 'float', 'precision': currency_precision}"/></strong>
</div>
</t>
</t>
</template>
</data>
</openerp>

Adding sequence numbering column to Qweb reports

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>

Account invoice report

<openerp>
<data>
<template id="report_invoice_document" inherit_id="account.report_invoice_document">
<xpath expr="//span[#t-field='t.amount']" position="after">
<span t-field="t.note"/>
</xpath>
</template>
</data>
</openerp>
i added field to invoice report inside tax table. but how can i make tax table visible only if there is note field, and hide if note is empty.
i trying something with t-if but my goal is to show tax table not to hide it when note field is not empy. is there any kind of t-ifnot?
<xpath expr="//span[#t-field='t.amount']/../../../../thead/tr" position="replace">
<th t-if="o.notes"
</xpath>
Yes. We can achieve it with following example:
<t t-if="o.notes">
<!-- Fields visible if Notes has value-->
</t>
<t t-if="not o.notes">
<!-- Fields visible if Notes has no value-->
</t>
EDIT
Design your table in one of condition.
<t t-if="o.notes">
<table style="border:1px solid; width:100%">
<thead>
<tr>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</t>
Hello An..,
Best Learning Tutorial
If you want use any types of condition so QWeb is provides many types of inbuilt functionality. More information for read below link,
1) https://www.odoo.com/documentation/8.0/reference/qweb.html
Solution
Account invoice base/odoo table is below,
<div class="row" t-if="len(o.tax_line_ids) > 0">
<div class="col-xs-6">
<table class="table table-condensed">
<thead>
<tr>
<th>Tax</th>
<th class="text-right">Base</th>
<th class="text-right">Amount</th>
</tr>
</thead>
<tbody>
<tr t-foreach="o.tax_line_ids" t-as="t">
<td><span t-field="t.tax_id.description"/></td>
<td class="text-right">
<span t-field="t.base" t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
<td class="text-right">
<span t-field="t.amount" t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</tr>
</tbody>
</table>
</div>
</div>
Now you want to show the table when t.note field is not empty so odoo XML provides if condition to check the anything.
Now try this below code for your problem,
<openerp>
<data>
<template id="report_invoice_document" inherit_id="account.report_invoice_document">
<xpath expr="//span[#t-field='t.amount']" position="after">
<t t-if="t.note">
<span t-field="t.note"/>
<!-- For example i add one new table -->
<table class="table table-condensed">
<thead>
<tr>
<th>Tax</th>
<th class="text-right">Base</th>
<th class="text-right">Amount</th>
</tr>
</thead>
<tbody>
<tr t-foreach="o.tax_line_ids" t-as="t">
<td><span t-field="t.name"/></td>
<td class="text-right">
<span t-field="t.base"
t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
</td>
<td class="text-right">
<span t-field="t.amount"
t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
</td>
</tr>
</tbody>
</table>
</t>
<t t-if="not t.note">
<!-- If empty t.note so not show tax table -->
</t>
</xpath>
</template>
</data>
</openerp>
I hope my answer is helpful.
If any query so comment please.

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>