I've found a way to get the active domain.
However, I think there must still be a better way to solve the problem.
In the browser inspector, I studied the http requests sent and received when a filter was activated.
The request looks something like this:
{
"jsonrpc":"2.0",
"method":"call",
"params":{
"model":"crm.lead",
"domain":[["type","=","opportunity"],["date",">=","2019-04-18"]],
"fields":["partner_id","user_id","phone","categs_id","state",],
"limit":80,
"sort":"create_date DESC",
"context":{
"lang":"fr_FR",
"tz":"Europe/Paris",
"uid":31,
"allowed_company_ids":[1],
"params":{"action":1647,"model":"crm.lead","view_type":"list","cids":"","menu_id":451},
"stage_type":"opportunity",
"default_type":"opportunity",
"default_user_id":31,
"needaction_menu_ref":"sale.menu_sale_quotations",
"bin_size":true
}
},"id":393865456
}
I was able to recover the active domain by importing “request” from odoo.http
from odoo.http import request
And then, in the source code of my python function :
http_request_domain = request.params.get('domain')
Based on all this, I think I'll be able to retrieve the list of record ids corresponding to the domain and achieve my goal.
Have a nice day
First, great you took the time to updated your post with your findings! Apart from that, I'm unsure about your usecase. For doing something based on records visible I would usually rather consider a computed field that is not stored. Also, as said, unsure about your usecase, but search, read, read_group etc all are functions on odoo.models (like create, write, etc) and can be extended per model. The search function for example has this definition: def search(self, domain, offset=0, limit=None, order=None) -> Self