Empty frappe.get_list in Python

I have created new app and installed it to the site where erpnext is.
Configured hooks.py to call my own methods on the DocTypes.

But my following code returns nothing, while JS code do the things.

Here is my Python code:

import frappe
from var_dump import var_dump

def transfer_confirmation_check(doc,event):
    manager_account_item = frappe.get_list('AccountAgent', filters={'user': frappe.session.user})
    frappe.msgprint(str(var_dump(manager_account_item)))

manager_account_item var is empty

JS code

frappe.call({
  method:"frappe.client.get_list",
  args: {
      doctype:"AccountAgent",
   filters:{
              user: frappe.session.user}
      },
  callback: function(r) {
   console.log(r)
  }
})

In console i see:

message: 0: Object { name: "7e92f394bc" }

What I do wrong in PY? Maybe I must do some special referencing to doctype from app, not just ‘AccountAgent’?

Any help apriciated to clarify this!

Hi,
Please try

import frappe
from var_dump import var_dump

def transfer_confirmation_check(doc,event):
    manager_account_item = frappe.get_list('AccountAgent', filters={'user': frappe.session.user}, fields=["name"])
    frappe.msgprint(str(var_dump(manager_account_item)))

Thanks for reply, but nothing changed :frowning:

could you please say how your configured your hooks.py?

To call python method from js, you have to whitelist the python method.

Add @frappe.whitelist() above the method definition

my method “transfer_confirmation_check” executes successfully, because if I put “frappe.msgprint(frappe.session.user)” in it, I see frappe message box with logged username.

To clarify:

doc_events = {
	"Payment Entry": {
		"validate": "unium_transfers.unium_transfers.payment_entry_custom.transfer_confirmation_check"
	},
} 

Thanks for the reply, but u misunderstood my my problem:
I don’t need to execute my PY method from clientside, my JS posted above works flawlessly and it is full duplicate of PY that doesn’t work as I expect.

Sorry I don’t know what it’s var_dump
Could you please try

import frappe
from var_dump import var_dump

def transfer_confirmation_check(doc,event):
    manager_account_item = frappe.get_list('AccountAgent', filters={'user': frappe.session.user}, fields=["name"])
    frappe.msgprint(str(manager_account_item[0].name))

Thanks a lot! It works!

It seems that var_dump was a problem.

Many thanks once again! :clap:

Sorry, I misunderstood.

amazing) you are welcome)