Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
9261 Widoki

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?

Awatar
Odrzuć
Najlepsza odpowiedź


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:


Awatar
Odrzuć

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

Najlepsza odpowiedź

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


Awatar
Odrzuć

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

Powiązane posty Odpowiedzi Widoki Czynność
2
mar 25
1394
0
mar 25
4591
0
mar 25
2871
2
cze 25
678
1
mar 25
905