• ¡Welcome to Square Theme!
  • This news are in header template.
  • Please ignore this message.
Hello There, Guest! Login Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random numbers in Basic Rate
#1
I am encountering an impossible bug.

I have created a Server Script to handle Before Submit of a Delivery Note.
The required functionality is record a special Material Transfer type Stock Entry

Today for the first time after more than 1500 executions, over the last two months, the script suddenly failed with the error …

""frappe.exceptions.Update After Submit Error:
____ Not allowed to change Basic Rate (as per Stock UOM) after submission"

… as you can see here below:

Code:
:       :       :       :       :       :
File "apps/frappe/frappe/model/document.py", line 868, in validate_update_after_submit
  d._validate_update_after_submit()
File "apps/frappe/frappe/model/base_document.py", line 857, in _validate_update_after_submit
  frappe.throw(
File "apps/frappe/frappe/__init__.py", line 504, in throw
  msgprint(
File "apps/frappe/frappe/__init__.py", line 479, in msgprint
  _raise_exception()
File "apps/frappe/frappe/__init__.py", line 434, in _raise_exception
  raise raise_exception(msg)
frappe.exceptions.UpdateAfterSubmitError:
   Not allowed to change Basic Rate (as per Stock UOM) after submission

After poking around for hours I edited the Frappe source code to add print statement line
Code:
print(f"df.label: {df.label} || self_value: ({self_value})  versus  db_value: ({db_value})")
… just before the thrown exception, like this …

File : frappe/frappe/model/base_document.py

My Date and Number Format settings specify Float = 9, but evidently the random number generated can be Float = 12 and causes this first “collision” after >1500 executions.

Even more annoying … it is not random!!! because I get the value 0.004792216125 every single time.
Questions:

    From where does Basic Rate (as per Stock UOM) get its value?
    How can I force a value of zero?
    Why do I get an “after submission” fault, if I am inserting a new record?
 
Reply
#2
It's odd how it keeps generating the same random value every time. Have you tried exploring your system settings to trace where that value might be coming from?And that "after submission" fault you're encountering—even with new records—is definitely unexpected. It might be worth revisiting any validation rules or restrictions in your system to see what's causing it.Your workaround with setting 'docstatus': 0 seems to provide a temporary fix, but it's important to unravel the underlying issue. But if you're ever stuck, you can always use a d20 roller to shake things up and approach the problem from a different angle.
 
Reply
  


Forum Jump:


Browsing: 2 Guest(s)