Value cannot be changed for Valuation Method

Hi,

When I’m trying to update an item(template), an error occurs which says Value cannot be changed for Valuation Method. I’ve searched the forum before submitting this post but I think this is slightly different from what I’ve found in other topics. It is not uploading .csv but the issue is occurring when I try to save directly after making changes (in my case it is changing a custom field) in the item template which has variants.

Below is the traceback I see in the browser console

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/save.py”, line 22, in savedocs
doc.save()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 256, in save
return self._save(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 307, in _save
self.run_post_save_methods()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 887, in run_post_save_methods
self.run_method(“on_update”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 755, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1024, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1007, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 749, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/stock/doctype/item/item.py”, line 111, in on_update
self.update_variants()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/stock/doctype/item/item.py”, line 631, in update_variants
variant.save()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 256, in save
return self._save(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 293, in _save
self._validate()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 455, in _validate
self.validate_set_only_once()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 482, in validate_set_only_once
frappe.CannotChangeConstantError)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 323, in throw
msgprint(msg, raise_exception=exc, title=title, indicator=‘red’)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 309, in msgprint
_raise_exception()
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 282, in _raise_exception
raise raise_exception(encode(msg))
CannotChangeConstantError: Value cannot be changed for Valuation Method
desk.min.js:6791 Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 62, in application
response = frappe.handler.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 22, in handle
data = execute_cmd(cmd)
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 53, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 939, in call
return fn(*args, **newargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/save.py”, line 22, in savedocs
doc.save()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 256, in save
return self._save(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 307, in _save
self.run_post_save_methods()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 887, in run_post_save_methods
self.run_method(“on_update”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 755, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1024, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1007, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 749, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/stock/doctype/item/item.py”, line 111, in on_update
self.update_variants()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/stock/doctype/item/item.py”, line 631, in update_variants
variant.save()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 256, in save
return self._save(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 293, in _save
self._validate()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 455, in _validate
self.validate_set_only_once()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 482, in validate_set_only_once
frappe.CannotChangeConstantError)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 323, in throw
msgprint(msg, raise_exception=exc, title=title, indicator=‘red’)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 309, in msgprint
_raise_exception()
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 282, in _raise_exception
raise raise_exception(encode(msg))
CannotChangeConstantError: Value cannot be changed for Valuation Method

Please help us…
We are on the latest version:
ERPNext: v10.1.6 (master)
Frappe: v10.1.2 (master)

Do you have existing Items already created from this template? If yes, maybe you would have to create another template or change the valuation rate on the Item that is being created itself. (The item should not have any stock entries when you change valuation rate setting)