Fix Sales Order Item's Amount instead of Item Rate

Hi guys,

Currently I have some struggle since the client needs the Amount to be fixed regardless of the Item Rate. (on most of the Related Documents like Sales Order, Delivery Note, Sales Invoice)
So basically I tried to:

  1. Unlock the Amount Field
  2. Override the function calculate_item_values in client script like so: https://gist.github.com/nathando/efc9ef532e2142b574855

This successfully set the rate in client side. But the moment I press Save, it revert back to what it was… In the screenshot, Rate has been calculated by Amount and Amount has been fixed until Save is pressed.

I also checked the POST data, it actually POST wrong amount 99.96 instead of 100.
Before


After

Do you have any suggestions ?

The item calculation code is a pretty complex one. Maybe you can add a custom field for amount and back calculate the basic rate (?)

Hi rmehta,

Yes solved the problem with similar code to the above.

The calculation is complicated, so I only overwrite the calculate_item_values function.

2 Likes