I am trying to use message_post() to add a message to the OpenChatter log whenever a product is changed in a sales order line. From what I can tell, that involves using mail.thread.message_post(). I figured that it should be included in the product_id_change function in sales.order.line so that it is called every time that a product is changed. My code looks something like this
class sales_order_detail_field(osv.Model):
_name = 'sale.order.line'
_inherit = ['sale.order.line','mail.thread']
_columns = {
'line_comment': fields.text('Comment'),
'part_no': fields.related('product_id', 'default_code', type='char', string ="Part Number"),
}
def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False, context=None):
{bulk of the product_id_change function that is irrelevant to this}
self.message_post(cr, uid, ids, subject='Product Change', body="A sales order line has been changed")
return {'value': result, 'domain': domain, 'warning': warning}
I feel like this should post a message every time the product is changed in a SO line, but nothing happens. I am not getting any errors at this point, but am also not getting any messages. Any idea why? Thanks!