Hi community, I want to thank you in advance for taking the time to read my question.
I currently overriding the product name_get(), so that when I'm selecting a product, I can do so by a custom 'part number' defined by me. I don't want this override to affect EVERY view, so I'm using the context in my xml file.
My name_get() looks like this:
def name_get(self, cr, uid, ids, context=None): result = []
if 'my_trigger' in context:
product_ids = self.pool.get('product.product').browse(cr,uid,ids,context)
for prod in product_ids:
result.append((prod.id,str(prod.part_number)))
return result
else:
return super(product_product, self).name_get(cr, uid, ids, context=context)
On my purchase order, I have the following xml field, that updates the contex to let my name_get() know that this is a 'special' box:
<field name="product_id" context="{'my_trigger':'1'}"/>
Everything works when I click the dropdown and type through my search. I can select and search by part number. But when I click off the cell, and/or hit the save button, the field reverts to the default name_get value! After doing some research, it looks like something is calling the name_get() function both (1) when I click off a cell, and (2) when I click the save button. Is there a way I can update the context when this happens so that my overriden name_get() knows that it should return the part_number field? Anyone have any suggestions?
Thanks so much,
Tim