Rules for creating preference objects - rally

What are the rules to creating preference objects using the WSAPI?
Do you need to specify a workspace, project, or user or some combination?
When do preference names conflict with other names? Can you have the same Name field value but for a different user?
I am seeing the following error when I try to create a second preference object: Validation error: Preference.Value conflicts with NAME (where NAME is the value in the name field). What triggers this?
Thanks...

Yes, you need to specify one (and only one) of Workspace, Project, or User. This is the "scope" of the preference.
You can specify the same name for different scope values. For example, all of these are valid:
Name: 'A', User: 'Bob', Value: 'some value'
Name: 'B', User: 'Bob', Value: 'some value'
Name: 'A', User: 'Larry', Value: 'some value'
Name: 'A', Workspace: 'WS1', Value: 'some value'
But trying to create a new Preference with Name 'A' and User 'Bob' would fail, since that Name/Scope combination already exists.

Related

Which is better practice in Rest API, to return NESTED empty objects (no data), first level empty object or null or 404?

For instance:
Considering type Person = {id: number; name:string; age: number; description?: {eyes: string } }
Considering user: Person
we call the endpoint GET host/user/1
Scenario 1: user with id = 1 doesnt exist:
response1:
{id: null, name: null, age: null, description: {eyes: null}}
response2:
{}
response3:
null
response4:
http no-data code (404, 204)
Scenario 2: user with id = 1 DOES exist without optional attribute description:
response1:
{id: 1, name: "a name", age: 20 , description: {eyes: null}}
response2:
{id: 1, name: "a name", age: 20 , description: {}}
response3:
{id: 1, name: "a name", age: 20 , description: null}
In my opinion falsy values (or the 404/204 in the first scenario) would be the best for empty attributes as they are easier and cleaner to handle.
Note: I found several similiar questions in StackOverflow but none of then with nested objects
HTTP status code is determined by what kind of response you are sending; are you sending an error message that tells the client that there is currently no representation of the resource? etc.
For some resources, it does make sense that the resource has a current representation even though there is no corresponding data entity in storage. That's largely going to be determined by the semantics of the resource.
If you are sending back a representation of the resource, then the handling of missing optional attributes is largely a question of schema design; omitting a name, including a name with a null value, including a name with an empty array or object are all perfectly reasonable choices for representing that information isn't available.
The fact that you are using a "REST API" to fetch a representation expressed in this schema really doesn't change the answers at all.

Odoo 10 get model name from record

I'm creating a log entry within a server action in Odoo 10. This is the server action Python code:
if record:
env['ir.logging'].create({
'type': 'server',
'name': 'test',
'level': record._name,
'path': 'test',
'line': 'test,
'func': '#',
'message': '#'
})
The line value for level of record._name gets me the name of the current model as a string, for example, product.product, or sale.order.
However, I don't think the _name attribute is not meant to be part of the public API. Does anyone know of a public way to retrieve the name of the model?
The model variable is also available in the server action, which returns product.product(). However, want product.product, without the parenthesis. I realize I could just use a string method to trim off the (), but I'm wondering if there is an intended way to get just the name of the model as a string.
Any ideas?
I don't see another way. _name is "private" and you could use __str__, which will give you the model name and the ids of the current RecordSet. The regex for odoo's model names is r'^[a-z0-9_.]+$', so i suggest, what you've already known: trim off everything at the end.

Dojox grid Datagrid "Sorry, an error occured"

I have valid Datagrid defined on the page with attached ItemFileWriteStore and normally it show data.
However as soon as data will contain (almost) duplicate entry, I will see Sorry, an error occurred.
I the code I do not see any data fields definitions beyond DataGrid columns definitions.
I suppose that store and/or DataGrid components balk at duplicates, but I do not know how can I change data to avoid those duplicates.
PS my data contain 6 columns duplicates differ only by 3rd column. Is position important? Do sore/datagrid expect 1rst column to be unique? Or first defined datagrid column to be unique?
Dojo: 1.4
Did you set identifier? You need something unique (ID) to differentiate datastore items.
for example:
var store = new ItemFileReadStore({
data: {
identifier: "id",
items: [
{id: 1, name: 'A'},
{id: 2, name: 'B'},
{id: 3, name: 'c'}
]
}
});
you need to tell the store that your 3rd column is your identifier

Multiple 'belongsTo' relationships on thinky model

I have two models, User and Capture, where a Capture can be related to multiple users: it is owned, claimed, and processed all by three different users.
User = thinky.createModel 'User',
id: String
displayName: String
email: String
Capture = thinky.createModel 'Capture',
id: String
ownerID: String
processedByID: String
claimedByID: String
created: Date
updated: Date
Capture.belongsTo User.model, 'owner', 'ownerID', 'id'
Capture.belongsTo User.model, 'processedBy', 'processedByID', 'id'
Capture.belongsTo User.model, 'claimedBy', 'claimedByID', 'id'
The owner relationship works, but I cannot get the processedBy and claimedBy relationships to work. I'm querying with .getJoin(), and Thinky has created the secondary indexes on my tables (so it at least knows about the relationships)
What am I doing wrong? How can I get the nested objects to return in my queries?
That's because thinky will join another model once by default (to avoid circular references).
You must be explicit on the links you want to fetch:
Capture.getJoin({owner: true, processedBy: true, claimedBy: true}).run()

Opencart - How to get module settings at front-end

For example, I have a ABC_module, which are available in two layout, each module has an extra setting field: 'Category ID'.
common/home with position = 'Content Top', Category ID = 5
product/category with position = 'Content Left', Category ID = 4
Now I want to get the value of 'Category ID' setting in my front-end module controller.
So I can choose which Category to display to the user.
Can someone tell me how to do this?
The same way as non-admin config:
$this->config->get('key_that_you_need');
All data saved in table settings, look there the key name of setting you need and fetch it.