ODOO 11 report, object has no attribute 'report_action' - python-3.x

Good day to all.
Trying to make custom ODOO 11 report to save it to pdf.
Report template(w/out any values, just for test purposes)
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="contract_template">
<t t-call="web.html_container">
<div class="article">
<h2>Report title</h2>
<p>Report 01</p>
</div>
</t>
</template>
</data>
</odoo>
If I call this template from XML like this:
<report
id="custom_template_1"
model="res.partner.contract.wizard"
string="Contract"
report_type="qweb-pdf"
name="client_contracts.contract_template"
file="client_contracts.contract_template"
menu="False"
/>
And add button to view it works fine - it generate report.
But when I'm trying to generate this report with python code:
def get_pdf_contract(self):
context = self._generate_context()
return self.env.ref('client_contracts.contract_template').report_action(self, data=context)
And add button to view:
<button string="Test pdf x" type="object" name="get_pdf_contract" />
When I press this button there is an error:
AttributeError: 'ir.ui.view' object has no attribute 'report_action'
Anyone can give me helping hand with that? Thanx for any help.

Found solution.
For anyone, who get same error/trouble - solution.
Just skip the
return self.env.ref('client_contracts.contract_template').report_action(self, data=context)
part, and replace it with
return {'type': 'ir.actions.report','report_name': 'client_contracts.contract_template','report_type':"qweb-pdf",'data': context,}
where context - previously generated dict of values, that need to be passed to template.
client_contract - name of module, conrtact_template - name of template

replace
return self.env.ref('client_contracts.contract_template').report_action(self, data=context)
with
return self.env.ref('client_contracts.custom_template_1').report_action(self, data=context)
means
return self.env.ref('module.report id').report_action(self,data=context)

The solution to this stack overflow question link, works fine.
To note: the report_id referenced below should refer to the report where you have declared name of report and type and file ... and not the template_id.
return self.env.ref('module_name.report_id').report_action(self, data=context)

Related

How to click on Web check box using Excel VBA?

