I am interacting with HP QC using python and referring to HP ALM OTA documentation.
What I need is to access fields in different places (particularly now I am trying to access Test Set description field). As far as I know it is done by following: TestSet['description field name'] = 'I am description' The problem is - I don't know this field name and I can't find it in documentation mentioned.Up until now I was wondering around examples in hope to find these names (the way I found that Actual field in test step is named 'ST_ACTUAL').
Could you please help me find some kind of list of these field names. Or the way to retrieve them.. (Or at least give me the name of this Test Set description field)
When you get an entity field value, the field must be the underlying database column name for that entity. You can discover this using the project customization UI in HP ALM: select project entities then explore the system or user fields. Beware that the Design Step says the column name begins ST_... it doesn't. It's actually DS_...
You can also get this information programmatically. Given a factory instance use the equivalent of:
private void ExploreFactoryFieldDefinitions(IBaseFactory factory)
{
List fields = factory.Fields;
foreach (TDField field in fields)
{
FieldProperty field_property = (FieldProperty)field.Property;
if (field_property.IsRequired)
{
Log(String.Format("User Label: {0}\n", field_property.UserLabel));
Log(String.Format("User Column Type: {0}\n", field_property.UserColumnType));
Log(String.Format("DB Column Name: {0}\n", field_property.DBColumnName));
Log(String.Format("DB Column Type: {0}\n", field_property.DBColumnType));
Log(String.Format("DB Table Name: {0}\n", field_property.DBTableName));
}
}
}
field_property.UserLabel gives you the user friendly field name. field_property.DBColumn name gives you the database column name that should be used with entity[field_name].
BTW - don't forget to call entity.Post() to have your changes saved. When working with a versioned project you have a few more hoops to jump through too. Good luck!
I think, the field you are looking for is CY_COMMENT (hint). Maybe there is a better way—but you can find the names of the fields in the Query Builder. If you create an Excel Report and open the Query Builder, there is an Entities View which shows all the fields of the tables (even the user-defined fields). Maybe there is some kind of database documentation which gives you the same thing.
Related
I am confused by this syntax in the Python wrapper to the Odoo Object-Relational Mapping (ORM). I understand this is one way to access a field: table_name.field_name. However, I am not sure what this means table_name.field_name.field_name. I am not sure I am reading this correctly. This may not mean what I think the code means.
We are using the Odoo 11 API. The documentation for this topic, "field access", can be seen at the following URL: https://www.odoo.com/documentation/11.0/reference/orm.html#field-access
They even give an example but do not give a detailed explanation or a table definition of the relational database table they are referencing via Python.
>>> record.name
Example Name
>>> record.company_id.name
Company Name
>>> record.name = "Bob"
>>> field = "name"
>>> record[field]
Bob
I am confused by the line record.company_id.name. It seems safe to assume that 'record' is the table name. I would guess that 'company_id' is a column name in the 'record' table. But then if that is true, why is 'name' appended to 'company_id' with the dot operator? This is where I am confused.
I understand the code that accesses the "name" field in the "record" table like this: record.name. However, the field access with three dots record.company_id.name does not seem logical. Seems like this is trying to access a field of a field? 🤯
Thanks for reading this. Please let me know how I can improve.
I have created a module which modifies other one (named base). In the module base there is the res.partner model, and in this model there is the field birthdate:
_columns = {
...
'birthdate': fields.char('Birthdate'),
...
}
What I do in my module is to overwrite this field to make it of type Date:
birthdate = fields.Date('Birthdate')
Everything seems OK, but, after updating the Odoo server, the data introduced in that column dissapears from the view, and when I check the database, I find that the column birthdate is being duplicated with other names like birthdate_moved0, birthdate_moved1, birthdate_moved2, etc... (and half of them are of type char and the other half of type date). The values stored in birthdate are being moved to these other columns (that's the reason bacause I can't see the data in the view, since in the form only birthdate is being shown).
However, I was able to overwrite several fields through Python. But this duplication problem happened me with the field birthdate and the field function of the model res.partner.
I can't come to a conclussion. Can anyone help me here, please? Thank you in advance!
You should name your "new" field 'birth_date' or 'dob' or anything other than 'birthday' just to avoid changing existing field data type. In next step you can copy values from current 'birthday' field to new one (through postgresql).
Finally, a co-worker shown me the solution:
It's not about Odoo, it's due to PostgreSQL. Generally, in PostgreSQL, is not possible to alter the data type of a column (even when this is empty), except for some cases, like for example:
From integer to char: because the casting to char is possible. Therefore, in Odoo, when you change the data type of a field.Date, a field.Integer, a field.Many2one, etc... to a fields.Char, there is no problem. However, if you try to change a fields.Char to fields.Date or fields.Many2one, or whatever, PostgreSQL is going to duplicate the column because is not ready for that type of casting.
That's the reason because I wasn't able to change a field of type Char and transform it in a field of kind Date (my attempt with birthdate) or Many2one (my attempt with function). And on the other hand, I was able to overwrite a Selection field (actually, in PostgreSQL is convert a Char into another Char).
So in conclusion:
If you are going to change the type of data of a field, check if the final kind of data is char (fields.Char, fields.Selection, etc...) or other possible casting. Then you can name the new field with the same name as before. If not, you must name the new field with other name, otherwise PostgreSQL will duplicate the column with name_moved0, name_moved1, etc...
I hope this helps to anyone!!
How do you determine the name of a custom field in jira-python?
When I retrieve an issue, my custom fields show up as customfield_xxx
The names on my screen are 'project', 'name', 'due date', etc.
Short of putting a value in each field, then seeing where it appears
when I re-read the issue.
That is I can put 'a' in one of my fields, then read the issue, and find that
customfield_10801 (or whatever) has the value 'a'. But is there a general
way to find, for example, if my custom field is 'due date', which customfield_xxx
does it get mapped to?
Or, in the JIRA GUI, how would I look up these customfield #'s.
From the GUI you can see the custom field id in the html code or url:
On the admin page where all the custom fields are listed on the row of the custom field you are interested to the right click the gear and click/hover over "Configure". You should see the custom field ID in the URL.
Another way is via the REST API:
{jira-base-url}/rest/api/2/field
It's a GET request so just put that url in your browser.
Update:
Based on the comments it can be done something like this:
# Fetch all fields
allfields=jira.fields()
# Make a map from field name -> field id
nameMap = {field['name']:field['id'] for field in allfields}
# Fetch an issue
issue = jira.issue('ABC-1')
# You can now look up custom fields by name using the map
getattr(issue.fields, nameMap[custom_name])
I have a model based on ndb, while saving it, I stored 'id' field with current logged-in user's user id. (Why I am doing this? Actually this model used to be based on db.Model and key_name has this user's id. Now, I am converting it to ndb)
m= Modelclass(id = str(users.get_current_user().used_id()),
--- Other fields ---
m.put()
This model's edit form sends this 'id' and I wanted to get corresponding 'key' from it. But, I got "Key id number is too long; received 'some big_number'". Tried both ways
Modelclass.get_by_id(<id>).key
OR
ndb.Key('Modelclass', <id>)
This is one case, there may be other cases where user can store some big number in 'id' field. In these scenarios, we can't extract key from 'id'. So, how to solve such a problem.
I am new to ndb. Thanks for any help.
Looks like your value is an int, not a string. But you converted it into a string when creating the entitiy. There's a simple solution:
ndb.Key('Modelclass', str(<id>))
Good luck!
Our project is basically a web interface to several systems of record. We have many tables mapped, and the names of each column aren't as well named and intuitive as we'd like... The users would like to know what data fields are available (i.e. what's been mapped from the database). But, it's pointless to just give them column names like: USER_REF1, USER_REF2, etc.
So, I was wondering, is there a way to provide a comment in the declaration of my field?
E.g.
class SegregationCode(Entity):
using_options(tablename="SEGREGATION_CODES")
segCode = Field(String(20), colname="CODE", ...
primary_key=True) #Have a comment attr too?
If not, any suggestions?
Doing some research thru the SQLAlchemy documentation, my buddy and I found a line that says the Column object has a default dictionary called info that is a space to store "application specific data." So, in my case, I can just doing something like:
class SegregationCode(Entity):
using_options(tablename="SEGREGATION_CODES")
segCode = Field(String(20), colname="CODE", ...
primary_key=True, info={'description'='Segregation Code'})