ERPNext.com Frappe Cloud Support Partners Foundation Frappe School

POS cannot submit sales invoice and is using wrong cost center in multicompany

I’m created 2 companies. The default company is educational, and the other is retail.
I set up a cashier with Sales User and Account User roles. In User Permission I allow this user can only use Retail Warehouse and Company.
My intention is the Cashier user can only sell Items from retail warehouse and post it in retail company.
While the first requirement is met, POS can only show items from retail warehouse. But the second requirement gave me this error:

Sales Invoice SINV-00001: Cost Center Main - KAFB does not belong to Company BAFB

The log is:

      File "/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/sales_invoice/pos.py", line 480, in submit_invoice
        si_doc.submit()
      File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 741, in submit
        self._submit()
      File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 730, in _submit
        self.save()
      File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 230, in save
        return self._save(*args, **kwargs)
      File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 280, in _save
        self.run_post_save_methods()
      File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 793, in run_post_save_methods
        self.run_method("on_submit")
      File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 666, in run_method
        out = Document.hook(fn)(self, *args, **kwargs)
      File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 887, in composer
        return composed(self, method, *args, **kwargs)
      File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 870, in runner
        add_to_return_value(self, fn(self, *args, **kwargs))
      File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 660, in <lambda>
        fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
      File "/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/sales_invoice/sales_invoice.py", line 131, in on_submit
        self.make_gl_entries()
      File "/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/sales_invoice/sales_invoice.py", line 594, in make_gl_entries
        update_outstanding=update_outstanding, merge_entries=False)
      File "/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/general_ledger.py", line 19, in make_gl_entries
        save_entries(gl_map, adv_adj, update_outstanding, from_repost)
      File "/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/general_ledger.py", line 88, in save_entries
        make_entry(entry, adv_adj, update_outstanding, from_repost)
      File "/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/general_ledger.py", line 99, in make_entry
        gle.insert()
      File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 192, in insert
        self.run_before_save_methods()
      File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 772, in run_before_save_methods
        self.run_method("validate")
      File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 666, in run_method
        out = Document.hook(fn)(self, *args, **kwargs)
      File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 887, in composer
        return composed(self, method, *args, **kwargs)
      File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 870, in runner
        add_to_return_value(self, fn(self, *args, **kwargs))
      File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 660, in <lambda>
        fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
      File "/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/gl_entry/gl_entry.py", line 25, in validate
        self.validate_cost_center()
      File "/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/gl_entry/gl_entry.py", line 112, in validate_cost_center
        .format(self.voucher_type, self.voucher_no, self.cost_center, self.company))
      File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 319, 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))
    ValidationError: Sales Invoice SINV-00001: Cost Center Main - KAFB does not belong to Company BAFB```

Submitting Sales Invoice can be done by manually taking off Write Off Account and Write Off Cost Center

Weird…

Any help on this yet? Am experiencing the same thing.

Here’s my log

    Traceback (most recent call last):
  File "/home/outcom/frappe-bench/apps/erpnext/erpnext/accounts/doctype/sales_invoice/pos.py", line 485, in submit_invoice
    si_doc.submit()
  File "/home/outcom/frappe-bench/apps/frappe/frappe/model/document.py", line 834, in submit
    self._submit()
  File "/home/outcom/frappe-bench/apps/frappe/frappe/model/document.py", line 823, in _submit
    self.save()
  File "/home/outcom/frappe-bench/apps/frappe/frappe/model/document.py", line 259, in save
    return self._save(*args, **kwargs)
  File "/home/outcom/frappe-bench/apps/frappe/frappe/model/document.py", line 310, in _save
    self.run_post_save_methods()
  File "/home/outcom/frappe-bench/apps/frappe/frappe/model/document.py", line 893, in run_post_save_methods
    self.run_method("on_submit")
  File "/home/outcom/frappe-bench/apps/frappe/frappe/model/document.py", line 758, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/outcom/frappe-bench/apps/frappe/frappe/model/document.py", line 1027, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/outcom/frappe-bench/apps/frappe/frappe/model/document.py", line 1010, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/outcom/frappe-bench/apps/frappe/frappe/model/document.py", line 752, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/outcom/frappe-bench/apps/erpnext/erpnext/accounts/doctype/sales_invoice/sales_invoice.py", line 134, in on_submit
    self.make_gl_entries()
  File "/home/outcom/frappe-bench/apps/erpnext/erpnext/accounts/doctype/sales_invoice/sales_invoice.py", line 605, in make_gl_entries
    update_outstanding=update_outstanding, merge_entries=False)
  File "/home/outcom/frappe-bench/apps/erpnext/erpnext/accounts/general_ledger.py", line 19, in make_gl_entries
    save_entries(gl_map, adv_adj, update_outstanding, from_repost)
  File "/home/outcom/frappe-bench/apps/erpnext/erpnext/accounts/general_ledger.py", line 88, in save_entries
    make_entry(entry, adv_adj, update_outstanding, from_repost)
  File "/home/outcom/frappe-bench/apps/erpnext/erpnext/accounts/general_ledger.py", line 99, in make_entry
    gle.insert()
  File "/home/outcom/frappe-bench/apps/frappe/frappe/model/document.py", line 221, in insert
    self.run_before_save_methods()
  File "/home/outcom/frappe-bench/apps/frappe/frappe/model/document.py", line 862, in run_before_save_methods
    self.run_method("validate")
  File "/home/outcom/frappe-bench/apps/frappe/frappe/model/document.py", line 758, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/outcom/frappe-bench/apps/frappe/frappe/model/document.py", line 1027, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/outcom/frappe-bench/apps/frappe/frappe/model/document.py", line 1010, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/outcom/frappe-bench/apps/frappe/frappe/model/document.py", line 752, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/outcom/frappe-bench/apps/erpnext/erpnext/accounts/doctype/gl_entry/gl_entry.py", line 25, in validate
    self.validate_cost_center()
  File "/home/outcom/frappe-bench/apps/erpnext/erpnext/accounts/doctype/gl_entry/gl_entry.py", line 112, in validate_cost_center
    .format(self.voucher_type, self.voucher_no, self.cost_center, self.company))
  File "/home/outcom/frappe-bench/apps/frappe/frappe/__init__.py", line 323, in throw
    msgprint(msg, raise_exception=exc, title=title, indicator='red')
  File "/home/outcom/frappe-bench/apps/frappe/frappe/__init__.py", line 309, in msgprint
    _raise_exception()
  File "/home/outcom/frappe-bench/apps/frappe/frappe/__init__.py", line 282, in _raise_exception
    raise raise_exception(encode(msg))
ValidationError: Sales Invoice SINV-RET-00002: Cost Center Main - OTG does not belong to Company Veggiefresh

any solutions ?