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>
Related
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>
My outer for loop is working and printing name but inner loop in which i'm trying to iterate through systems is not working.
var executions = [
{
name:'Password',
email:'p#pol.com',
systems: [
{system: 'PME1'},
{system: 'PME2'},
{system: 'PME2'},
],
}
];
{#each executions}}
<span>Name : {{name}}</span>
<table>
<tbody>
{{#each systems}}
<tr>
<td>
<p>{{ system }}</p>
</td>
</tr>
{{/each}}
</tbody>
</table>
{{/each}}
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 want to achieve the below scenario. Have tried in many ways but no luck.
<t t-if="q1_percent > 75">
<td style="background-color:#52be80"><field name="q1_percent" nolabel="1"/></td>
</t>
<t t-elif="'q1_percent' > 50 and 'q1_percent' < 75">
<td class="td_act" style="background-color:#f4d03f"><field name="q1_percent" nolabel="1"/></td>
</t>
<t t-elif="'q1_percent' < 50">
<td class="td_act" style="background-color:#e74c3c"><field name="q1_percent" nolabel="1"/></td>
</t>
I am using odoo 10. And the above code is for form view.
How can I achieve this? Any ideas any help is most appreciated. Thanks!
Until Odoo 12 There is a difference between a regular view(tree, form, etc) and a QWeb view meaning that regular views cannot be mixed with QWeb content to be evaluated as for Reports and Website Pages.
You still could be able to acquire what you are looking for by simply defining a computed HTML Field that will contains the HTML result of evaluate that QWeb code or directly build the HTML without using QWeb at all. Or without QWeb just generating the HTML by yourself.
For example:
from lxml import etree
q1_percent_html = fields.HTML("Q1 Percent HTML", compute='_compute_q1_percent_html')
#api.depends('q1_percent')
def _compute_q1_percent_html(self):
for elem in self:
# QWeb version
t = etree.fromstring("""
<div>
<t t-if="q1_percent > 75">
<td style="background-color:#52be80"><t t-esc="q1_percent"/></td>
</t>
<t t-elif="'q1_percent' > 50 and 'q1_percent' < 75">
<td class="td_act" style="background-color:#f4d03f"><t t-esc="q1_percent"/></td>
</t>
<t t-elif="'q1_percent' < 50">
<td class="td_act" style="background-color:#e74c3c"><t t-esc="q1_percent"/></td>
</t>
<div>
""")
elem.q1_percent_html = self.env['ir.qweb'].render(t, {'q1_percent': elem.q1_percent})
# Python direct version
if elem.q1_percent >= 75:
background_color = "#52be80"
elif elem.q1_percent >= 50 and elem.q1_percent <= 75:
background_color = "#f4d03f"
elif elem.q1_percent <= 50:
background_color = "#e74c3c"
elem.q1_percent_html = """<div><td style="background-color:%s">%s</td></div>"""% (background_color, elem.q1_percent)
Use that field in your form view like:
<field name="q1_percent_html" nolabel="1" readonly="1"/>
Is it possible to auto-print the fields of a Meteor collection using helpers without specifying them?
Let's say I start having a helper that returns the collection of objects stored in a table, as follows:
{{ #each CollectionData }}
<thead>
<tr>
<th>Code</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<Tr class="object-row">
<Td> {{code}} </ td>
<Td> {{description}} </ td>
</tr>
</tbody>
...
{{/each}}
Now i specify an "object schema" for each collection to set which field i want to auto-print, pseudo example:
// Items is the name of the possible collection
Schema.items var = {
fields {
code: {
columnName: "code",
show: false,
},
description: {
columnName: "description",
show: false,
},
otherField {
columnName: "foo",
show: false,
}
}
}
Now, I would make the helper to auto-generate the table columns and values of a collection field where the show check is true, without having to manually specify {{code}}, {{description}} and so on, pseudo example:
{{ #each CollectionData }}
<thead>
<tr>
{{print each column where show check is == true, without manually specifing any name}}
</tr>
</thead>
<tbody>
<Tr class="object-row">
{{print the value of the column, for this record, where show check is == true, without specifing its name}}
</tr>
</tbody>
...
{{/each}}
Is there any way to do that?
The simpliest way would be to create a template for each TD, something like
<thead>
<tr>
{{#each fetchColumnHeaders}}
{{> columnHeader }}
{{/each}}
</tr>
</thead>
{{ #each CollectionData }}
<tbody>
<Tr class="object-row">
{{#each fetchColumnItems}}
{{> columnItem}}
{{/each}}
</tr>
</tbody>
{{/each}}
<template name="columnHeader">
<th>{{label}}</th>
</template>
<template name="columnItem">
<td>{{label}}</td>
</template>
And then you can write template helpers to return the column headers, and the various items based on your schema