Error during submition of Purchase Invoice

Hello,
could you please help me to submit Purchase Invoice?
I never had this problem before untill now.
When I want to submit PI it give me the message:

“Cost Center is required for ‘Profit and Loss’ account … Not saved”

When I try to fill in Cost center at the item in popup window and save it after that, the Cost center disappear again.
The same problem I have with Expense Head. There is original expense head, I can change it, but when I save it jump back to original one.

Do you have an idea what could be wrong?
Thank you.
Tomas

Hi @protocast,

Paste your browser’s console traceback here.

Thanks, Rohit

Hi @rohit_w,
where can I get it?
Thank you

@protocast

Use the keyboard shortcut

  • for mac Command + Option + J

  • For Windows/Linux Control + Shift + J .

Thanks, Rohit

Thank you.

jquery.min.js:4 POST https://protocast.erpnext.com/ 417 (EXPECTATION FAILED)k.cors.a.crossDomain.send @ jquery.min.js:4n.extend.ajax @ jquery.min.js:4frappe.request.call @ desk.min.js:7286frappe.call @ desk.min.js:7281_call @ form.min.js:204(anonymous function) @ form.min.js:195check_name @ form.min.js:198save @ form.min.js:195frappe.ui.form.save @ form.min.js:204(anonymous function) @ form.min.js:81j @ jquery.min.js:2k.add @ jquery.min.js:2_f.Frm.save @ form.min.js:79(anonymous function) @ form.min.js:73
desk.min.js:7297 Traceback (innermost last):
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/desk/form/save.py”, line 18, in savedocs
doc.save()
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/model/document.py”, line 259, in save
self.run_post_save_methods()
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/model/document.py”, line 638, in run_post_save_methods
self.run_method(“on_submit”)
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/model/document.py”, line 579, in run_method
return Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/model/document.py”, line 735, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/model/document.py”, line 718, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/model/document.py”, line 573, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappe/press/benches/1605111019/apps/erpnext/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py”, line 243, in on_submit
self.make_gl_entries()
File “/home/frappe/press/benches/1605111019/apps/erpnext/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py”, line 403, in make_gl_entries
make_gl_entries(gl_entries, cancel=(self.docstatus == 2))
File “/home/frappe/press/benches/1605111019/apps/erpnext/erpnext/accounts/general_ledger.py”, line 19, in make_gl_entries
save_entries(gl_map, adv_adj, update_outstanding)
File “/home/frappe/press/benches/1605111019/apps/erpnext/erpnext/accounts/general_ledger.py”, line 86, in save_entries
make_entry(entry, adv_adj, update_outstanding)
File “/home/frappe/press/benches/1605111019/apps/erpnext/erpnext/accounts/general_ledger.py”, line 94, in make_entry
gle.insert()
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/model/document.py”, line 193, in insert
self.run_before_save_methods()
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/model/document.py”, line 617, in run_before_save_methods
self.run_method(“validate”)
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/model/document.py”, line 579, in run_method
return Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/model/document.py”, line 735, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/model/document.py”, line 718, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/model/document.py”, line 573, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappe/press/benches/1605111019/apps/erpnext/erpnext/accounts/doctype/gl_entry/gl_entry.py”, line 21, in validate
self.pl_must_have_cost_center()
File “/home/frappe/press/benches/1605111019/apps/erpnext/erpnext/accounts/doctype/gl_entry/gl_entry.py”, line 57, in pl_must_have_cost_center
frappe.throw(
(“Cost Center is required for ‘Profit and Loss’ account {0}”).format(self.account))
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/init.py”, line 264, in throw
msgprint(msg, raise_exception=exc)
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/init.py”, line 257, in msgprint
_raise_exception()
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/init.py”, line 242, in _raise_exception
raise raise_exception, encode(msg)
ValidationError: Cost Center is required for ‘Profit and Loss’ account Sklad uctovany1 - PC

