check_for_stopped_status() recieves an empty doctype

Hi All,

I'm trying to create 'Purchase Receipts' via the API, and I'm hitting an error where app/buying/doctype/purchase_common/purchase_common.py -> check_for_stopped_status() appears to be getting passed an empty doctype. 


It could simply be that my request is malformed. Any advice appreciated.
-Jev

wn_client.wn_client.WNException: ["Traceback (innermost last):
  File "lib/webnotes/handler.py", line 78, in handle
    execute_cmd(cmd)
  File "lib/webnotes/handler.py", line 118, in execute_cmd
    ret = call(method, webnotes.form_dict)
  File "lib/webnotes/handler.py", line 140, in call
    return fn(**newargs)
  File "lib/webnotes/client.py", line 52, in insert
    return save(doclist)
  File "lib/webnotes/client.py", line 60, in save
    doclistobj.save()
  File "lib/webnotes/model/bean.py", line 299, in save
    self.run_method('validate')
  File "lib/webnotes/model/bean.py", line 239, in run_method
    getattr(self.controller, method)(*args, **kwargs)
  File "app/stock/doctype/purchase_receipt/purchase_receipt.py", line 62, in validate
    self.check_for_stopped_status(pc_obj)
  File "app/stock/doctype/purchase_receipt/purchase_receipt.py", line 225, in check_for_stopped_status
    pc_obj.check_for_stopped_status( d.prevdoc_doctype, d.prevdoc_docname)
  File "app/buying/doctype/purchase_common/purchase_common.py", line 158, in check_for_stopped_status
    status = 'Stopped'""" % (doctype, '%s'), docname)
  File "lib/webnotes/db.py", line 97, in sql
    self._cursor.execute(query, values)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in execute
    self.errorhandler(self, exc, value)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
 ProgrammingError: (1146, "Table 'my_db_name.tab' doesn't exist")
"]

Sample code that builds request:

        grn[]
        grn.append({
            'doctype': 'Purchase Receipt',
            'name': g['Name'],
            'status': 'Submitted',
            'tmp_name': g['Name'],
            'tracking_number': g['Tracking__c'],
            'company': company_name,
            'currency': supplier['default_currency'],
            'conversion_rate': utils.fx_rates[supplier['default_currency']],
            'courier': g['Courier__c'],
            'supplier': supplier['name'],
            'supplier_name': supplier['name'],
            'number_of_boxes': g['Package_Count__c'],
            'posting_date': g['Receipt_Date__c'],
            'fiscal_year': get_fiscal_year(g['Receipt_Date__c']),
            'historic': json.dumps(g, sort_keys=True, indent=4)
        })
        for i in g['lines']:
            grn.append({
                'doctype': 'Purchase Receipt Item',
                'parentfield': 'purchase_receipt_details',
                'tmp_parent': g['Name'],
                'item_code': product_id_code_map[i['Product__c']]['code'],
                'item_name': product_id_code_map[i['Product__c']]['name'],
                'prevdoc_docname': get_po_name(i['Purchase_Order__c']),
                'qty': i['Quantity__c'],
                'received_qty': i['Quantity_Advised__c'],
                'description': i['Goods_Receipt_Note__c'],
                })
        grns.append(grn)



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

You did not mention value for prevdoc_doctype field in Purchase Receipt item table, it is required if prevdoc_docname provided.

On 12 Jan 2014 11:09, "Jev Björsell" <eb...@gmail.com> wrote:
Hi All,

I'm trying to create 'Purchase Receipts' via the API, and I'm hitting an error where app/buying/doctype/purchase_common/purchase_common.py -> check_for_stopped_status() appears to be getting passed an empty doctype.


It could simply be that my request is malformed. Any advice appreciated.
-Jev

wn_client.wn_client.WNException: ["Traceback (innermost last):
File "lib/webnotes/handler.py", line 78, in handle
execute_cmd(cmd)
File "lib/webnotes/handler.py", line 118, in execute_cmd
ret = call(method, webnotes.form_dict)
File "lib/webnotes/handler.py", line 140, in call
return fn(**newargs)
File "lib/webnotes/client.py", line 52, in insert
return save(doclist)
File "lib/webnotes/client.py", line 60, in save
doclistobj.save()
File "lib/webnotes/model/bean.py", line 299, in save
self.run_method('validate')
File "lib/webnotes/model/bean.py", line 239, in run_method
getattr(self.controller, method)(*args, **kwargs)
File "app/stock/doctype/purchase_receipt/purchase_receipt.py", line 62, in validate
self.check_for_stopped_status(pc_obj)
File "app/stock/doctype/purchase_receipt/purchase_receipt.py", line 225, in check_for_stopped_status
pc_obj.check_for_stopped_status( d.prevdoc_doctype, d.prevdoc_docname)
File "app/buying/doctype/purchase_common/purchase_common.py", line 158, in check_for_stopped_status
status = 'Stopped'""" % (doctype, '%s'), docname)
File "lib/webnotes/db.py", line 97, in sql
self._cursor.execute(query, values)
File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in execute
self.errorhandler(self, exc, value)
File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
ProgrammingError: (1146, "Table 'my_db_name.tab' doesn't exist")
"]

Sample code that builds request:

grn[]
grn.append({
'doctype': 'Purchase Receipt',
'name': g['Name'],
'status': 'Submitted',
'tmp_name': g['Name'],
'tracking_number': g['Tracking__c'],
'company': company_name,
'currency': supplier['default_currency'],
'conversion_rate': utils.fx_rates[supplier['default_currency']],
'courier': g['Courier__c'],
'supplier': supplier['name'],
'supplier_name': supplier['name'],
'number_of_boxes': g['Package_Count__c'],
'posting_date': g['Receipt_Date__c'],
'fiscal_year': get_fiscal_year(g['Receipt_Date__c']),
'historic': json.dumps(g, sort_keys=True, indent=4)
})
for i in g['lines']:
grn.append({
'doctype': 'Purchase Receipt Item',
'parentfield': 'purchase_receipt_details',
'tmp_parent': g['Name'],
'item_code': product_id_code_map[i['Product__c']]['code'],
'item_name': product_id_code_map[i['Product__c']]['name'],
'prevdoc_docname': get_po_name(i['Purchase_Order__c']),
'qty': i['Quantity__c'],
'received_qty': i['Quantity_Advised__c'],
'description': i['Goods_Receipt_Note__c'],
})
grns.append(grn)



Note:



If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.



    End of Note



    You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.