Both of them create gl entry submit and preview


both of them call make_gl_entries method
what the diff between them?!

When you click the “Accounting Ledger” button, it makes GL entries but rolls back the transaction.

Check below code for reference

1 Like

okey this good
how could i fire method when the gl entry insert and not rollback?

For these types of tasks, there are many solutions depending on the scenario and the way you want to approach them.

  • Check whether the request path is different using frappe.local.request.path for both requests?

or

  • You can set flags (frappe.flags.gl_preview = true) and check in your code if frappe.flags.gl_preview is true, but for this, you will have to override the stock_controller.py code or other ERPNext file code.


i commet this code
but


did not create in db?!

If you are making changes directly on the server, then you should run the bench restart command to take effect.

i did it
but no thing effect happend i test it by throw the Test first and its worked with me then i commet it but no thing happend with me

try replacing frappe.db.rollback() with frappe.db.commit()

this code is framework not mine

You were making changes to the framework code, which is why I suggested you do that. As I already mentioned, you will have to override methods to make changes. :blush:

i understand you
but based there code the rollback effect but we did not find the real data that the rollback rollback it

Just for testing, add a commit and check if records are inserted into the database. Don’t forget to run the restart command after making changes.

by the way the reverse entry does not appear in general entry
but still in gl entry and still make gl entry in submit or cancel

this create gl entry

Actually, I am not from an accounting background, so I don’t know what a reverse GL entry is. :sweat_smile:

Some GL entries (passed via journal vouchers like period close vouchers, provisions and other account closing adjustments) are posted and need to be reversed to remove the impact of those transactions. They are like temporary entries posted to show true and fair accounting status as of the closing report date. However, since these transactions are more estimation-based, they need to be reversed.

i get this error when i bulk more than 19 rows (recordes)

 File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
      args = (<GLEntry: 2a31cabadc docstatus=1>,)
      kwargs = {}
      apply_condition = <function whitelist.<locals>.innerfn.<locals>.<lambda> at 0x71dda3dd88b0>
      func = <function Document.submit at 0x71dda3dd8820>
  File "apps/frappe/frappe/model/document.py", line 1060, in submit
    return self._submit()
      self = <GLEntry: 2a31cabadc docstatus=1>
  File "apps/frappe/frappe/model/document.py", line 1043, in _submit
    return self.save()
      self = <GLEntry: 2a31cabadc docstatus=1>
  File "apps/frappe/frappe/model/document.py", line 342, in save
    return self._save(*args, **kwargs)
      self = <GLEntry: 2a31cabadc docstatus=1>
      args = ()
      kwargs = {}
  File "apps/frappe/frappe/model/document.py", line 364, in _save
    return self.insert()
      self = <GLEntry: 2a31cabadc docstatus=1>
      ignore_permissions = None
      ignore_version = None
  File "apps/frappe/frappe/model/document.py", line 312, in insert
    self.run_method("after_insert")
      self = <GLEntry: 2a31cabadc docstatus=1>
      ignore_permissions = None
      ignore_links = None
      ignore_if_duplicate = False
      ignore_mandatory = None
      set_name = None
      set_child_names = True
  File "apps/frappe/frappe/model/document.py", line 974, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
      self = <GLEntry: 2a31cabadc docstatus=1>
      args = ()
      kwargs = {}
      fn = <function Document.run_method.<locals>.fn at 0x71dda07d4af0>
      method = 'after_insert'
  File "apps/frappe/frappe/model/document.py", line 1334, in composer
    return composed(self, method, *args, **kwargs)
      self = <GLEntry: 2a31cabadc docstatus=1>
      args = ()
      kwargs = {}
      hooks = [<function after_insert at 0x71dda09dfe20>]
      method = 'after_insert'
      doc_events = {'*': {'on_update': ['frappe.desk.notifications.clear_doctype_notifications', 'frappe.workflow.doctype.workflow_action.workflow_action.process_workflow_actions', 'frappe.core.doctype.file.utils.attach_files_to_document', 'frappe.automation.doctype.assignment_rule.assignment_rule.apply', 'frappe.automation.doctype.assignment_rule.assignment_rule.update_due_date', 'frappe.core.doctype.user_type.user_type.apply_permissions_for_non_standard_user_type'], 'after_rename': ['frappe.desk.notifications.clear_doctype_notifications'], 'on_cancel': ['frappe.desk.notifications.clear_doctype_notifications', 'frappe.workflow.doctype.workflow_action.workflow_action.process_workflow_actions', 'frappe.automation.doctype.assignment_rule.assignment_rule.apply'], 'on_trash': ['frappe.desk.notifications.clear_doctype_notifications', 'frappe.workflow.doctype.workflow_action.workflow_action.process_workflow_actions'], 'on_update_after_submit': ['frappe.workflow.doctype.workflow_action.workflow_action.process_w...
      handler = 'my_app.crud_events.gl_entry.after_insert'
      composed = <function Document.hook.<locals>.compose.<locals>.runner at 0x71dda07d6050>
      compose = <function Document.hook.<locals>.compose at 0x71dda07d5bd0>
      f = <function Document.run_method.<locals>.fn at 0x71dda07d4af0>
  File "apps/frappe/frappe/model/document.py", line 1318, in runner
    add_to_return_value(self, f(self, method, *args, **kwargs))
      self = <GLEntry: 2a31cabadc docstatus=1>
      method = 'after_insert'
      args = ()
      kwargs = {}
      f = <function after_insert at 0x71dda09dfe20>
      add_to_return_value = <function Document.hook.<locals>.add_to_return_value at 0x71dda07d4dc0>
      fn = <function Document.run_method.<locals>.fn at 0x71dda07d4af0>
      hooks = (<function after_insert at 0x71dda09dfe20>,)
  File "apps/my_app/my_app/crud_events/gl_entry.py", line 114, in after_insert
    frappe.throw(e)
      doc = <GLEntry: 2a31cabadc docstatus=1>
      method = 'after_insert'
  File "apps/frappe/frappe/__init__.py", line 603, in throw
    msgprint(
      msg = AttributeError('request')
      exc = <class 'frappe.exceptions.ValidationError'>
      title = None
      is_minimizable = False
      wide = False
      as_list = False
      primary_action = None
  File "apps/frappe/frappe/__init__.py", line 568, in msgprint
    _raise_exception()
      title = None
      as_table = False
      as_list = False
      indicator = 'red'
      alert = False
      primary_action = None
      is_minimizable = False
      wide = False
      realtime = False
      sys = <module 'sys' (built-in)>
      _raise_exception = <function msgprint.<locals>._raise_exception at 0x71dda07d6680>
      inspect = <module 'inspect' from '/usr/lib/python3.10/inspect.py'>
      msg = AttributeError('request')
      out = {'message': AttributeError('request'), 'title': 'Message', 'indicator': 'red', 'raise_exception': 1, '__frappe_exc_id': '29d733f4110156e0568001db2d162157cd2f5b3810149ccec4d2226b'}
      raise_exception = <class 'frappe.exceptions.ValidationError'>
  File "apps/frappe/frappe/__init__.py", line 519, in _raise_exception
    raise exc
      exc = ValidationError(AttributeError('request'))
      inspect = <module 'inspect' from '/usr/lib/python3.10/inspect.py'>
      msg = AttributeError('request')
      out = {'message': AttributeError('request'), 'title': 'Message', 'indicator': 'red', 'raise_exception': 1, '__frappe_exc_id': '29d733f4110156e0568001db2d162157cd2f5b3810149ccec4d2226b'}
      raise_exception = <class 'frappe.exceptions.ValidationError'>
frappe.exceptions.ValidationError: request