Hi!
The string representation in these fields is generally determined by the function name_get() of the concerned entity. In your case this would be name_get() inside the ProductProduct class (here for Odoo 12).
You can override this function and then either completely build the names yourself or take the result from the inherited class and modify them. You might want to take a look at the original method first, since the function is not really short in the case of products. In general, overriding the method works like in any other case, but keep in mind that it always returns an array of tuples in the form of (<ID>, <name>), because it is called for multiple products at once.
If you need additional product attributes but want to utilize the default name construction, you could modify the original string with something like this:
from odoo import api, models
class ProductProduct(models.Model):
_inherit = 'product.product'
@api.multi
def name_get(self):
result = []
for record in self:
name = super(ProductProduct, record).name_get()[0][1]
# TODO: modify the name as needed
result.append((record.id, name))
return result
Alternatively, you could of course construct the names completely on your own or just fall back to the super implementation for products you do not need to modify. I hope this works for you and helps you with all the cases you have in mind.
Search many2one filed by other than name: https://goo.gl/7PHhPP