Skip to Content
Menú
This question has been flagged
2 Respostes
9451 Vistes

I would like to track the change of cost of a product in the inventory module. For example, if someone changes the cost from 50 to 60, I would like it to appear in the chatter or somewhere that is easy to access. For example : "The cost has been changed from 50 to 60 on 4th December 2020". It would be nice if I could also make a graph from the changes based on months.


I have tried using audit trail, but it tracks the changes of all the fields. I am only interested in the change of the cost of product. Track_visibility only tells me that the cost has been changed, but it doesn't tell me from which value to which value. I would still like to know the previous value of cost even after updating the value. Is this possible?

Avatar
Descartar
Best Answer


You can do this with an Automated Action that is triggered On Update of either the Product model (if you are using Product Variants) or Product Template model (if you are not).




for record in records:
  currency_symbol = record.currency_id.symbol
  if record._context.get('old_values'):
    old_vals = record._context['old_values'].get(record.id, {})
    if 'standard_price' in old_vals:
      record.message_post(body="Cost changed from %s%.2f to %s%.2f." 
                          % (currency_symbol,
                             old_vals['standard_price'],
                             currency_symbol,
                             record.standard_price))


This will record cost price changes in the Chatter, like this:


Avatar
Descartar

Hello does it work for standard_price in V13 ? I could achieve to do it for list_price, but not for standard_price.

Best Answer

Track visibility shows both old and new values. Here's a sample.


Avatar
Descartar

Seems to work if cost is changed manually but not when receiving stock that affects the avg cost?

Related Posts Respostes Vistes Activitat
2
de març 25
1594
0
de març 25
4591
0
de març 25
2871
2
de juny 25
894
1
de març 25
1037