[10.0] Where should I hook into the many2one widget to partially pre-fill the search term?
I'm trying to pre-fill the search term of a many2one field (if it is blank).
The use case is semi-structured 'internal reference' on a product. I've got a wizard form to copy a sale.order.line in a very bespoke way. I want to default the product_id to False, but pre-fill the search box with part of the internal reference of the product, with everything after the first forward-slash (/) stripped off. The idea is to make it very easy for the user to search among similar products by their SKU (by adding /BLK/M for example to get the black medium variant), but also easy to widen the search if necessary by deleting the pre-filled search text.
My intended interface is that I would set a different field on the TransientModel backing the wizard form with the intended default prefix, and provide the name of that field as a new attribute initial_search on the many2one widget. In edit mode it would then pre-fill the search term from the named field iff that attribute is set and the actual value of the field is blank.
I've been digging around in the many2one widget code in addons/web/src/js/views/form_common.js and form_relational_widgets.js but there are so many similarly-named methods I can't work out which I should use.
My question is, where should I hook in to add this feature?
Boilerplate code so far (with an example of how I envisage the configuration working): https://pastebin.com/NwJvqUB0