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']
Related
In Sale Quotation Line, there is a field Quantity (product_uom_qty).
I want to customize something in its onchange event, but it does not seem to be triggering it when I change its value.
This is what I tried:
class sale_order_line_inherit(models.Model):
_inherit = 'sale.order.line'
#api.onchange('product_uom', 'product_uom_qty')
def product_uom_change(self):
print(res)
print(self.price_unit)
res = super(sale_order_line_inherit, self).product_uom_change()
print(res)
print(self.price_unit)
Nothing gets printed at all.
I already included 'sale' in manifest as well.
What did I do wrong?
Few points to consider,
How to change quantity from the frond end or script?
Can you verify field name on the list/form view?
Put print statement on the Odoo core sale module
If still not working, put error code on the file and upgrade the module to identify file execute at all or not.
I don't have any issue in your code. This is alternative of your code.
#api.onchange('product_uom', 'product_uom_qty')
def product_uom_change(self):
print(self.price_unit)
super().product_uom_change()
print(self.price_unit)
I have successfully implemented react-native-cn-richtext-editor with limited toolbar functions.
I want to know that, how to get value (text that we have typed) from editor.
I am new in RN, have tried to get value but didn't get success. How can I resolve this issue, as I want to sent this text to server and then do further process.
In given example of this library there is method onValueChange on change the content object is present in value and to extract the value below example is there
onValueChanged = (value) => {
console.log(value[0].content[0].text)
}
Finally I got the solution of above question.
convert the value in HTML with convertToHtmlString write following command,
let html = convertToHtmlString(this.state.value)
for more details refer this github link
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
Hi I am a very novice when it comes to scripting. I am trying to write a Jython script that will take an image that is not at the front, in imageJ, and bring it to the front. I have tried using the WindowManager but routinely run into a similar error.
TypeError: setCurrentWindow(): 1st arg can't be coerced to
ij.gui.ImageWindow
or some other form of this error. It seems as though activating an image that is not at the front shouldn't be too difficult.
Here is the code I'm using:
from ij import IJ
from ij import WindowManager as WM
titles = WM.getIDList()
WM.setCurrentWindow(titles[:1])
The WindowManager.setCurrentWindow method takes an ImageWindow object, not an int image ID. But you can look up the ImageWindow for a given ID as follows:
WM.getImage(imageID).getWindow()
Here is a working version of your code:
from ij import IJ
from ij import WindowManager as WM
print("[BEFORE] Active image is: " + IJ.getImage().toString())
ids = WM.getIDList()
win = WM.getImage(ids[-1]).getWindow()
WM.setCurrentWindow(win)
win.toFront()
print("[AFTER] Active image is: " + IJ.getImage().toString())
Notes
I renamed your titles variable to ids because the method WindowManager.getIDList() returns a list of int image IDs, not a list of String image titles.
The WM.getImage(int imageID) method needs an int, not a list. So I used ids[-1], which is the last element of the ids list, not ids[:1], which is a subarray. Of course, you could pass whichever image ID you wish.
I added the call win.toFront(), which actually brings the window to the front. Calling WM.setCurrentWindow(win) is important in that it tells ImageJ that that image is now the active image... but it will not actually raise the window, which is what it seems like you want here.
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[].