How to Get the ID field value in Odoo [duplicate] - odoo

This question already has an answer here:
How do I get the value from a form field using Odoo?
(1 answer)
Closed 7 years ago.
I'm new in Odoo 8 and have some difficulties getting the ID value of a object for example the ID field value of hr.employee, can you give me some sample in this matter

Please read the Official Doc for v8.0 , it will give you clear idea.
For note, if your are using New API then you just directly create model_object and fetch using model_obj.id
As on your example
HrEmployee = self.env['hr.employee']
employee_id = HrEmployee.id

Related

How to check the status code of one API from karate-config.js? [duplicate]

This question already has an answer here:
How to pass multiple parameters to callSingle karate on karate-config.js
(1 answer)
Closed 1 year ago.
We have to call two APIs only once in whole project which is a pre-requisite for all other features to run. All features are using values set in userId and unitId.
The first feature call is working fine but I am not sure how to add if condition on status code as only when the status code of first feature#test1 is 200 only then we want to call the second one else not.
The below code displayed the value as
User Id is -------------378
But is not going in the if condition although this API returned response code as 200.
var result = karate.callSingle('classpath:util/users.feature#test1',config);
config.userId = result.response.value[0].id;
karate.log("User Id is -------------" + config.userId)
if( result.status == 200 )
{
var result1 = karate.callSingle('classpath:util/users.feature#test2',config);
config.unitId = result1.response.value[0].id;
karate.log("Unit Id is -------------" + config.unitId)
}
It should be result.responseStatus.

Set SQL WHERE value using an element from a list [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I have a variable with a list on it and I need to use its value for my find option. I get an error when I set my id_user to id_u.
Here is the list
id_u = user_key[0]
This is my SELECT and WHERE
find = ("SELECT * FROM hashtags WHERE id_user=id_u")
You have to concatenate SELECT string with variable value.
Try like this:
id_u = user_key[0]
find = ("SELECT * FROM hashtags WHERE id_user=" + id_u)

karate gatling name resolver [duplicate]

This question already has answers here:
Is there an option for us to customize and group the test scenarios in the statics section of the Karate Gatling Report?
(2 answers)
Closed 1 year ago.
I have two scenarios in my feature file
#name=foo #name=fooRamp
Scenario : verify Performance for foo
Given def query = read('classpath:perf/testData/foo.graphql')
And request {query:'#(query)'}
And header karate-name = 'foo','fooRamp'
#name=bar #name=barRamp
Scenario : verify Performance for bar
Given def query = read('classpath:perf/testData/bar.graphql')
And request {query:'#(query)'}
And header karate-name = 'bar,'barRamp'
Two scenario I defined are
val scenario1=scenario("singleusers").exec(karateFeature("classpath:perf/foobar.feature#name=foo"))
.pause(3)
.exec(karateFeature("classpath:perf/foobar.feature#name=bar"))
val scenario2=scenario("ramp10Usersin30secs").exec(karateFeature("classpath:perf/foobar.feature#name=fooRamp"))
.pause(3)
.exec(karateFeature("classpath:perf/foobar.feature#name=barRamp"))
setUp(
scenario1.inject(atOnceUsers(1)).protocols(protocol),
scenario2.inject(rampUsers(10) during (30 seconds)).protocols(protocol)
)
What I get is
Request users metrics
foo 11 <responseTime>
bar 11 <responseTime>
I want to see in my report like
Request users metrics
foo 1 <responseTime>
bar 1 <responseTime>
fooRamp 10 <responseTime>
barRamp 10 <responseTime>
Is there any way that this can happen that I get separate names for single and ramp runs? Can nameresolver pick the different name for same feature scenario as per the scenario run in simulation? or do I need to create a duplicate scenario to achieve this?
I don't understand the logic after re-reading your question, so just do whatever conditional code you need and set a single header. Setting comma-delimited values won't work, it will take only the first.
* def temp = doSomeLogicHere()
And header karate-name = temp
There are multiple ways you can do the logic, look at the karate.info property, maybe looking at the feature name may give you what you need.

karate - how to read individual values from database query instead of hardcoding [duplicate]

This question already has an answer here:
Error using DBUtils in first scenario [duplicate]
(1 answer)
Closed 1 year ago.
In karate, I am trying to read database query
* def AccountDetails = db.readRow('select * from ')
From this I am trying to read individual values from this query and set this to one value
* set oimattrDetails $.User Login = AccountDetails.UD_BLR_USR_USER_LOGIN
Here, UD_BLR_USR_USER_LOGIN - is of the attribute present in the particular database
I do not want to hard code this value at this point. Instead assign this to some reference value and call it
*def USER_LOGIN = UD_BLR_USR_USER_LOGIN
Now use USER_LOGIN
* set oimattrDetails $.User Login = AccountDetails.USER_LOGIN
Something like this..But this is not working
Can any one help me here with exact syntax to use
A lot depends on what is the type of object returned by this code:
db.readRow()
That code is not part of Karate and you should provide more details here on that part - otherwise no one can help you. If it is not written by you, talk to the person or team who has written it - there is no point in talking about database "attributes". Maybe a simple solution is to add some Java code to the db object (I am assuming this is a Java utility) - to solve for your specific use case.
In short, your question sounds to me that it has nothing to do with Karate.

Getting list of questions that has not been shown or answered

I have two tables :
Question table where contains :
And then I have another table that is called
UserAnswerQuestion that contains :
That has reference to the question via question_id
The thing is that every time user answers a question I create a row in db saying :
question_id user_id has answered it and then I check if the answer is correct or not, if it's correct I put passed as a True, otherwise I put passed as a false.
Ok, from now is all ok, the thing that I can not get is I'm creating a method that returns to me the nextQuestion not answered, but I'm not able to do this method correctly.
What I'd like is to have a query that first return all questions that user have not answered yet, and then another query that returns just a question that user has not answered yet.
Note: This shown attribute was added because I want first to iterate over other questions instead of showing the ones that user has failed recently.
Is the question clear?
What I've tried?
I've tried to get the questions List<UserAnswerQuestion> findAllByUserEmailAndPassedFalseAndShownFalse(String email); but it doesn't work because with this table I can know every answer in every try that user does, so for example if I have a question that have 4 answers and 1 correct, this table can contain 4 row with the same question_question_id because the user perhaps has failed 3 times and then at the fourth it answers correctly.
Edit
I have already the questions that user can answer with this method :
public List<Question> getAllQuestionsThatUserCanAnswer(String email, Long topic){
List<Question> mList = this.questionRepository.findAllByTopicParentId(topic);
if(mList==null) return null;
List<UserAnswerQuestion> userAnswerQuestionList = this.userAnswerQuestionRepository.findAllByUserEmail(email);
for (UserAnswerQuestion userAnswerQuestion : userAnswerQuestionList) {
if(mList.contains(userAnswerQuestion.getQuestion())){
if(userAnswerQuestion.getPassed()){
mList.remove(userAnswerQuestion.getQuestion());
}
}
}
return mList;
}
Now I'm trying to do the getNext of this method but I do not know how to iterate over it.
Focus on SQL query that solve your problem
select * from Question q
left join Answer a on q.id = a.question_id
where a.id is null OR (a.passed != 'true' AND a.user_id = 1)
order by a.passed
Check scratch here