How to pass value to qweb odoo14 - odoo

How can I pass value to qweb and add to binary field. Everything is fine but I don't know how to add value to qweb. Here is my code.
def button_plan(self):
super(MrpProduction, self).button_plan()
for report in self.bom_id.reports:
report_name = "action_report_template"
template = report
pdf = self.env.ref('my_module.action_report_template')._render_qweb_pdf(self.ids)
report.operation_id.worksheet_type = 'pdf'
report.operation_id.worksheet = base64.b64encode(pdf[0])
How can I add template value to qweb.

The method _render_qweb_pdf has 2 possible parameters ids and data
You can found more information here.
https://github.com/odoo/odoo/blob/14.0/odoo/addons/base/models/ir_actions_report.py#L726

Related

Odoo access ir.config_paramter in report

I want to access and print a config parameter in a report.
I have tried this
<div t-if="ir.config_paramter">
<span t-field="ir.config_paramter.mymodule.myhtmlfield"/>
</div>
But I get an error saying it does not know 'ir'
The report I am trying to edit is account.report_invoice_document
What do I need to do to correctly print the field on the report?
You can pass the value of your ir_config_parameter via data argument in get_report function, or include it via a computed field in your report related method.
For example:
ir_parameter_value = fields.Char(compute="_compute_ir_parameter_value")
def _compute_ir_parameter_value(self):
for record in self:
record.ir_parameter_value = self.env['ir.config_parameter'].get_parameter("parameter_key")
config_paramter
is it a typo?
have do you include dependencies in manifest.py?

Retrieve s:hidden value and add as a param to an url

I have an hidden input field which value changes according to the option selected in a s:select in Struts 2. Then, there's a button that points to an action like loadData.action.
I would like to add to this action a parameter named item.id with the value of the hidden field as its value, a value changing each time I select a new option.
I've tried to use an s:param with an s:property inside and the name or the id of the s:hidden, but it doesn't print the value after the = sign.
How can I do to achieve this result? loadData.action?item.id=12 where 12 is the value of s:hidden name="item" id="item" ?
Please Provide complete action link and which value to be change also your HTML structure, so it will be easy to answer your question
Assuming your HTML structure's elements, I have tried to answer your question
You can change action using jQuery on change event of your <s:select>
Have a look at https://jsfiddle.net/shantaram/qy9rew4v/
$('#id-select').change( function () {
var newAction = $('#id-form').prop('action');
newAction = newAction.substring(0, newAction.lastIndexOf('='));
$('#id-form').prop('action', newAction+"="+varItemId);
//varItemId is value of your hidden field
//which you want to change Dynamically
});
provided:
id-select -> Id of your <select> element
id-form -> Id of your <form> element

How to add Price field to Odoo Product template?

I am using this free Odoo data slider module on website.
https://www.odoo.com/apps/modules/9.0/website_snippet_data_slider/
A nice module and works well too.I need to add "price" field in to this as currently it displays product name only.
Accordingly to this module we can add fields to slider from product.template to this section
https://github.com/laslabs/odoo-website/blob/9.0/website_snippet_data_slider/static/src/js/data_slider.js#L131
have tried to add price field like this
this.priceField = this.widgetOptions.data_price_field;
this.fields = [this.priceField, 'lst_price'];
unfortunate it doesn't work.Can anyone point me the reason and fix?
Thanks
Basically you need to map the value of the price to an html element. I have not tested this however if you take a look at data_slider.js just follow what is done for the display_name (product name data_name_field) from top to bottom.
You will also want to do some formatting for currency and so on. This should get you going in the right direction. Good luck!
In data_slider.js try making the following changes.
Below line 27 add:
data_price_field: 'price',
Below line 125 add:
this.priceField = this.widgetOptions.data_price_field;
Replace line 131 with:
this.fields = [this.nameField, this.priceField, 'id'];
Below line 96 add:
var $price = $('<h5>').text("Price " + record[this.fields[1]]);
Replace line 97 with:
var $caption = $('<div class="caption">').append($title).append($price);

How to get all input having the same class, id name in Controller - Laravel 5?

I have function which appends new answer inputs when 'Add answer' button is clicked. In Controller, i want to get the value of all answer inputs with id or class.
Here is the code I am currently using:
<script>
var txt1 = '{!! Form::text('answer1',null,['class' => 'answer']) !!}';
$(document).on('click','#btn1',function(){
$(this).before(txt1);
});
</script>
In Controller, I'm using this:
$input['answer_body'] = Input::get('answer1');
I can get one value according to one id in Laravel, but now i need to get all values that have same id and class.
Could anybody help me?
You can't, the ID and class aren't submitted and so aren't available in the PHP. What you can do is get results by the same name by turning them into an array. Change Form::text('answer1', to Form::text('answer1[]' so that you can submit multiple inputs with the same name.
If you then use $input['answer_body'] = Input::get('answer1');, $input['answer_body'] will have an array in it. You can get specific answers by using dot notation to specify which input you want to get, e.g.: Input::get('answer1.0'); will fetch the value in the first input with a name of answer1[].

Is it possible not to show dialog boxes in download function

I'm using "DOWNLOAD" function of abap to download something as txt file. But "DOWNLOAD" function shows some dialog boxes that shows where the file is being downloaded and asks if there is another file with the same name I want to replace.
There is silent parameter for that function to import but it doesn't change anything when I assign 'm' or 's' or 'x' to that.
Here is what I do;
CALL FUNCTION 'DOWNLOAD'
EXPORTING
filename = fn
filetype = 'ASC'
silent = 'M'
TABLES
data_tab = itab.
GUI_DOWNLOAD (obsolete) is ok without dialog boxes but I can not silence 'DOWNLOAD' function. Anyone knows how to achieve that ?
Thanks.
Rather than the function modules you mention, you should use the methods of class cl_gui_frontend_services.
The following snippet shows you an example call to cl_gui_frontend_services=>gui_download.
types: t_line type c length 100.
data: lt_tab type table of t_line.
append 'test' to lt_tab.
call method cl_gui_frontend_services=>gui_download
exporting
filename = 'C:\temp\file.txt'
changing
data_tab = lt_tab[].
This downloads the file to the specified location without a dialog. For showing a file selection dialog if you choose, there is cl_gui_frontend_services=>file_open_dialog or cl_gui_frontend_services=>file_save_dialog.
Notes:
You should check the return codes from the method calls. I just omitted them here for brevity, but failure to include them may result in a short dump.