I'm trying to extend a report with another one. If an if is true, the part should be loaded from another template and filled with the appropriate data. Maybe someone can give me a tip how I can implement this. Unfortunately I'm not getting any results at the moment. Only the initial report is printed.
<template id="a_report_order`your text`">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="doc">
<t t-call="web.internal_layout">
<div class="page">
....
</div>
<t t-if="checkuppaper_bool">
<t t-call="a.b_report_checkup">
<t t-foreach="self.env['a.checkup'].search([('partner_id', '=', 'partner_id')])"
t-as="doc"/>
</t>
</t>
</t>
</t>
</t>
Related
I was able to add the customer's name on the receipt but I can't replace the unit price.
My goal is to display the unit price in its non-rounded form (in this case 5.60 and not 6).
Currently, the POS shows the correct form:
product 1
11pk at 5.60/pk = 62
but after validating the payment, the receipt would round off all the unit prices and would print this:
product 1
11pkx6 = 62
This is my code in my custom pos receipt xml file:
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="OrderReceipt" t-inherit="point_of_sale.OrderReceipt" t-inherit-mode="extension" owl="1">
<xpath expr="//div[#class='pos-receipt-contact']" position="inside">
<t t-if='receipt.client'>
<div>Client:
<t t-esc='receipt.client.name' />
</div>
</t>
</xpath>
</t>
<t t-name="OrderLinesReceipt" t-inherit="point_of_sale.OrderLinesReceipt" t-inherit-mode="extension" owl="1">
<xpath expr="//div[#class='pos-receipt-left-padding']" position="replace">
<t t-esc="Math.round(line.quantity * Math.pow(10, env.pos.dp['Product Unit of Measure']))/ Math.pow(10, env.pos.dp['Product Unit of Measure'])"/>
<t t-if="!line.is_in_unit" t-esc="line.unit_name" />
x
<t t-esc="line.price_display_one" />
<span class="price_display pos-receipt-right-align">
<t t-esc="env.pos.format_currency_no_symbol(line.price_display)" />
</span>
</xpath>
</t>
</templates>
The code to insert customer name worked but no indication that the code to replace the unit price worked.
I need to print sgst and cgst labels with their value on qweb.
The below code is printing amount untaxed, cgst, sgst, total value in the table. But I need to print only sgst and cgst labels and their value.
How can I do it in Odoo v15?
<tr style="border-bottom:hidden">
<td style="width:80%;text-align:right;font-size:13px;">
<t t-set="tax_totals" t-value="json.loads(doc.tax_totals_json)"/>
</td>
<td style="width:20%;text-align:right;font-size:13px;">
<t t-call="account.document_tax_totals"/>
</td>
</tr>
The tax_totals_json, is a field formatted in JSON as below
{
"amount_total": 4563.45,
"amount_untaxed": 4342.2,
"formatted_amount_total": "4,563.45 \u20ac",
"formatted_amount_untaxed": "4,342.20 \u20ac",
"groups_by_subtotal":
{
"Untaxed Amount": [
{
"tax_group_name": "Tax 15%",
"tax_group_amount": 221.25,
"tax_group_base_amount": 1475.0,
"formatted_tax_group_amount": "221.25 \u20ac",
"formatted_tax_group_base_amount": "1,475.00 \u20ac",
"tax_group_id": 2,
"group_key": "Untaxed Amount-2"}
]
},
"subtotals":
[
{
"name": "Untaxed Amount", "amount": 4342.2,
"formatted_amount": "4,342.20 \u20ac"
}
],
"allow_tax_edition": false}
So for example if you would like to access to the Taxes value, your code will be as below:
<t t-set="tax_totals" t-value="json.loads(doc.tax_totals_json)"/>
<t t-foreach="tax_totals['subtotals']" t-as="subtotal">
<t t-set="subtotal_to_show" t-value="subtotal['name']"/>
<t t-foreach="tax_totals['groups_by_subtotal'][subtotal_to_show]" t-as="amount_by_group">
<t t-if="len(tax_totals['groups_by_subtotal'][subtotal_to_show]) > 1">
<span class="text-right" t-esc="amount_by_group['formatted_tax_group_amount']"/>
</t>
<t t-else="">
<span class="text-right" t-esc="amount_by_group['formatted_tax_group_amount']" />
</t>
</t>
</t>
For creating a dict, i used the following code:
<t t-set="count" t-value="dict()"/>
<t t-foreach="count_obj" t-as="ob">
<t t-set="count" t-esc="count.update({ob.id: ob.name})"/>
</t>
But i am getting a none value.Why?
Can anyone help me?Thanks in advance..
shahinsha ummer
You have to specify the value in dict form when you try setting the value
[<t t-set="variable" t-value=""/>].
In your example, there is no need to set the variable before the loop with dictionary form it will do nothing.
<t t-foreach="count_obj" t-as="ob">
<t t-set="count" t-value="{ob.id: ob.name}"/> <!-- Set the Value in form of dictionar -->
<span t-esc="count"/>
</t>
I need the show invoice reference on invoice report in header. which is just like that "Draft Invoice: ~ AR-2018/0303". It is on the first page only and i need to display on every page.
I try to that: ~
<template id="external_layout_header_inherited" inherit_id="report.external_layout_header">
<xpath expr="//div[#class='header']" position="inside">
<div t-if="o.number">Ref.: <span t-field="o.number"/></div>
</xpath>
</template>
But when I print the other Report Just like Sale or Purchase It effect all the report.
So, My Question is that how to print invoice reference on Invoice report starting of Second page also?
You are in the right way, but in your invoice report, you need call a custom external_layout that call a custom header like this
<t t-call="report.external_layout_custom">
<t t-call="report.external_layout_header_custom" />
<t t-raw="0" />
<t t-call="report.external_layout_footer_custom" />
</t>
</t>
I met Odoo for first time a little less than a month ago, and, a DOS Systems Analyst from the 90's, am helping to implement it for a small but fast growing local manufacturer. Largely out of the industry the last 15 years, I'm not pro, but fast learning Python, HTML (some past exper) and Java...
I've been through the Developer Docs, as well as the Developer's Cookbook & Essentials, and a variety of online tutorials (just about everything Google could come up with from several search word combinations).
I read the closed post asking about this and get that there's apparently no actual Odoo reference...
Can someone please tell me where I might find 'date/time' parse and conversion functions that I can access from a report that is using the 'canned' 'hr.employee' model?
<?xml version="1.0"?>
<t t-name="hr_attendance.report_attendancelog">
<t t-call="report.html_container">
<t t-call="report.external_layout">
<div class="page">
<div class="oe_structure"/>
<div class="row">
<div class="col-xs-6">
<h2><br/>Attendance Log: </h2>
</div>
</div>
<table class="table table-condensed mt32">
<thead>
<th><strong>Date / Time</strong></th>
<th><strong> Operation</strong></th>
</thead>
<tbody>
<t t-foreach="docs" t-as="o">
<t t-set="DspDate" t-value="o.name"/>
<t t-set="DspTime" t-value="o.name"/>
<!-- I want to parse 'o.name', which is 'date time' format (from
Attendance record) to separate 'Date' and 'Time' fields... -->
<!-- t t-set="DspDate" t-value="FUNC?(o.name)"/ -->
<!-- t t-set="DspTime" t-value="FUNC?(o.name)"/ -->
<!-- and do calcs with date & time...) -->
<!-- t t-set="ClcDt1" t-value="FUNC?('PrvDt')"/ -->
<!-- t t-set="ClcDt2" t-value="FUNC?(DspDate)"/ -->
<!-- t t-set="ClcTm1" t-value="FUNC?('PrvTm')"/ -->
<!-- t t-set="ClcTm2" t-value="FUNC?(DspTime)"/ -->
<tr>
<t t-if="ClcDt1 == ClcDt2">
<td><span t-esc="DspDate"/></td>
<td><span t-esc="DspTime"/></td>
<td><span t-esc="o.action"/></td>
</t
</tr>
</t>
<tr class="border-black">
<td colspan="3"><strong>Total period</strong></td>
<td><strong t-esc="o.worked_hours"/></td -->
</tr>
</tbody>
</table>
</div>
</t>
</t>
</t>
I prefixed 'br/' to H2 to keep the it properly positioned (only shows on the first page), but subsequent pages obscure the col headers behind the layout header... this is probably obvious and I'm oblivious, but how can I adjust the 'H2' position to be below the 'header' setup by 'report.external_layout'??
On QWeb rendering you can use the python libs time, datetime and relativedelta. They are included in the so called QWeb context which is used for the evaluation (python eval) of the code in reports. You can see this in Odoo code here.
That means you do something like this:
<t t-set="DspDate" t-value="datetime.datetime.strptime(o.name, '%Y-%m-%d %H:%M:%S').strftime('%d/%m/%Y')" />
I prefer parser classes for reports to define some common functions. For example: you can define the function getDate doing your parsing or transforming stuff. The report code will be much better with parser functions:
<t t-set="DspDate" t-value="getDate(o.name)" />