Account invoice report - odoo

<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.

Related

how to print several products on the same page with 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>

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>

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).

Inherit qweb report and replace string odoo 9

I'm inherit qweb report, now I want replace string Total Without Taxes, Taxes, Total
<div class="row" name="total">
<div class="col-xs-4 pull-right">
<table class="table table-condensed">
<tr class="border-black">
<td><strong>Total Without Taxes</strong></td>
<td class="text-right">
<span t-field="doc.amount_untaxed"
t-field-options='{"widget": "monetary", "display_currency": "doc.pricelist_id.currency_id"}'/>
</td>
</tr>
<tr>
<td>Taxes</td>
<td class="text-right">
<span t-field="doc.amount_tax"
t-field-options='{"widget": "monetary", "display_currency": "doc.pricelist_id.currency_id"}'/>
</td>
</tr>
<tr class="border-black">
<td><strong>Total</strong></td>
<td class="text-right">
<span t-field="doc.amount_total"
t-field-options='{"widget": "monetary", "display_currency": "doc.pricelist_id.currency_id"}'/>
</td>
</tr>
</table>
</div>
</div>
<xpath expr="?????" position="replace">
</xpath>
Any simple solution or online example?..................................
please try this code :-
<xpath expr="//div[#name='total']" position="replace">
<div class="col-xs-4 pull-right">
<table class="table table-condensed">
<tr class="border-black">
<!--Add your Custom String-->
<td><strong>Custom String</strong></td>
<td class="text-right">
<span t-field="doc.amount_untaxed"
t-field-options='{"widget": "monetary", "display_currency": "doc.pricelist_id.currency_id"}'/>
</td>
</tr>
<tr>
<!--Add your Custom String for taxes-->
<td>Custom String</td>
<td class="text-right">
<span t-field="doc.amount_tax"
t-field-options='{"widget": "monetary", "display_currency": "doc.pricelist_id.currency_id"}'/>
</td>
</tr>
<tr class="border-black">
<!--Add your Custom String for Total-->
<td><strong>Custom String</strong></td>
<td class="text-right">
<span t-field="doc.amount_total"
t-field-options='{"widget": "monetary", "display_currency": "doc.pricelist_id.currency_id"}'/>
</td>
</tr>
</table>
</div>
</xpath>
Try this. Havent had a chance to test it.
<xpath expr="//table[contains(#class, 'table-condensed')]/tr[first()]/td[first()]" position="replace">
<!-- YOUR XML HERE -->
</xpath>