How do I check the table checkbox?
I tried clicking.
ie.Document.getElementsByClassName("x-grid3-hd-checker").Checked = True
<div class="x-grid3-hd-inner x-grid3-hd-checker x-grid3-hd-checker-on" unselectable="on" style="">
<a class="x-grid3-hd-btn" href="#"></a>
<div class="x-grid3-hd-checker"> </div>
<img class="x-grid3-sort-icon" src="/javascript/extjs/resources/images/default/s.gif">
</div>
I can't see a checkbox in the HTML code. But you use getElementsByClassName() in a wrong way for your case. getElementsByClassName() generates a node collection. If you need a specific node, you must get it by it's index in the node collection. First element has index 0.
Please note that the div tag with the CSS class class="x-grid3-hd-inner x-grid3-hd-checker x-grid3-hd-checker-on " is also included in the Node Collection, because a part of the class identifier is identical to "x-grid3-hd-checker ". [Edit: I'm not realy sure if the part must maybe stand at the begin of the identifier]
If you want to check this:
<div class="x-grid3-hd-checker"> </div>
Your code needs the second index of the node collection:
ie.Document.getElementsByClassName("x-grid3-hd-checker")(1).Checked = True
But if there are more tags with the class name "x-grid3-hd-checker" the above line don't work. I can't say anymore until you don't post more HTML and VBA code. The best would be a link to the site.

Kendo angular grid add static column while export data in excel angular 4

I want to export data in excel using following code
<kendo-excelexport [data]="excelData" [group]="groups" [filterable]="true" fileName="exceldata.xlsx" #excelexport>
<kendo-excelexport-column title="title">
<ng-template kendoExcelExportCellTemplate let-dataItem>
{{dataItem.isTrue == 1 ? "title" }}
</ng-template>
<ng-template kendoExcelExportGroupFooterTemplate let-group="group" let-aggregates>
<span> Total</span>
</ng-template>
<ng-template kendoExcelExportFooterTemplate let-column="column">
<span>Grand Total</span>
</ng-template>
</kendo-excelexport-column>
</kendo-excelexport>
Please help me to resolve this issue.
Thanks in advance
Excel export does not use column template for formatting value or customizing data, please refer following link for further clarification https://www.telerik.com/kendo-angular-ui/components/grid/export/excel-export/#toc-known-limitations
You can customize the exported workbook by accessing the generated options, and modifying them as necessary:
DOCS AND EXAMPLE
You can customize both the appearance and value of each cell based on some custom logic.

Search title from input tag by classname and action

I want to get the title called "ABCD" as output from below :
Note I can't use input id to search and have to use classname. Also, note that I have several <div class="promptChoiceListBox" > and class="promptTextField promptTextFieldReadOnly" exist and this is just one example.
Also this Title is dynamic and changed with dropdown selection.
How can I check it in onclick event if the text inside the text is changed?
How can I achieve this ? any help is appreciated.
<div class="promptChoiceListBox" >
<input id="xyz123" type="text" class="promptTextField promptTextFieldReadOnly" readonly="" title="ABCD">
I have tried below and it doesn't work:
console.log($('.promptTextField').attr('title'));
thanks
Javascript way of doing it:
console.log(document.getElementById("xyz123").title);
JQuery (on-click example):
$("input:promptTextField promptTextFieldReadOnly").click(function(){
$("input:promptTextField promptTextFieldReadOnly").toggle();
});
$('.promptTextField').map(x=>x.title)

Export Telerik RadGrid with EditMode lines

I need to export a RadGrid table, and it contains several EditMode lines.
I would like to choose which content to export or ideally, if possible, change the lines to
EditMode = false
before exporting, so it looks how I need.
Code Details:
I have a few GridTemplateColumn, here is one of them:
<telerik:GridTemplateColumn
ItemStyle-Wrap="false" UniqueName="DataInicioAtividade"
DataField="DataInicioAtividade" HeaderText="*Data Inicio">
<ItemTemplate>
<telerik:RadDatePicker runat="server" ID="data_inicio" MinDate="1900/1/1">
<DateInput runat="server"
CssClass="date-picker" ID="rad_dateInput_data_inicio"
MaxLength="10" CausesValidation="true" />
</telerik:RadDatePicker>
</ItemTemplate>
</telerik:GridTemplateColumn>
And a button that simply executes the code:
rgd_grid_naoiniciada.ExportExcel();
The problem is, as it looks, telerik RadGrid exporting just dumps the HTML code of the resulting table to an Excel file.
The behaviour of the component is just like it should be, but the resulting file should have the field values, instead of HTML code containing input fields, links, images of RadCalendar etc...
Thanks in advance.
When you export Set the Templatecolumn values to the text property of Template column and then give ExportOnlyData="true";
This will work for Template columns also now.
In ItemBoundEvent, give the following code.
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if ((isExport) && (e.Item is GridDataItem))
{
GridDataItem item = e.Item as GridDataItem;
item["DataInicioAtividade"].Text = ((RadDatePicker)item["DataInicioAtividade"].FindControl("data_inicio")).SelectedDate.ToString();
}
}

Expression Engine: How do I display the category name of an entry?

I am using SafeCracker to create some entries on a site and when the form is submitted it comes up in a preview template.
I need to be able to display the selected category for the entry.
I am using the following code to display the results in the preview template:
{exp:safecracker channel="jobs" id="contact" return="jobs/preview/ENTRY_ID" entry_id="{segment_3}"}
<p>Job Type: {job_type}<br />
Category: {exp:channel:category_heading}{category_name}{/exp:channel:category_heading}<br />
Location: {job_location}</p>
<p>Description:<br />
{job_description}
</p>
<p>Apply by: {how_to_apply} at: {apply_value}</p>
<p>Company: {company}</p>
<p>Description: <br />
{company_description}</p>
{/exp:safecracker}
As it is, the Category: value is blank. What is the correct way to do this?
Thanks!
Use: {categories}{if selected}{category_name}{/if}{/categories}.
Failing that, you could use the query module:
{exp:query sql="
SELECT c.cat_name
FROM exp_categories c, exp_category_posts cp
WHERE cp.entry_id = {segment_3}
AND c.cat_id = cp.cat_id
" backspace="2"}{cat_name}, {/exp:query}

Resources