Odoo access ir.config_paramter in report - odoo

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?

Related

Vue.js get element by id/ref

I have a custom component called 'menu-entry':
<menu-entry v-for="field in fields" :id:"field.id" :ref="field.id" v-bind:key="field.id" v-bind:class="[classArray]" v-bind:field="field" v-on:clicked="menuEntryClicked">
</menu-entry>
I need to get one of them (for example field.id = 2) and remove an item from the classArray.
this.$refs[2] is working for HTML elements, but not for custom elements.
this.$el.querySelector isnt working either.
is there another way to remove an item from the classArray of a specific element?
Your question it is not clear but you are trying to set id and ref to field.id so following this logic it is not necessary to do though.
You can just send the id to the method you are executing like below:
<menu-entry
v-for="field in fields"
v-bind:key="field.id"
v-bind:class="[classArray]"
v-bind:field="field"
v-on:clicked="menuEntryClicked(field.id)" // <= send the id here
>
</menu-entry>
I am not sure if i helped but regarding your question, now you can figoure out which id of element is clicked and remove it from classArray or whatever you want
2 is not a valid id selector when you use document.querySelector('#2'); maybe you can use document.getElementById('2') instead - it can work.

How to get the current id section in odoo 9?

When I click in a register of a list, in the url appears something like this:
http://myInstance:8069/web?&debug=#id=9&view_type=form&model=ext.test&action=544
I need to capture the 9 (the value of id) in python in order to pass it as a default value of other field.
I don't know how to capture this value.
I want something similar like this:
#api.model
def default_get(self, vals):
result = super(my_relation, self).default_get(vals)
result['my_id'] = HERE_GOES_THE_VALUE_OF_THE_ID
return result
How can I do it?
I found the solution!
I realized that the "current id section" is the "active_id" variable.
However, if I try to access to this variable inside the python code, the value is 'None'.
To solve this problem, I have sent the variable via 'context'. In the xml file:
<field name="my_field_name" context="{'my_id': active_id}"/>
Then, in the python file, I can access to the context doing this:
result['my_id'] = self._context['my_id']

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

New structure field is not empty

I'm changing my liferay velocity template by adding new field for structure. e.g. 'heading1' and then adding this new field to template:
<h1>Heading is: $heading1.data</h1>
But if the structure field is not yet filled the outcome is:
Heading is: $heading1.data
So I thought I can fix this by:
#if($heading1.data!="")<h1>Heading is: $heading1.data</h1>#end
But the outcome is still:
Heading is: $heading1.data
If I open the web content and just publish it then the outcome is right, it doesn't show anything, but I don't want do find every similar web content and start publish them manually.
So is there a way how to check if the heading is just not filled?
Thanks.
You can use a silent reference to tell Velocity not to display an empty reference:
<h1>Heading is: $!heading1.data</h1>
or you can directly test whether its content does exist:
#if($headings1.data) <h1>Heading is: $heading1.data</h1> #end
Up to Velocity 1.7, this test will be false if the reference is null or uninitialized, but will still be true if the reference contains an empty string. Empty strings will also evaluate to false in next versions.

Yii Retrieve and store in a variable a renderPartial file

I have a php file under protected/views/directory_controller_name with formatting like that
<p>
<?php echo $model->title;?>
</p>
...
I display the file with classic method in the controller :
$this->render('filename',array('model'=>$model));
But know, I need to send an email with the same template/layout so I want to store the render of the file in an variable like
$msgHTML = $this->renderInternal('_items', array('model'=>$model));
But it doesn't work!
How can I get render view from a file and store in a variable?
Is it possible?
I don't want to use:
$msgHTML = '<p>'.$model->title.'</p>'
...
Because the file is very long and I don't want to duplicate code!!!
Don't use the renderInternal method, use renderPartial instead. Render internal is low level method and should not be used in such context. To catch the output just set the $return parameter to true:
<?php $output = $this->renderPartial('_subView', $dataArray, true); ?>
$msgHTML = $this->renderInternal('_items', array('model'=>$model), true);
http://www.yiiframework.com/doc/api/1.1/CBaseController#renderInternal-detail
I might be missing something, but can't you just use regular render() with the return argument set to true? Then you can just use a view 'name' instead of knowing the path. (And unless my trusty stack trace logger is broken, renderFile and renderInternal take the same fully qualified path argument. At least I can see renderPartial() passing the full path to my view file to renderFile.)
you can do this with these ways
1) if you want to get the output with header and footer (i.e ) full layout then do this
//add true in the last parameter if you want a return of the output
$htmloutput=$this->render('_pdfoutput',array('data'=>'nothing'),true);
2) similarly if you don't want to get the layout files just use renderpartial in the same way
$htmloutput=$this->renderpartial('_pdfoutput',array('data'=>'nothing'),true);
you will get the html of files in the variable . use this anywhere