Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
9448 Zobrazení

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
Zrušit
Nejlepší odpověď


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
Zrušit

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

Nejlepší odpověď

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


Avatar
Zrušit

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

Related Posts Odpovědi Zobrazení Aktivita
2
bře 25
1593
0
bře 25
4591
0
bře 25
2871
2
čvn 25
894
1
bře 25
1037