(Odoo) How to filter rows/entities saved in a field of a model? - filtering

I am trying to filter the images (get images with a certain tag) that belong to a user. The images are stored in a field of the res.user model. I tried to solve the problem by using the search() method on the field but as a result, I am getting images that do not belong to that user. Can you give me any advice on how can I solve this problem by using some of the built-in Odoo methods?
request.env.user.image_ids.search([
('tag_id', 'in', image_tag),
])
Thanks

Please try:
filtered_records = request.env.user.image_ids.search([
('tag_id', 'in', image_tag)]).filtered(condition w.r.t field)

Related

ACF - category field data to its containing posts/pages

I am trying to find a general way to bring the field data of a category to the posts in this category.
My categories have fields like "e-mail", "adress" etc. and I can show this data on the category pages. It would make sense that the posts/pages assigned to a category somehow inherit the field data of their parent category.
Is there a way to achieve this through functions.php or some setting?
Some help would be greatly appreciated. Thanks!
Cheers, Markus
I am pretty sure you would have to do a separate query in the post/page template to get the acf field data associated with the category of the posts/pages.
You could make this into a function. You would send the categories from the template page for your posts or pages to this function and get the template to assemble the acf metadata.

how to filter Collection (Firebase) by uid in swift

I'm having problems trying to get one specific value from Firebase.
I'm using .whereField('uid', isEqualsTo: "givenID") in Collection("something") but I'm not getting any response. I know in Flutter the field is 'uid' but for some reason in swift isn't the same. I'll appreciate your help maybe with the name of the field or another way to bring the value with the given id in Firebase.
Useful information
Swift 5
XCODE 11.4.1
I found a "solution". Create a field in my Collection called "id" and assigning it with the same id from the document. Now I can just
db.collection("yourCollection").whereField("id", isEqualsTo: "givenID").
Not the best solution, but a solution is a solution.
UPDATE
I found it.
db.Collection("yourCollection").document("GivenID")
This bright you the subCollection
And that's all

Where are stored filter params in magento 2?

I need to export the products catalog after I applied a filter. I made a custom button for this, but in the query I need the filters already applied on the grid. Is it possible to get them from the global variable? I noticed that if I refresh the page, the filters are kept, but I do not know where they are from.
You can find applied filters data at the ui_bookmark table of your database;
SELECT `namespace`, `config` FROM `ui_bookmark`;

Select query for search with 2 or more words without double quotes against more than one field in solr

Please refer My previous question .
With respect to the this answer for my question, I could do with one filed.
I Could not able to do with multiple fields.
http://$solr_host:8983/solr/magazines/select&q=sport+education&df=title&q.op=OR - this is working for one field. How can I do it for multiple field.
What is the right way to achieve my objective. Thank you in advance.
Use Dismax/eDismax with qf (Query Fields) Parameter.
example:
http://$solr_host:8983/solr/magazines/select&q=sport+education&defType=edismax&qf=title name&q.op=OR
Check this here

Finding the number of different values of an attribute

I am writing an APS.NET MVC 5 application in C#, using a MongoDB database. Suppose I have a MongoDatabase object called my_db, which contains a MongoCollection of Label objects, called labels. Each Label object has a few attributes, one of which is a string called tag. Each tag value may be shared across different Labels, such that some Label objects will have the same value for tag.
I want to find out how many different values for tag there are in this collection, and store these values in an array of some sort.
I'm fairly new to MongoDB, so I don't really know how to do this. All I have done so far is get labels:
var labels = my_db.GetCollection<Label>("labels");
But I'm stuck as to what I need to do now. I could manually iterate through each Label in labels, and check whether that Label's tag attribute has already been seen before. But is there a neater way to do this with a MongoDB function? Thanks!
There is a MongoDB method for this: distinct, that should exist in any API.
As you are doing this on MVC 5 c# application, MongoDB provides C# LINQ Driver which will help your querying MongoDB using LINQ.
http://docs.mongodb.org/ecosystem/tutorial/use-linq-queries-with-csharp-driver/
Hope this helps.
var query = (from e in labels.AsQueryable<labelClass>()
select e.tag).Distinct()