Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
2 Antworten
9670 Ansichten

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
Verwerfen
Beste Antwort


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
Verwerfen

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

Beste Antwort

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


Avatar
Verwerfen

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

Verknüpfte Beiträge Antworten Ansichten Aktivität
2
März 25
1803
0
März 25
4591
0
März 25
2871
2
Juni 25
1063
1
März 25
1150