Error with the create button

Hi Guys ,

I am planning to make a new doc from my custom app , vave with the following code which returns an error , please help

frappe.ui.form.on("VAVE", "refresh", function(frm){
     {
      frm.add_custom_button(__("Create dta"), function() {
        frappe.model.open_mapped_doc({
                        method : "vave.vave.doctype.dta.make_dta",
                        frm : cur_frm
                })
         })
    }
});

when I click on the create dta button , I am getting the below error displayed

Traceback (most recent call last):
  File "/home/ommi/frappe-bench/apps/frappe/frappe/app.py", line 55, in application
    response = frappe.handler.handle()
  File "/home/ommi/frappe-bench/apps/frappe/frappe/handler.py", line 19, in handle
    execute_cmd(cmd)
  File "/home/ommi/frappe-bench/apps/frappe/frappe/handler.py", line 30, in execute_cmd
    method = get_attr(cmd)
  File "/home/ommi/frappe-bench/apps/frappe/frappe/handler.py", line 114, in get_attr
    method = frappe.get_attr(cmd)
  File "/home/ommi/frappe-bench/apps/frappe/frappe/__init__.py", line 856, in get_attr
    return getattr(get_module(modulename), methodname)
AttributeError: 'module' object has no attribute 'make_dta'

Thanks in advance

Hi @ragav,

It seems that path is not correct, it should be like

method : "vave.vave.doctype.dta.dta.make_dta",

I hope dta is your doctype

Thanks

1 Like

Hi @rohit_w , Yes you are correct dta is my doctype , I changed my code , but still the same error , could you guide me please ?

Thanks in advance

Hi @ragav,

Can you share me your github repo, so its easy to me to find the issue.

Thanks

1 Like

So kind of you @rohit_w . This is the link to my repo GitHub - Niville/myerp1 at develop

I created a new doctype dta in my local inside the vave module which I am yet to push to my repo .

Thanks a ton for helping

Hi @ragav,

I have to check the file dta.py, It will be great if you push the module vave to your repo so I can easily checks the file dta.py.

Thanks

1 Like

Many thanks for the continued support @rohit_w . Link to the repo containing both vave and dta .

Thanks a lot for the help

Hi @ragav,

Path is correct but method make_dta is not present in the dta.py file, please check below

You need to write method in the dat.py file, for example check below js and py file

Js file

Py file

Thanks

1 Like

Many thanks for guiding me @rohit_w . I will try and revert back if I am struck somewhere .

Thanks again

Hi , @rohit_w

I edited the dta.py file and added this

@frappe.whitelist()
def make_dta(source_name, target_doc=None):

doclist = get_mapped_doc("dta", source_name,		{
		"dta": {
			"doctype": "vave",
			
		},

return doclist 

but I am getting an error now ,

Traceback (most recent call last):
  File "/home/ommi/frappe-bench/apps/frappe/frappe/app.py", line 55, in application
    response = frappe.handler.handle()
  File "/home/ommi/frappe-bench/apps/frappe/frappe/handler.py", line 19, in handle
    execute_cmd(cmd)
  File "/home/ommi/frappe-bench/apps/frappe/frappe/handler.py", line 30, in execute_cmd
    method = get_attr(cmd)
  File "/home/ommi/frappe-bench/apps/frappe/frappe/handler.py", line 114, in get_attr
    method = frappe.get_attr(cmd)
  File "/home/ommi/frappe-bench/apps/frappe/frappe/__init__.py", line 856, in get_attr
    return getattr(get_module(modulename), methodname)
  File "/home/ommi/frappe-bench/apps/frappe/frappe/__init__.py", line 643, in get_module
    return importlib.import_module(modulename)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/ommi/frappe-bench/apps/vave/vave/vave/doctype/dta/dta.py", line 16
    doclist = get_mapped_doc("dta", source_name,		{
          ^
IndentationError: expected an indented block

Could you please help me ?

Thanks in advance

Its indentation error, check and correct indentation on line number 16

1 Like

Thanks for the reply @makarand_b , I checked again everything seems to be correct , could you just indicate where I am wrong ?

Thanks in advance

dta.py don’t have code in given repo, can you push your code ?

1 Like

Many thanks for the reply @makarand_b . So kind of you for doing such a help , I pushed it to my repo

Many thanks for the support

@frappe.whitelist()
def make_dta(source_name, target_doc=None):

doclist = get_mapped_doc("dta", source_name,		{
		"dta": {
			"doctype": "vave",
			
		},

should be

@frappe.whitelist()
def make_dta(source_name, target_doc=None):
	doclist = get_mapped_doc("dta", source_name,{
			"dta": {
				"doctype": "vave",
				
			}, target_doc)
	return doclist

Thanks, Makarand

1 Like

Thanks a ton @makarand_b for swift reply . You are awesome .

I will check , many thanks my friend

Hi @makarand_b ,

Nope again I am getting a syntax error , please help .

Traceback (most recent call last):
  File "/home/ommi/frappe-bench/apps/frappe/frappe/app.py", line 55, in application
    response = frappe.handler.handle()
  File "/home/ommi/frappe-bench/apps/frappe/frappe/handler.py", line 19, in handle
    execute_cmd(cmd)
  File "/home/ommi/frappe-bench/apps/frappe/frappe/handler.py", line 30, in execute_cmd
    method = get_attr(cmd)
  File "/home/ommi/frappe-bench/apps/frappe/frappe/handler.py", line 114, in get_attr
    method = frappe.get_attr(cmd)
  File "/home/ommi/frappe-bench/apps/frappe/frappe/__init__.py", line 856, in get_attr
    return getattr(get_module(modulename), methodname)
  File "/home/ommi/frappe-bench/apps/frappe/frappe/__init__.py", line 643, in get_module
    return importlib.import_module(modulename)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/ommi/frappe-bench/apps/vave/vave/vave/doctype/dta/dta.py", line 20
    return doclist
         ^
SyntaxError: invalid syntax 

Thanks in advance

add one more tab to return doclist line. for get_map_doc syntax please check the sales_order.py, sales_invoice.py files.

Thanks for the reply @makarand_b . I already did that , you could see that in my repo , dunno exactly what is causing this error , please guide me

Thanks