desk.min.js:7297 Traceback (innermost last):
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/app.py”, line 57, in application
response = frappe.handler.handle()
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/handler.py”, line 19, in handle
execute_cmd(cmd)
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/handler.py”, line 36, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/init.py”, line 806, in call
return fn(*args, **newargs)
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/desk/form/save.py”, line 18, in savedocs
doc.save()
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/model/document.py”, line 259, in save
self.run_post_save_methods()
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/model/document.py”, line 638, in run_post_save_methods
self.run_method(“on_submit”)
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/model/document.py”, line 579, in run_method
return Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/model/document.py”, line 735, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/model/document.py”, line 718, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/model/document.py”, line 573, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappe/press/benches/1605111019/apps/erpnext/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py”, line 243, in on_submit
self.make_gl_entries()
File “/home/frappe/press/benches/1605111019/apps/erpnext/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py”, line 403, in make_gl_entries
make_gl_entries(gl_entries, cancel=(self.docstatus == 2))
File “/home/frappe/press/benches/1605111019/apps/erpnext/erpnext/accounts/general_ledger.py”, line 19, in make_gl_entries
save_entries(gl_map, adv_adj, update_outstanding)
File “/home/frappe/press/benches/1605111019/apps/erpnext/erpnext/accounts/general_ledger.py”, line 86, in save_entries
make_entry(entry, adv_adj, update_outstanding)
File “/home/frappe/press/benches/1605111019/apps/erpnext/erpnext/accounts/general_ledger.py”, line 94, in make_entry
gle.insert()
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/model/document.py”, line 193, in insert
self.run_before_save_methods()
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/model/document.py”, line 617, in run_before_save_methods
self.run_method(“validate”)
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/model/document.py”, line 579, in run_method
return Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/model/document.py”, line 735, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/model/document.py”, line 718, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/model/document.py”, line 573, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappe/press/benches/1605111019/apps/erpnext/erpnext/accounts/doctype/gl_entry/gl_entry.py”, line 21, in validate
self.pl_must_have_cost_center()
File “/home/frappe/press/benches/1605111019/apps/erpnext/erpnext/accounts/doctype/gl_entry/gl_entry.py”, line 57, in pl_must_have_cost_center
frappe.throw(_(“Cost Center is required for ‘Profit and Loss’ account {0}”).format(self.account))
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/init.py”, line 264, in throw
msgprint(msg, raise_exception=exc)
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/init.py”, line 257, in msgprint
_raise_exception()
File “/home/frappe/press/benches/1605111019/apps/frappe/frappe/init.py”, line 242, in _raise_exception
raise raise_exception, encode(msg)
ValidationError: Cost Center is required for ‘Profit and Loss’ account Sklad uctovany1 - PC

Hi @rohit_w,
do you have an idea where could be a problem? When I add Cost center at the item in Editing raw table in Purchase invoice and save it, the Cost center disappear.
Thank you
protocast

Hi @protocast,

Please check whether the cost centre is group or node, it must be a node. One more select the cost centre from the drop down instead of type and save.

Thanks, Rohit

Thanks @rohit_w
It is node and I do select it from drop down menu.
protocast

Hi @protocast,

Set default cost centre on company form.

Thanks, Rohit

Hi @rohit_w,
Default cost center is already set up.
Thing is that it worked before and I do not think that I changed any setup.
thanks, protocast

Hi @protocast,

It seems that you have modified the ledger type of account Stock Received But Not Billed on company master. The ledger should be a liability account not an expense account. In case if you want to book the amount under expense account, you have to first disable the perpetual inventory setting.
Goto Setup > Accounts Settings > Uncheck Make Accounting Entry For Every Stock Movement > Save

For more details about perpetual inventory please check https://frappe.github.io/erpnext/user/manual/en/stock/accounting-of-inventory-stock/perpetual-inventory.html

Thanks, Rohit

Thank you @rohit_w it works now. I will study perpentual inventory.
Have a nice day!