As shown in picture, “Transport Allowance” is calculated if “TA provided” is set to Yes. I have customized with hooks.py. This works only after saving the document. This hooks code will not work if edited after submitting the document.
Yes, this option enables fields to be editable, but i need to auto update the fields which are dependent on field which is enabled “Allow on Submit”.
In above picture, field “TA Provided” is set to “Allow on Submit”, the field “Transport Allowance” should be changed to zero when we set “TA Provided” to “No”. But even after we alter the of “TA Provided”, the field “Transport Allowance” remains same as that was before Submitting the document.
In the above picture 2nd column fields are set as “Allow on Submit”, and 3rd column fields are dependent on these fields, 3rd column field should get changed if we change 2nd column fields.
I am using hooks as follows:
After submitting the salary structure assignment, we have to avail employee with food allowance…
I have created above fields and created the above code, and it 3rd column fields will be fetched into salary slips.
The code works perfectly before submit and after save. But after submit even if I change 2nd column fields the 3rd column fields remain unchanged.
Ex: I above picture, if “Company Accommodation” is No, Food Allowance will not be provided, and if it yes it should assign the value 300. I am using the code,
edited reply above to use doc. instead of self. Create your method in any file and use the dotted path to the method in your custom app hooks.py. e.g. on_submit hook in erpnext hooks.py for ‘Stock Entry’