Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
8840 Tampilan

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
Buang
Jawaban Terbai


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
Buang

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

Jawaban Terbai

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


Avatar
Buang

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

Post Terkait Replies Tampilan Aktivitas
2
Mar 25
1019
0
Mar 25
4591
0
Mar 25
2871
2
Jun 25
271
1
Mar 25
662