API for ERPNext

Jonathan,

I am assuming you want something like a search based on a filter. I think it should be possible.

- Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 29-Jan-2013, at 9:36 PM, Jonathan <ir...@gmail.com> wrote:

Hi Rushabh,

I have updated all the scripts, but I am happy enough if it all works under Linux.

Would it be possible to have a generalization of get_doc along the following lines:

def get_doc(server, doctype, name, value):
    return request(server, { "cmd":"webnotes.client.get", "doctype":doctype, name:value})

because, for example for retrieving a sales order, I may know the purchase order number but not the sales order name.

Thanks.

- j





Jonathan,

Great.

Are you running the latest update of the requests module? I did not encounter this error on my Mac.


Anyways, I updated the webclient.py to use posts when required.

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 21-Jan-2013, at 11:16 PM, Jonathan <ir...@gmail.com> wrote:

Hi Rushabh,

Had to change the update() method to use both params and data arguments, and the requests module under both mac and windows didn't seem to fill in the POST request body. Finally got it all to work under linux.

def request(server, params=None, data=None):
    global sid
    
    if not sid: login()
    
    response = requests.post(server, cookies = {"sid": sid}, params=params, data=data)


Thanks for the suggestions.

- j


On Monday, January 21, 2013 3:30:54 PM UTC+1, rushabh wrote:
Jonathan,

Your second approach is correct. You need to do a POST. You are not able send 2 items because of the URL limit in GET.

From the traceback, the parameters are not getting mapped correctly - can you debug the POST a bit?

I am sure you are pretty close to the solution.

best,
Rushabh



Hi.  I am still unable to get update to work and am asking two specific questions.

1. We have a BOM doctype which contains a number of individual BOM Item doctypes. Is it possible to read and update an individual BOM Item from a BOM doctype, or must one read the entire BOM and update the whole thing at once? So far I have only managed to read the entire BOM, but not an individual BOM Item.

2: Since I cannot so far read individual BOM Items, I am trying to update the entire BOM doctype. My update script works successfully if the BOM contains only a single BOM Item, but fails if there are two BOM Items. Why is that?

My script uses the same functions for get_doc(), login(), update(), etc. that you posted here: https://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py. In the original update function, the doclist is added to the params argument of requests.post(), which means the entire doclist is added to the request url. Specifically, I am doing the following:

doc = get_doc("BOM", bom)
rows = doc.json().get("message")
for row in rows
# change Qty if a certain condition is met
update(rows)

If there is one BOM Item in the BOM, the update is successful.  With two or more Bom Items, I get the following traceback:

Traceback (most recent call last):
  File "...\updateqty.py", line 187, in <module>
    main()
  File "...\updateqty.py", line 182, in main
    update(server, rows);
  File "...\updateqty.py", line 50, in update
    "doclist": json.dumps(doclist)
  File "...\updateqty.py", line 62, in request
    response = requests.post(server, cookies = {"sid": sid}, params=params)
  File "C:\Python27\lib\site-packages\requests\api.py", line 87, in post
    return request('post', url, data=data, **kwargs)
  File "C:\Python27\lib\site-packages\requests\api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 279, in request
    resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 374, in send
    r = adapter.send(request, **kwargs)
  File "C:\Python27\lib\site-packages\requests\adapters.py", line 222, in send
    r.content
  File "C:\Python27\lib\site-packages\requests\models.py", line 550, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
  File "C:\Python27\lib\site-packages\requests\models.py", line 496, in generate
    chunk = self.raw.read(chunk_size)
  File "C:\Python27\lib\site-packages\requests\packages\urllib3\response.py", line 148, in read
    return self._fp.read(amt)
  File "C:\Python27\lib\httplib.py", line 561, in read
    s = self.fp.read(amt)
  File "C:\Python27\lib\httplib.py", line 1298, in read
    return s + self._file.read(amt - len(s))
  File "C:\Python27\lib\socket.py", line 380, in read
    data = self._sock.recv(left)
socket.error: [Errno 10054] An existing connection was forcibly closed by the remote host

If instead I try to extend the update to use the "data" argument (which puts the data into the body of the post rather than the url), something like:

response = requests.post(server, cookies = {"sid": sid}, params=params, data=data)

where params= {
"cmd": "webnotes.client.save"
}
and data= {
"doclist": json.dumps(doclist) 
}

I get the following result from ERPNext:

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n  File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n    execute_cmd(cmd)\\n  File \\"../lib/webnotes/handler.py\\", line 191, in execute_cmd\\n    ret = call(method, webnotes.form_dict)\\n  File \\"../lib/webnotes/handler.py\\", line 210, in call\\n    return fn(**newargs)\\n TypeError: save() takes exactly 1 argument (0 given)\\n"'}

Can you suggest the right approach for updating either individual BOM Items or the entire BOM?

Thank you for your help.


 
Jonathan,

The way to do this would be to first get, update and push.

You can send the list of dicts (we call it a doclist) via a POST request. It should work - where are you getting stuck? Is there a specific error message?

- Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 17-Jan-2013, at 12:49 AM, Jonathan <ir...@gmail.com> wrote:

Thanks for the reply. What we are trying to do is update a complex doctype from a script--specifically we are trying to update a BOM--that is to say, update some subset of BOM Items for a given BOM. The first approach was to try get_doc on an individual BOM Item, passing in the parent BOM name and the item_code of the particular Bom Item as parameters. Various experiments along those lines got us the response that get takes 2 arguments and only 1 is given.

The next approach was to read the entire BOM using get_doc (this works fine), modify the fields in question, then call update. But this puts the entire pile of json into the url. Experiments trying to move the data into the body of the POST didn't get anywhere.

Can you suggest a way forward?

Thanks very much.

- j

On Saturday, January 12, 2013 4:28:50 AM UTC+1, rushabh wrote:
Jonathan, you have to "get" the customer after save, rename it and save gain. The system will only save if the incoming record's "modified" property matches with the one in the database to maintain version conflicts.

Sent from mobile

On 12-Jan-2013, at 12:00 AM, Jonathan <ir...@gmail.com> wrote:

Hi, sorry, me again.

We are trying to create--and optionally update--a Customer doctype based on the script that started this thread.  We are able to create a customer, but so far we have not been able to create a customer where the customer_name is different from the name.  In other words we have a unique name for the Customer ("johndoe123"), which is what we want the doctype to be referenced by, but we want the customer's name to be "John Doe". Once the Customer doctype is created we can change the customer name using the ERPNext API, but we were unable to create the customer that way or update it thereafter. In particular, the update function returns a message that says "Document has been modified after you have opened it."

Could you point us in the right direction?

Thanks.

On Monday, January 7, 2013 3:47:39 PM UTC+1, Jonathan wrote:
Thanks for the suggestion. The problem seems to be the weird parameter-doubling from the 'requests' module.  Now the login is working...

- j

On Monday, January 7, 2013 3:19:45 PM UTC+1, rushabh wrote:
The test runs fine on my setup. I think your installation may be messed up.

What do you get when you run that from the browser?

Sent from mobile

On 07-Jan-2013, at 7:32 PM, Jonathan <ir...@gmail.com> wrote:

Here's the redacted url returned from response.get().  Odd that all the params are doubled.

https://{server}/server.py?pwd={password}&cmd=login&usr={user}&pwd={password}&cmd=login&usr={user}

We are using the sample code llinked to earlier in the forum, only changing the server, user, and password parameters at the top (we also changed response.json.get() to response.json().get()--the code wouldn't work otherwise).

Thanks.

On Monday, January 7, 2013 2:43:00 PM UTC+1, rushabh wrote:
Can you post the entire url? I think you need to pass login id and password as the url parameters

For example you can login via:

server.py?cmd=login&usr=Administrator&pwd=admin

If you are passwords are correctly set.


On Mon, Jan 7, 2013 at 6:40 PM, Amin Zayani <za...@gmail.com> wrote:
Thanks for the quick reply.  We should have thought to test the simplest server.py url. We get back the following json in response to the login.

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n  File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n execute_cmd(cmd)\\n  Fil
e \\"../lib/webnotes/handler.py\\", line 176, in execute_cmd\\n method = get_method(cmd)\\n  File \\"../lib/webnotes/handler.py\\", line 218, in ge
t_method\\n    method = globals()[cmd]\\n KeyError: u\\"[\'login\', \'login\']\\"\\n"'}

Any suggestions?

Thanks again.

PS: my colleague Jonathan will join this thread

On Monday, January 7, 2013 1:10:56 PM UTC+1, rushabh wrote:
Amin,

Thanks for making the 3rd party API script available. We are newbies at ERPNext, so please excuse the following questions if the answers should be obvious.

In our tests using the sample code fromhttps://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py, we have not been able to get past login--we get a 404 response.  We are trying variations of "http://{our local erpnext server}/webnotes/erpnext_master/public/server.py" as the server address.  Our ERPNext is installed simply on a Ubuntu 12.10 virtual machine on a local server and is also accessible outside our LAN through a subdomain of our site, so we were trying, for example, "http://{our local erpnext server}/public/server.py". Can you give us any hints about what the url should be? (We also tried "client.py" instead of "server.py").

Don't use /public/server.py --- just use {local erpnext server}/server.py

Since all requests are passed via server.py (and this should be accessible via your browser). So set "server" to that url (which is server.py replaced by app.html)

We are also not entirely certain that we have updated ERPNext correctly in order to install the correct "client.py" file into the proper location. Can you tell us how to ascertain whether we have the correct file and it's in the expected place?  Once it's in the right place do we need to set any permissions? (because the repository updated is webnotes framework and we only update our ERPNext repository version)

the webclient.py file can be anywhere because it accesses the system via http requests.

Also webclient.py is a template and you can use that code to access data from anywhere.


Thanks.

On Monday, January 7, 2013 6:08:22 AM UTC+1, rushabh wrote:


On Mon, Jan 7, 2013 at 10:32 AM, Rushabh Mehta <rm...@gmail.com> wrote:
Just updated client.py with

webnotes.client.get

pass "doctype" and "name" as parameters

example:

cmd=webnotes.client.get&doctype=[doctype]&name=[name]

you will get a JSON object with a list of main record and the child records (if any)


On Fri, Jan 4, 2013 at 7:42 PM, Amin Zayani <za...@gmail.com> wrote:
Great!
Any chance you add a "read" method to fetch data from ERPNext? And include a simple example for fetching some doctype?

Thanks

On Wednesday, December 19, 2012 12:41:39 PM UTC+1, rushabh wrote:
Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.


Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh



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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/yzLMPR9UcxsJ.

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

 

 








Twitter: @rushabh_mehta



--



Twitter: @rushabh_mehta



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

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/QpP1CwrCuW8J.

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

 

 





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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9sfw-iCSHTkJ.


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



--



Twitter: @rushabh_mehta



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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/AtBNp4DGZjsJ.

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

 

 




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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/d1YRSsSA8U8J.

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

 

 




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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/sso_-D03AMEJ.

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

 

 





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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/BiY2q-sq-2gJ.

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

 

 





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

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/NDrHqRjqDQEJ.

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

 

 





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.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/hwlxXe3VleYJ.

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

 

 




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.

To post to this group, send email to er...@googlegroups.com.

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

 

 

Here you go:

https://github.com/webnotes/wnframework/commit/067411da16c6764ade1a7c5bdb6abd35f39f9409


W: https://erpnext.com
T: @rushabh_mehta

On 29-Jan-2013, at 9:36 PM, Jonathan <ir...@gmail.com> wrote:

Hi Rushabh,

I have updated all the scripts, but I am happy enough if it all works under Linux.

Would it be possible to have a generalization of get_doc along the following lines:

def get_doc(server, doctype, name, value):
    return request(server, { "cmd":"webnotes.client.get", "doctype":doctype, name:value})

because, for example for retrieving a sales order, I may know the purchase order number but not the sales order name.

Thanks.

- j





Jonathan,

Great.

Are you running the latest update of the requests module? I did not encounter this error on my Mac.


Anyways, I updated the webclient.py to use posts when required.

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 21-Jan-2013, at 11:16 PM, Jonathan <ir...@gmail.com> wrote:

Hi Rushabh,

Had to change the update() method to use both params and data arguments, and the requests module under both mac and windows didn't seem to fill in the POST request body. Finally got it all to work under linux.

def request(server, params=None, data=None):
    global sid
    
    if not sid: login()
    
    response = requests.post(server, cookies = {"sid": sid}, params=params, data=data)


Thanks for the suggestions.

- j


On Monday, January 21, 2013 3:30:54 PM UTC+1, rushabh wrote:
Jonathan,

Your second approach is correct. You need to do a POST. You are not able send 2 items because of the URL limit in GET.

From the traceback, the parameters are not getting mapped correctly - can you debug the POST a bit?

I am sure you are pretty close to the solution.

best,
Rushabh



Hi.  I am still unable to get update to work and am asking two specific questions.

1. We have a BOM doctype which contains a number of individual BOM Item doctypes. Is it possible to read and update an individual BOM Item from a BOM doctype, or must one read the entire BOM and update the whole thing at once? So far I have only managed to read the entire BOM, but not an individual BOM Item.

2: Since I cannot so far read individual BOM Items, I am trying to update the entire BOM doctype. My update script works successfully if the BOM contains only a single BOM Item, but fails if there are two BOM Items. Why is that?

My script uses the same functions for get_doc(), login(), update(), etc. that you posted here: https://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py. In the original update function, the doclist is added to the params argument of requests.post(), which means the entire doclist is added to the request url. Specifically, I am doing the following:

doc = get_doc("BOM", bom)
rows = doc.json().get("message")
for row in rows
# change Qty if a certain condition is met
update(rows)

If there is one BOM Item in the BOM, the update is successful.  With two or more Bom Items, I get the following traceback:

Traceback (most recent call last):
  File "...\updateqty.py", line 187, in <module>
    main()
  File "...\updateqty.py", line 182, in main
    update(server, rows);
  File "...\updateqty.py", line 50, in update
    "doclist": json.dumps(doclist)
  File "...\updateqty.py", line 62, in request
    response = requests.post(server, cookies = {"sid": sid}, params=params)
  File "C:\Python27\lib\site-packages\requests\api.py", line 87, in post
    return request('post', url, data=data, **kwargs)
  File "C:\Python27\lib\site-packages\requests\api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 279, in request
    resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 374, in send
    r = adapter.send(request, **kwargs)
  File "C:\Python27\lib\site-packages\requests\adapters.py", line 222, in send
    r.content
  File "C:\Python27\lib\site-packages\requests\models.py", line 550, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
  File "C:\Python27\lib\site-packages\requests\models.py", line 496, in generate
    chunk = self.raw.read(chunk_size)
  File "C:\Python27\lib\site-packages\requests\packages\urllib3\response.py", line 148, in read
    return self._fp.read(amt)
  File "C:\Python27\lib\httplib.py", line 561, in read
    s = self.fp.read(amt)
  File "C:\Python27\lib\httplib.py", line 1298, in read
    return s + self._file.read(amt - len(s))
  File "C:\Python27\lib\socket.py", line 380, in read
    data = self._sock.recv(left)
socket.error: [Errno 10054] An existing connection was forcibly closed by the remote host

If instead I try to extend the update to use the "data" argument (which puts the data into the body of the post rather than the url), something like:

response = requests.post(server, cookies = {"sid": sid}, params=params, data=data)

where params= {
"cmd": "webnotes.client.save"
}
and data= {
"doclist": json.dumps(doclist) 
}

I get the following result from ERPNext:

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n  File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n    execute_cmd(cmd)\\n  File \\"../lib/webnotes/handler.py\\", line 191, in execute_cmd\\n    ret = call(method, webnotes.form_dict)\\n  File \\"../lib/webnotes/handler.py\\", line 210, in call\\n    return fn(**newargs)\\n TypeError: save() takes exactly 1 argument (0 given)\\n"'}

Can you suggest the right approach for updating either individual BOM Items or the entire BOM?

Thank you for your help.


 
Jonathan,

The way to do this would be to first get, update and push.

You can send the list of dicts (we call it a doclist) via a POST request. It should work - where are you getting stuck? Is there a specific error message?

- Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 17-Jan-2013, at 12:49 AM, Jonathan <ir...@gmail.com> wrote:

Thanks for the reply. What we are trying to do is update a complex doctype from a script--specifically we are trying to update a BOM--that is to say, update some subset of BOM Items for a given BOM. The first approach was to try get_doc on an individual BOM Item, passing in the parent BOM name and the item_code of the particular Bom Item as parameters. Various experiments along those lines got us the response that get takes 2 arguments and only 1 is given.

The next approach was to read the entire BOM using get_doc (this works fine), modify the fields in question, then call update. But this puts the entire pile of json into the url. Experiments trying to move the data into the body of the POST didn't get anywhere.

Can you suggest a way forward?

Thanks very much.

- j

On Saturday, January 12, 2013 4:28:50 AM UTC+1, rushabh wrote:
Jonathan, you have to "get" the customer after save, rename it and save gain. The system will only save if the incoming record's "modified" property matches with the one in the database to maintain version conflicts.

Sent from mobile

On 12-Jan-2013, at 12:00 AM, Jonathan <ir...@gmail.com> wrote:

Hi, sorry, me again.

We are trying to create--and optionally update--a Customer doctype based on the script that started this thread.  We are able to create a customer, but so far we have not been able to create a customer where the customer_name is different from the name.  In other words we have a unique name for the Customer ("johndoe123"), which is what we want the doctype to be referenced by, but we want the customer's name to be "John Doe". Once the Customer doctype is created we can change the customer name using the ERPNext API, but we were unable to create the customer that way or update it thereafter. In particular, the update function returns a message that says "Document has been modified after you have opened it."

Could you point us in the right direction?

Thanks.

On Monday, January 7, 2013 3:47:39 PM UTC+1, Jonathan wrote:
Thanks for the suggestion. The problem seems to be the weird parameter-doubling from the 'requests' module.  Now the login is working...

- j

On Monday, January 7, 2013 3:19:45 PM UTC+1, rushabh wrote:
The test runs fine on my setup. I think your installation may be messed up.

What do you get when you run that from the browser?

Sent from mobile

On 07-Jan-2013, at 7:32 PM, Jonathan <ir...@gmail.com> wrote:

Here's the redacted url returned from response.get().  Odd that all the params are doubled.

https://{server}/server.py?pwd={password}&cmd=login&usr={user}&pwd={password}&cmd=login&usr={user}

We are using the sample code llinked to earlier in the forum, only changing the server, user, and password parameters at the top (we also changed response.json.get() to response.json().get()--the code wouldn't work otherwise).

Thanks.

On Monday, January 7, 2013 2:43:00 PM UTC+1, rushabh wrote:
Can you post the entire url? I think you need to pass login id and password as the url parameters

For example you can login via:

server.py?cmd=login&usr=Administrator&pwd=admin

If you are passwords are correctly set.


On Mon, Jan 7, 2013 at 6:40 PM, Amin Zayani <za...@gmail.com> wrote:
Thanks for the quick reply.  We should have thought to test the simplest server.py url. We get back the following json in response to the login.

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n  File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n execute_cmd(cmd)\\n  Fil
e \\"../lib/webnotes/handler.py\\", line 176, in execute_cmd\\n method = get_method(cmd)\\n  File \\"../lib/webnotes/handler.py\\", line 218, in ge
t_method\\n    method = globals()[cmd]\\n KeyError: u\\"[\'login\', \'login\']\\"\\n"'}

Any suggestions?

Thanks again.

PS: my colleague Jonathan will join this thread

On Monday, January 7, 2013 1:10:56 PM UTC+1, rushabh wrote:
Amin,

Thanks for making the 3rd party API script available. We are newbies at ERPNext, so please excuse the following questions if the answers should be obvious.

In our tests using the sample code fromhttps://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py, we have not been able to get past login--we get a 404 response.  We are trying variations of "http://{our local erpnext server}/webnotes/erpnext_master/public/server.py" as the server address.  Our ERPNext is installed simply on a Ubuntu 12.10 virtual machine on a local server and is also accessible outside our LAN through a subdomain of our site, so we were trying, for example, "http://{our local erpnext server}/public/server.py". Can you give us any hints about what the url should be? (We also tried "client.py" instead of "server.py").

Don't use /public/server.py --- just use {local erpnext server}/server.py

Since all requests are passed via server.py (and this should be accessible via your browser). So set "server" to that url (which is server.py replaced by app.html)

We are also not entirely certain that we have updated ERPNext correctly in order to install the correct "client.py" file into the proper location. Can you tell us how to ascertain whether we have the correct file and it's in the expected place?  Once it's in the right place do we need to set any permissions? (because the repository updated is webnotes framework and we only update our ERPNext repository version)

the webclient.py file can be anywhere because it accesses the system via http requests.

Also webclient.py is a template and you can use that code to access data from anywhere.


Thanks.

On Monday, January 7, 2013 6:08:22 AM UTC+1, rushabh wrote:


On Mon, Jan 7, 2013 at 10:32 AM, Rushabh Mehta <rm...@gmail.com> wrote:
Just updated client.py with

webnotes.client.get

pass "doctype" and "name" as parameters

example:

cmd=webnotes.client.get&doctype=[doctype]&name=[name]

you will get a JSON object with a list of main record and the child records (if any)


On Fri, Jan 4, 2013 at 7:42 PM, Amin Zayani <za...@gmail.com> wrote:
Great!
Any chance you add a "read" method to fetch data from ERPNext? And include a simple example for fetching some doctype?

Thanks

On Wednesday, December 19, 2012 12:41:39 PM UTC+1, rushabh wrote:
Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.


Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh



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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/yzLMPR9UcxsJ.

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

 

 








Twitter: @rushabh_mehta



--



Twitter: @rushabh_mehta



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

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/QpP1CwrCuW8J.

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

 

 





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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9sfw-iCSHTkJ.


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



--



Twitter: @rushabh_mehta



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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/AtBNp4DGZjsJ.

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

 

 




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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/d1YRSsSA8U8J.

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

 

 




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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/sso_-D03AMEJ.

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

 

 





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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/BiY2q-sq-2gJ.

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

 

 





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

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/NDrHqRjqDQEJ.

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

 

 





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.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/hwlxXe3VleYJ.

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

 

 




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.

To post to this group, send email to er...@googlegroups.com.

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

 

 

Hi Rushabh,


Thanks, that great–I am already using the new code.

- j

On Wednesday, January 30, 2013 6:37:22 AM UTC+1, rushabh wrote:
Here you go:

https://github.com/webnotes/wnframework/commit/067411da16c6764ade1a7c5bdb6abd35f39f9409



W: https://erpnext.com
T: @rushabh_mehta

On 29-Jan-2013, at 9:36 PM, Jonathan <ir...@gmail.com> wrote:

Hi Rushabh,

I have updated all the scripts, but I am happy enough if it all works under Linux.

Would it be possible to have a generalization of get_doc along the following lines:

def get_doc(server, doctype, name, value):
    return request(server, { "cmd":"webnotes.client.get", "doctype":doctype, name:value})

because, for example for retrieving a sales order, I may know the purchase order number but not the sales order name.

Thanks.

- j





Jonathan,

Great.

Are you running the latest update of the requests module? I did not encounter this error on my Mac.


Anyways, I updated the webclient.py to use posts when required.

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 21-Jan-2013, at 11:16 PM, Jonathan <ir...@gmail.com> wrote:

Hi Rushabh,

Had to change the update() method to use both params and data arguments, and the requests module under both mac and windows didn't seem to fill in the POST request body. Finally got it all to work under linux.

def request(server, params=None, data=None):
    global sid
    
    if not sid: login()
    
    response = requests.post(server, cookies = {"sid": sid}, params=params, data=data)


Thanks for the suggestions.

- j


On Monday, January 21, 2013 3:30:54 PM UTC+1, rushabh wrote:
Jonathan,

Your second approach is correct. You need to do a POST. You are not able send 2 items because of the URL limit in GET.

From the traceback, the parameters are not getting mapped correctly - can you debug the POST a bit?

I am sure you are pretty close to the solution.

best,
Rushabh



Hi.  I am still unable to get update to work and am asking two specific questions.

1. We have a BOM doctype which contains a number of individual BOM Item doctypes. Is it possible to read and update an individual BOM Item from a BOM doctype, or must one read the entire BOM and update the whole thing at once? So far I have only managed to read the entire BOM, but not an individual BOM Item.

2: Since I cannot so far read individual BOM Items, I am trying to update the entire BOM doctype. My update script works successfully if the BOM contains only a single BOM Item, but fails if there are two BOM Items. Why is that?

My script uses the same functions for get_doc(), login(), update(), etc. that you posted here: https://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py. In the original update function, the doclist is added to the params argument of requests.post(), which means the entire doclist is added to the request url. Specifically, I am doing the following:

doc = get_doc("BOM", bom)
rows = doc.json().get("message")
for row in rows
# change Qty if a certain condition is met
update(rows)

If there is one BOM Item in the BOM, the update is successful.  With two or more Bom Items, I get the following traceback:

Traceback (most recent call last):
  File "...\updateqty.py", line 187, in <module>
    main()
  File "...\updateqty.py", line 182, in main
    update(server, rows);
  File "...\updateqty.py", line 50, in update
    "doclist": json.dumps(doclist)
  File "...\updateqty.py", line 62, in request
    response = requests.post(server, cookies = {"sid": sid}, params=params)
  File "C:\Python27\lib\site-packages\requests\api.py", line 87, in post
    return request('post', url, data=data, **kwargs)
  File "C:\Python27\lib\site-packages\requests\api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 279, in request
    resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 374, in send
    r = adapter.send(request, **kwargs)
  File "C:\Python27\lib\site-packages\requests\adapters.py", line 222, in send
    r.content
  File "C:\Python27\lib\site-packages\requests\models.py", line 550, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
  File "C:\Python27\lib\site-packages\requests\models.py", line 496, in generate
    chunk = self.raw.read(chunk_size)
  File "C:\Python27\lib\site-packages\requests\packages\urllib3\response.py", line 148, in read
    return self._fp.read(amt)
  File "C:\Python27\lib\httplib.py", line 561, in read
    s = self.fp.read(amt)
  File "C:\Python27\lib\httplib.py", line 1298, in read
    return s + self._file.read(amt - len(s))
  File "C:\Python27\lib\socket.py", line 380, in read
    data = self._sock.recv(left)
socket.error: [Errno 10054] An existing connection was forcibly closed by the remote host

If instead I try to extend the update to use the "data" argument (which puts the data into the body of the post rather than the url), something like:

response = requests.post(server, cookies = {"sid": sid}, params=params, data=data)

where params= {
"cmd": "webnotes.client.save"
}
and data= {
"doclist": json.dumps(doclist) 
}

I get the following result from ERPNext:

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n  File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n    execute_cmd(cmd)\\n  File \\"../lib/webnotes/handler.py\\", line 191, in execute_cmd\\n    ret = call(method, webnotes.form_dict)\\n  File \\"../lib/webnotes/handler.py\\", line 210, in call\\n    return fn(**newargs)\\n TypeError: save() takes exactly 1 argument (0 given)\\n"'}

Can you suggest the right approach for updating either individual BOM Items or the entire BOM?

Thank you for your help.


 
Jonathan,

The way to do this would be to first get, update and push.

You can send the list of dicts (we call it a doclist) via a POST request. It should work - where are you getting stuck? Is there a specific error message?

- Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 17-Jan-2013, at 12:49 AM, Jonathan <ir...@gmail.com> wrote:

Thanks for the reply. What we are trying to do is update a complex doctype from a script--specifically we are trying to update a BOM--that is to say, update some subset of BOM Items for a given BOM. The first approach was to try get_doc on an individual BOM Item, passing in the parent BOM name and the item_code of the particular Bom Item as parameters. Various experiments along those lines got us the response that get takes 2 arguments and only 1 is given.

The next approach was to read the entire BOM using get_doc (this works fine), modify the fields in question, then call update. But this puts the entire pile of json into the url. Experiments trying to move the data into the body of the POST didn't get anywhere.

Can you suggest a way forward?

Thanks very much.

- j

On Saturday, January 12, 2013 4:28:50 AM UTC+1, rushabh wrote:
Jonathan, you have to "get" the customer after save, rename it and save gain. The system will only save if the incoming record's "modified" property matches with the one in the database to maintain version conflicts.

Sent from mobile

On 12-Jan-2013, at 12:00 AM, Jonathan <ir...@gmail.com> wrote:

Hi, sorry, me again.

We are trying to create--and optionally update--a Customer doctype based on the script that started this thread.  We are able to create a customer, but so far we have not been able to create a customer where the customer_name is different from the name.  In other words we have a unique name for the Customer ("johndoe123"), which is what we want the doctype to be referenced by, but we want the customer's name to be "John Doe". Once the Customer doctype is created we can change the customer name using the ERPNext API, but we were unable to create the customer that way or update it thereafter. In particular, the update function returns a message that says "Document has been modified after you have opened it."

Could you point us in the right direction?

Thanks.

On Monday, January 7, 2013 3:47:39 PM UTC+1, Jonathan wrote:
Thanks for the suggestion. The problem seems to be the weird parameter-doubling from the 'requests' module.  Now the login is working...

- j

On Monday, January 7, 2013 3:19:45 PM UTC+1, rushabh wrote:
The test runs fine on my setup. I think your installation may be messed up.

What do you get when you run that from the browser?

Sent from mobile

On 07-Jan-2013, at 7:32 PM, Jonathan <ir...@gmail.com> wrote:

Here's the redacted url returned from response.get().  Odd that all the params are doubled.

https://{server}/server.py?pwd={password}&cmd=login&usr={user}&pwd={password}&cmd=login&usr={user}

We are using the sample code llinked to earlier in the forum, only changing the server, user, and password parameters at the top (we also changed response.json.get() to response.json().get()--the code wouldn't work otherwise).

Thanks.

On Monday, January 7, 2013 2:43:00 PM UTC+1, rushabh wrote:
Can you post the entire url? I think you need to pass login id and password as the url parameters

For example you can login via:

server.py?cmd=login&usr=Administrator&pwd=admin

If you are passwords are correctly set.


On Mon, Jan 7, 2013 at 6:40 PM, Amin Zayani <za...@gmail.com> wrote:
Thanks for the quick reply.  We should have thought to test the simplest server.py url. We get back the following json in response to the login.

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n  File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n execute_cmd(cmd)\\n  Fil
e \\"../lib/webnotes/handler.py\\", line 176, in execute_cmd\\n method = get_method(cmd)\\n  File \\"../lib/webnotes/handler.py\\", line 218, in ge
t_method\\n    method = globals()[cmd]\\n KeyError: u\\"[\'login\', \'login\']\\"\\n"'}

Any suggestions?

Thanks again.

PS: my colleague Jonathan will join this thread

On Monday, January 7, 2013 1:10:56 PM UTC+1, rushabh wrote:
Amin,

Thanks for making the 3rd party API script available. We are newbies at ERPNext, so please excuse the following questions if the answers should be obvious.

In our tests using the sample code fromhttps://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py, we have not been able to get past login--we get a 404 response.  We are trying variations of "http://{our local erpnext server}/webnotes/erpnext_master/public/server.py" as the server address.  Our ERPNext is installed simply on a Ubuntu 12.10 virtual machine on a local server and is also accessible outside our LAN through a subdomain of our site, so we were trying, for example, "http://{our local erpnext server}/public/server.py". Can you give us any hints about what the url should be? (We also tried "client.py" instead of "server.py").

Don't use /public/server.py --- just use {local erpnext server}/server.py

Since all requests are passed via server.py (and this should be accessible via your browser). So set "server" to that url (which is server.py replaced by app.html)

We are also not entirely certain that we have updated ERPNext correctly in order to install the correct "client.py" file into the proper location. Can you tell us how to ascertain whether we have the correct file and it's in the expected place?  Once it's in the right place do we need to set any permissions? (because the repository updated is webnotes framework and we only update our ERPNext repository version)

the webclient.py file can be anywhere because it accesses the system via http requests.

Also webclient.py is a template and you can use that code to access data from anywhere.


Thanks.

On Monday, January 7, 2013 6:08:22 AM UTC+1, rushabh wrote:


On Mon, Jan 7, 2013 at 10:32 AM, Rushabh Mehta <rm...@gmail.com> wrote:
Just updated client.py with

webnotes.client.get

pass "doctype" and "name" as parameters

example:

cmd=webnotes.client.get&doctype=[doctype]&name=[name]

you will get a JSON object with a list of main record and the child records (if any)


On Fri, Jan 4, 2013 at 7:42 PM, Amin Zayani <za...@gmail.com> wrote:
Great!
Any chance you add a "read" method to fetch data from ERPNext? And include a simple example for fetching some doctype?

Thanks

On Wednesday, December 19, 2012 12:41:39 PM UTC+1, rushabh wrote:
Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.


Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh



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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/yzLMPR9UcxsJ.

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

 

 








Twitter: @rushabh_mehta



--



Twitter: @rushabh_mehta



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

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/QpP1CwrCuW8J.

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

 

 





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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9sfw-iCSHTkJ.


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



--



Twitter: @rushabh_mehta



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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/AtBNp4DGZjsJ.

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

 

 




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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/d1YRSsSA8U8J.

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

 

 




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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/sso_-D03AMEJ.

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

 

 





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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/BiY2q-sq-2gJ.

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

 

 





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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/NDrHqRjqDQEJ.

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

 

 





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.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/hwlxXe3VleYJ.

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

 

 




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.

To post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/UgiKjX0EqrQJ.

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

 

 

Hi Rushabh,


Is there already a script equivalent to “submit”, or if not would you consider adding it?

Thanks very much.

- j


Hi Rushabh,

Thanks, that great–I am already using the new code.

- j

On Wednesday, January 30, 2013 6:37:22 AM UTC+1, rushabh wrote:
Here you go:

https://github.com/webnotes/wnframework/commit/067411da16c6764ade1a7c5bdb6abd35f39f9409



W: https://erpnext.com
T: @rushabh_mehta

On 29-Jan-2013, at 9:36 PM, Jonathan <ir...@gmail.com> wrote:

Hi Rushabh,

I have updated all the scripts, but I am happy enough if it all works under Linux.

Would it be possible to have a generalization of get_doc along the following lines:

def get_doc(server, doctype, name, value):
    return request(server, { "cmd":"webnotes.client.get", "doctype":doctype, name:value})

because, for example for retrieving a sales order, I may know the purchase order number but not the sales order name.

Thanks.

- j





Jonathan,

Great.

Are you running the latest update of the requests module? I did not encounter this error on my Mac.


Anyways, I updated the webclient.py to use posts when required.

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 21-Jan-2013, at 11:16 PM, Jonathan <ir...@gmail.com> wrote:

Hi Rushabh,

Had to change the update() method to use both params and data arguments, and the requests module under both mac and windows didn't seem to fill in the POST request body. Finally got it all to work under linux.

def request(server, params=None, data=None):
    global sid
    
    if not sid: login()
    
    response = requests.post(server, cookies = {"sid": sid}, params=params, data=data)


Thanks for the suggestions.

- j


On Monday, January 21, 2013 3:30:54 PM UTC+1, rushabh wrote:
Jonathan,

Your second approach is correct. You need to do a POST. You are not able send 2 items because of the URL limit in GET.

From the traceback, the parameters are not getting mapped correctly - can you debug the POST a bit?

I am sure you are pretty close to the solution.

best,
Rushabh



Hi.  I am still unable to get update to work and am asking two specific questions.

1. We have a BOM doctype which contains a number of individual BOM Item doctypes. Is it possible to read and update an individual BOM Item from a BOM doctype, or must one read the entire BOM and update the whole thing at once? So far I have only managed to read the entire BOM, but not an individual BOM Item.

2: Since I cannot so far read individual BOM Items, I am trying to update the entire BOM doctype. My update script works successfully if the BOM contains only a single BOM Item, but fails if there are two BOM Items. Why is that?

My script uses the same functions for get_doc(), login(), update(), etc. that you posted here: https://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py. In the original update function, the doclist is added to the params argument of requests.post(), which means the entire doclist is added to the request url. Specifically, I am doing the following:

doc = get_doc("BOM", bom)
rows = doc.json().get("message")
for row in rows
# change Qty if a certain condition is met
update(rows)

If there is one BOM Item in the BOM, the update is successful.  With two or more Bom Items, I get the following traceback:

Traceback (most recent call last):
  File "...\updateqty.py", line 187, in <module>
    main()
  File "...\updateqty.py", line 182, in main
    update(server, rows);
  File "...\updateqty.py", line 50, in update
    "doclist": json.dumps(doclist)
  File "...\updateqty.py", line 62, in request
    response = requests.post(server, cookies = {"sid": sid}, params=params)
  File "C:\Python27\lib\site-packages\requests\api.py", line 87, in post
    return request('post', url, data=data, **kwargs)
  File "C:\Python27\lib\site-packages\requests\api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 279, in request
    resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 374, in send
    r = adapter.send(request, **kwargs)
  File "C:\Python27\lib\site-packages\requests\adapters.py", line 222, in send
    r.content
  File "C:\Python27\lib\site-packages\requests\models.py", line 550, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
  File "C:\Python27\lib\site-packages\requests\models.py", line 496, in generate
    chunk = self.raw.read(chunk_size)
  File "C:\Python27\lib\site-packages\requests\packages\urllib3\response.py", line 148, in read
    return self._fp.read(amt)
  File "C:\Python27\lib\httplib.py", line 561, in read
    s = self.fp.read(amt)
  File "C:\Python27\lib\httplib.py", line 1298, in read
    return s + self._file.read(amt - len(s))
  File "C:\Python27\lib\socket.py", line 380, in read
    data = self._sock.recv(left)
socket.error: [Errno 10054] An existing connection was forcibly closed by the remote host

If instead I try to extend the update to use the "data" argument (which puts the data into the body of the post rather than the url), something like:

response = requests.post(server, cookies = {"sid": sid}, params=params, data=data)

where params= {
"cmd": "webnotes.client.save"
}
and data= {
"doclist": json.dumps(doclist) 
}

I get the following result from ERPNext:

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n  File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n    execute_cmd(cmd)\\n  File \\"../lib/webnotes/handler.py\\", line 191, in execute_cmd\\n    ret = call(method, webnotes.form_dict)\\n  File \\"../lib/webnotes/handler.py\\", line 210, in call\\n    return fn(**newargs)\\n TypeError: save() takes exactly 1 argument (0 given)\\n"'}

Can you suggest the right approach for updating either individual BOM Items or the entire BOM?

Thank you for your help.


 
Jonathan,

The way to do this would be to first get, update and push.

You can send the list of dicts (we call it a doclist) via a POST request. It should work - where are you getting stuck? Is there a specific error message?

- Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 17-Jan-2013, at 12:49 AM, Jonathan <ir...@gmail.com> wrote:

Thanks for the reply. What we are trying to do is update a complex doctype from a script--specifically we are trying to update a BOM--that is to say, update some subset of BOM Items for a given BOM. The first approach was to try get_doc on an individual BOM Item, passing in the parent BOM name and the item_code of the particular Bom Item as parameters. Various experiments along those lines got us the response that get takes 2 arguments and only 1 is given.

The next approach was to read the entire BOM using get_doc (this works fine), modify the fields in question, then call update. But this puts the entire pile of json into the url. Experiments trying to move the data into the body of the POST didn't get anywhere.

Can you suggest a way forward?

Thanks very much.

- j

On Saturday, January 12, 2013 4:28:50 AM UTC+1, rushabh wrote:
Jonathan, you have to "get" the customer after save, rename it and save gain. The system will only save if the incoming record's "modified" property matches with the one in the database to maintain version conflicts.

Sent from mobile

On 12-Jan-2013, at 12:00 AM, Jonathan <ir...@gmail.com> wrote:

Hi, sorry, me again.

We are trying to create--and optionally update--a Customer doctype based on the script that started this thread.  We are able to create a customer, but so far we have not been able to create a customer where the customer_name is different from the name.  In other words we have a unique name for the Customer ("johndoe123"), which is what we want the doctype to be referenced by, but we want the customer's name to be "John Doe". Once the Customer doctype is created we can change the customer name using the ERPNext API, but we were unable to create the customer that way or update it thereafter. In particular, the update function returns a message that says "Document has been modified after you have opened it."

Could you point us in the right direction?

Thanks.

On Monday, January 7, 2013 3:47:39 PM UTC+1, Jonathan wrote:
Thanks for the suggestion. The problem seems to be the weird parameter-doubling from the 'requests' module.  Now the login is working...

- j

On Monday, January 7, 2013 3:19:45 PM UTC+1, rushabh wrote:
The test runs fine on my setup. I think your installation may be messed up.

What do you get when you run that from the browser?

Sent from mobile

On 07-Jan-2013, at 7:32 PM, Jonathan <ir...@gmail.com> wrote:

Here's the redacted url returned from response.get().  Odd that all the params are doubled.

https://{server}/server.py?pwd={password}&cmd=login&usr={user}&pwd={password}&cmd=login&usr={user}

We are using the sample code llinked to earlier in the forum, only changing the server, user, and password parameters at the top (we also changed response.json.get() to response.json().get()--the code wouldn't work otherwise).

Thanks.

On Monday, January 7, 2013 2:43:00 PM UTC+1, rushabh wrote:
Can you post the entire url? I think you need to pass login id and password as the url parameters

For example you can login via:

server.py?cmd=login&usr=Administrator&pwd=admin

If you are passwords are correctly set.


On Mon, Jan 7, 2013 at 6:40 PM, Amin Zayani <za...@gmail.com> wrote:
Thanks for the quick reply.  We should have thought to test the simplest server.py url. We get back the following json in response to the login.

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n  File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n execute_cmd(cmd)\\n  Fil
e \\"../lib/webnotes/handler.py\\", line 176, in execute_cmd\\n method = get_method(cmd)\\n  File \\"../lib/webnotes/handler.py\\", line 218, in ge
t_method\\n    method = globals()[cmd]\\n KeyError: u\\"[\'login\', \'login\']\\"\\n"'}

Any suggestions?

Thanks again.

PS: my colleague Jonathan will join this thread

On Monday, January 7, 2013 1:10:56 PM UTC+1, rushabh wrote:
Amin,

Thanks for making the 3rd party API script available. We are newbies at ERPNext, so please excuse the following questions if the answers should be obvious.

In our tests using the sample code fromhttps://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py, we have not been able to get past login--we get a 404 response.  We are trying variations of "http://{our local erpnext server}/webnotes/erpnext_master/public/server.py" as the server address.  Our ERPNext is installed simply on a Ubuntu 12.10 virtual machine on a local server and is also accessible outside our LAN through a subdomain of our site, so we were trying, for example, "http://{our local erpnext server}/public/server.py". Can you give us any hints about what the url should be? (We also tried "client.py" instead of "server.py").

Don't use /public/server.py --- just use {local erpnext server}/server.py

Since all requests are passed via server.py (and this should be accessible via your browser). So set "server" to that url (which is server.py replaced by app.html)

We are also not entirely certain that we have updated ERPNext correctly in order to install the correct "client.py" file into the proper location. Can you tell us how to ascertain whether we have the correct file and it's in the expected place?  Once it's in the right place do we need to set any permissions? (because the repository updated is webnotes framework and we only update our ERPNext repository version)

the webclient.py file can be anywhere because it accesses the system via http requests.

Also webclient.py is a template and you can use that code to access data from anywhere.


Thanks.

On Monday, January 7, 2013 6:08:22 AM UTC+1, rushabh wrote:


On Mon, Jan 7, 2013 at 10:32 AM, Rushabh Mehta <rm...@gmail.com> wrote:
Just updated client.py with

webnotes.client.get

pass "doctype" and "name" as parameters

example:

cmd=webnotes.client.get&doctype=[doctype]&name=[name]

you will get a JSON object with a list of main record and the child records (if any)


On Fri, Jan 4, 2013 at 7:42 PM, Amin Zayani <za...@gmail.com> wrote:
Great!
Any chance you add a "read" method to fetch data from ERPNext? And include a simple example for fetching some doctype?

Thanks

On Wednesday, December 19, 2012 12:41:39 PM UTC+1, rushabh wrote:
Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.


Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh



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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/yzLMPR9UcxsJ.

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

 

 








Twitter: @rushabh_mehta



--



Twitter: @rushabh_mehta



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

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/QpP1CwrCuW8J.

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

 

 





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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9sfw-iCSHTkJ.


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



--



Twitter: @rushabh_mehta



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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/AtBNp4DGZjsJ.

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

 

 




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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/d1YRSsSA8U8J.

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

 

 




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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/sso_-D03AMEJ.

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

 

 





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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/BiY2q-sq-2gJ.

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

 

 





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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/NDrHqRjqDQEJ.

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

 

 





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.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/hwlxXe3VleYJ.

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

 

 




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.

To post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/2mC-a8e_t0cJ.

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

 

 

Added submit and cancel methods. Check webclient.py



On 05-Feb-2013, at 10:47 PM, Jonathan <ir...@gmail.com> wrote:

Hi Rushabh,

Is there already a script equivalent to "submit", or if not would you consider adding it?

Thanks very much.

- j


Hi Rushabh,

Thanks, that great--I am already using the new code.

- j

On Wednesday, January 30, 2013 6:37:22 AM UTC+1, rushabh wrote:
Here you go:

https://github.com/webnotes/wnframework/commit/067411da16c6764ade1a7c5bdb6abd35f39f9409


W: https://erpnext.com
T: @rushabh_mehta

On 29-Jan-2013, at 9:36 PM, Jonathan <ir...@gmail.com> wrote:

Hi Rushabh,

I have updated all the scripts, but I am happy enough if it all works under Linux.

Would it be possible to have a generalization of get_doc along the following lines:

def get_doc(server, doctype, name, value):
    return request(server, { "cmd":"webnotes.client.get", "doctype":doctype, name:value})

because, for example for retrieving a sales order, I may know the purchase order number but not the sales order name.

Thanks.

- j





Jonathan,

Great.

Are you running the latest update of the requests module? I did not encounter this error on my Mac.


Anyways, I updated the webclient.py to use posts when required.

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 21-Jan-2013, at 11:16 PM, Jonathan <ir...@gmail.com> wrote:

Hi Rushabh,

Had to change the update() method to use both params and data arguments, and the requests module under both mac and windows didn't seem to fill in the POST request body. Finally got it all to work under linux.

def request(server, params=None, data=None):
    global sid
    
    if not sid: login()
    
    response = requests.post(server, cookies = {"sid": sid}, params=params, data=data)


Thanks for the suggestions.

- j


On Monday, January 21, 2013 3:30:54 PM UTC+1, rushabh wrote:
Jonathan,

Your second approach is correct. You need to do a POST. You are not able send 2 items because of the URL limit in GET.

From the traceback, the parameters are not getting mapped correctly - can you debug the POST a bit?

I am sure you are pretty close to the solution.

best,
Rushabh



Hi.  I am still unable to get update to work and am asking two specific questions.

1. We have a BOM doctype which contains a number of individual BOM Item doctypes. Is it possible to read and update an individual BOM Item from a BOM doctype, or must one read the entire BOM and update the whole thing at once? So far I have only managed to read the entire BOM, but not an individual BOM Item.

2: Since I cannot so far read individual BOM Items, I am trying to update the entire BOM doctype. My update script works successfully if the BOM contains only a single BOM Item, but fails if there are two BOM Items. Why is that?

My script uses the same functions for get_doc(), login(), update(), etc. that you posted here: https://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py. In the original update function, the doclist is added to the params argument of requests.post(), which means the entire doclist is added to the request url. Specifically, I am doing the following:

doc = get_doc("BOM", bom)
rows = doc.json().get("message")
for row in rows
# change Qty if a certain condition is met
update(rows)

If there is one BOM Item in the BOM, the update is successful.  With two or more Bom Items, I get the following traceback:

Traceback (most recent call last):
  File "...\updateqty.py", line 187, in <module>
    main()
  File "...\updateqty.py", line 182, in main
    update(server, rows);
  File "...\updateqty.py", line 50, in update
    "doclist": json.dumps(doclist)
  File "...\updateqty.py", line 62, in request
    response = requests.post(server, cookies = {"sid": sid}, params=params)
  File "C:\Python27\lib\site-packages\requests\api.py", line 87, in post
    return request('post', url, data=data, **kwargs)
  File "C:\Python27\lib\site-packages\requests\api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 279, in request
    resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 374, in send
    r = adapter.send(request, **kwargs)
  File "C:\Python27\lib\site-packages\requests\adapters.py", line 222, in send
    r.content
  File "C:\Python27\lib\site-packages\requests\models.py", line 550, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
  File "C:\Python27\lib\site-packages\requests\models.py", line 496, in generate
    chunk = self.raw.read(chunk_size)
  File "C:\Python27\lib\site-packages\requests\packages\urllib3\response.py", line 148, in read
    return self._fp.read(amt)
  File "C:\Python27\lib\httplib.py", line 561, in read
    s = self.fp.read(amt)
  File "C:\Python27\lib\httplib.py", line 1298, in read
    return s + self._file.read(amt - len(s))
  File "C:\Python27\lib\socket.py", line 380, in read
    data = self._sock.recv(left)
socket.error: [Errno 10054] An existing connection was forcibly closed by the remote host

If instead I try to extend the update to use the "data" argument (which puts the data into the body of the post rather than the url), something like:

response = requests.post(server, cookies = {"sid": sid}, params=params, data=data)

where params= {
"cmd": "webnotes.client.save"
}
and data= {
"doclist": json.dumps(doclist) 
}

I get the following result from ERPNext:

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n  File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n    execute_cmd(cmd)\\n  File \\"../lib/webnotes/handler.py\\", line 191, in execute_cmd\\n    ret = call(method, webnotes.form_dict)\\n  File \\"../lib/webnotes/handler.py\\", line 210, in call\\n    return fn(**newargs)\\n TypeError: save() takes exactly 1 argument (0 given)\\n"'}

Can you suggest the right approach for updating either individual BOM Items or the entire BOM?

Thank you for your help.


 
Jonathan,

The way to do this would be to first get, update and push.

You can send the list of dicts (we call it a doclist) via a POST request. It should work - where are you getting stuck? Is there a specific error message?

- Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 17-Jan-2013, at 12:49 AM, Jonathan <ir...@gmail.com> wrote:

Thanks for the reply. What we are trying to do is update a complex doctype from a script--specifically we are trying to update a BOM--that is to say, update some subset of BOM Items for a given BOM. The first approach was to try get_doc on an individual BOM Item, passing in the parent BOM name and the item_code of the particular Bom Item as parameters. Various experiments along those lines got us the response that get takes 2 arguments and only 1 is given.

The next approach was to read the entire BOM using get_doc (this works fine), modify the fields in question, then call update. But this puts the entire pile of json into the url. Experiments trying to move the data into the body of the POST didn't get anywhere.

Can you suggest a way forward?

Thanks very much.

- j

On Saturday, January 12, 2013 4:28:50 AM UTC+1, rushabh wrote:
Jonathan, you have to "get" the customer after save, rename it and save gain. The system will only save if the incoming record's "modified" property matches with the one in the database to maintain version conflicts.

Sent from mobile

On 12-Jan-2013, at 12:00 AM, Jonathan <ir...@gmail.com> wrote:

Hi, sorry, me again.

We are trying to create--and optionally update--a Customer doctype based on the script that started this thread.  We are able to create a customer, but so far we have not been able to create a customer where the customer_name is different from the name.  In other words we have a unique name for the Customer ("johndoe123"), which is what we want the doctype to be referenced by, but we want the customer's name to be "John Doe". Once the Customer doctype is created we can change the customer name using the ERPNext API, but we were unable to create the customer that way or update it thereafter. In particular, the update function returns a message that says "Document has been modified after you have opened it."

Could you point us in the right direction?

Thanks.

On Monday, January 7, 2013 3:47:39 PM UTC+1, Jonathan wrote:
Thanks for the suggestion. The problem seems to be the weird parameter-doubling from the 'requests' module.  Now the login is working...

- j

On Monday, January 7, 2013 3:19:45 PM UTC+1, rushabh wrote:
The test runs fine on my setup. I think your installation may be messed up.

What do you get when you run that from the browser?

Sent from mobile

On 07-Jan-2013, at 7:32 PM, Jonathan <ir...@gmail.com> wrote:

Here's the redacted url returned from response.get().  Odd that all the params are doubled.

https://{server}/server.py?pwd={password}&cmd=login&usr={user}&pwd={password}&cmd=login&usr={user}

We are using the sample code llinked to earlier in the forum, only changing the server, user, and password parameters at the top (we also changed response.json.get() to response.json().get()--the code wouldn't work otherwise).

Thanks.

On Monday, January 7, 2013 2:43:00 PM UTC+1, rushabh wrote:
Can you post the entire url? I think you need to pass login id and password as the url parameters

For example you can login via:

server.py?cmd=login&usr=Administrator&pwd=admin

If you are passwords are correctly set.


On Mon, Jan 7, 2013 at 6:40 PM, Amin Zayani <za...@gmail.com> wrote:
Thanks for the quick reply.  We should have thought to test the simplest server.py url. We get back the following json in response to the login.

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n  File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n execute_cmd(cmd)\\n  Fil
e \\"../lib/webnotes/handler.py\\", line 176, in execute_cmd\\n method = get_method(cmd)\\n  File \\"../lib/webnotes/handler.py\\", line 218, in ge
t_method\\n    method = globals()[cmd]\\n KeyError: u\\"[\'login\', \'login\']\\"\\n"'}

Any suggestions?

Thanks again.

PS: my colleague Jonathan will join this thread

On Monday, January 7, 2013 1:10:56 PM UTC+1, rushabh wrote:
Amin,

Thanks for making the 3rd party API script available. We are newbies at ERPNext, so please excuse the following questions if the answers should be obvious.

In our tests using the sample code fromhttps://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py, we have not been able to get past login--we get a 404 response.  We are trying variations of "http://{our local erpnext server}/webnotes/erpnext_master/public/server.py" as the server address.  Our ERPNext is installed simply on a Ubuntu 12.10 virtual machine on a local server and is also accessible outside our LAN through a subdomain of our site, so we were trying, for example, "http://{our local erpnext server}/public/server.py". Can you give us any hints about what the url should be? (We also tried "client.py" instead of "server.py").

Don't use /public/server.py --- just use {local erpnext server}/server.py

Since all requests are passed via server.py (and this should be accessible via your browser). So set "server" to that url (which is server.py replaced by app.html)

We are also not entirely certain that we have updated ERPNext correctly in order to install the correct "client.py" file into the proper location. Can you tell us how to ascertain whether we have the correct file and it's in the expected place?  Once it's in the right place do we need to set any permissions? (because the repository updated is webnotes framework and we only update our ERPNext repository version)

the webclient.py file can be anywhere because it accesses the system via http requests.

Also webclient.py is a template and you can use that code to access data from anywhere.


Thanks.

On Monday, January 7, 2013 6:08:22 AM UTC+1, rushabh wrote:


On Mon, Jan 7, 2013 at 10:32 AM, Rushabh Mehta <rm...@gmail.com> wrote:
Just updated client.py with

webnotes.client.get

pass "doctype" and "name" as parameters

example:

cmd=webnotes.client.get&doctype=[doctype]&name=[name]

you will get a JSON object with a list of main record and the child records (if any)


On Fri, Jan 4, 2013 at 7:42 PM, Amin Zayani <za...@gmail.com> wrote:
Great!
Any chance you add a "read" method to fetch data from ERPNext? And include a simple example for fetching some doctype?

Thanks

On Wednesday, December 19, 2012 12:41:39 PM UTC+1, rushabh wrote:
Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.


Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh



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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/yzLMPR9UcxsJ.

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

 

 








Twitter: @rushabh_mehta



--



Twitter: @rushabh_mehta



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

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/QpP1CwrCuW8J.

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

 

 





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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9sfw-iCSHTkJ.


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



--



Twitter: @rushabh_mehta



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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/AtBNp4DGZjsJ.

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

 

 




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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/d1YRSsSA8U8J.

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

 

 




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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/sso_-D03AMEJ.

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

 

 





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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/BiY2q-sq-2gJ.

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

 

 





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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/NDrHqRjqDQEJ.

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

 

 





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.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/hwlxXe3VleYJ.

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

 

 





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.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/2mC-a8e_t0cJ.

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

 

 




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.

To post to this group, send email to er...@googlegroups.com.

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

 

 

Thanks for the quick turnaround. Is there a way to tell whether a document is saved, submitted, or cancelled?  I had guessed docstatus, but that doesn’t seem to change, at least between saved and submittted.


Cheers,

- j

On Wednesday, February 6, 2013 4:29:42 AM UTC+1, rushabh wrote:
Added submit and cancel methods. Check webclient.py




On 05-Feb-2013, at 10:47 PM, Jonathan <ir...@gmail.com> wrote:

Hi Rushabh,

Is there already a script equivalent to "submit", or if not would you consider adding it?

Thanks very much.

- j


Hi Rushabh,

Thanks, that great--I am already using the new code.

- j

On Wednesday, January 30, 2013 6:37:22 AM UTC+1, rushabh wrote:
Here you go:

https://github.com/webnotes/wnframework/commit/067411da16c6764ade1a7c5bdb6abd35f39f9409


W: https://erpnext.com
T: @rushabh_mehta

On 29-Jan-2013, at 9:36 PM, Jonathan <ir...@gmail.com> wrote:

Hi Rushabh,

I have updated all the scripts, but I am happy enough if it all works under Linux.

Would it be possible to have a generalization of get_doc along the following lines:

def get_doc(server, doctype, name, value):
    return request(server, { "cmd":"webnotes.client.get", "doctype":doctype, name:value})

because, for example for retrieving a sales order, I may know the purchase order number but not the sales order name.

Thanks.

- j





Jonathan,

Great.

Are you running the latest update of the requests module? I did not encounter this error on my Mac.


Anyways, I updated the webclient.py to use posts when required.

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 21-Jan-2013, at 11:16 PM, Jonathan <ir...@gmail.com> wrote:

Hi Rushabh,

Had to change the update() method to use both params and data arguments, and the requests module under both mac and windows didn't seem to fill in the POST request body. Finally got it all to work under linux.

def request(server, params=None, data=None):
    global sid
    
    if not sid: login()
    
    response = requests.post(server, cookies = {"sid": sid}, params=params, data=data)


Thanks for the suggestions.

- j


On Monday, January 21, 2013 3:30:54 PM UTC+1, rushabh wrote:
Jonathan,

Your second approach is correct. You need to do a POST. You are not able send 2 items because of the URL limit in GET.

From the traceback, the parameters are not getting mapped correctly - can you debug the POST a bit?

I am sure you are pretty close to the solution.

best,
Rushabh



Hi.  I am still unable to get update to work and am asking two specific questions.

1. We have a BOM doctype which contains a number of individual BOM Item doctypes. Is it possible to read and update an individual BOM Item from a BOM doctype, or must one read the entire BOM and update the whole thing at once? So far I have only managed to read the entire BOM, but not an individual BOM Item.

2: Since I cannot so far read individual BOM Items, I am trying to update the entire BOM doctype. My update script works successfully if the BOM contains only a single BOM Item, but fails if there are two BOM Items. Why is that?

My script uses the same functions for get_doc(), login(), update(), etc. that you posted here: https://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py. In the original update function, the doclist is added to the params argument of requests.post(), which means the entire doclist is added to the request url. Specifically, I am doing the following:

doc = get_doc("BOM", bom)
rows = doc.json().get("message")
for row in rows
# change Qty if a certain condition is met
update(rows)

If there is one BOM Item in the BOM, the update is successful.  With two or more Bom Items, I get the following traceback:

Traceback (most recent call last):
  File "...\updateqty.py", line 187, in <module>
    main()
  File "...\updateqty.py", line 182, in main
    update(server, rows);
  File "...\updateqty.py", line 50, in update
    "doclist": json.dumps(doclist)
  File "...\updateqty.py", line 62, in request
    response = requests.post(server, cookies = {"sid": sid}, params=params)
  File "C:\Python27\lib\site-packages\requests\api.py", line 87, in post
    return request('post', url, data=data, **kwargs)
  File "C:\Python27\lib\site-packages\requests\api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 279, in request
    resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 374, in send
    r = adapter.send(request, **kwargs)
  File "C:\Python27\lib\site-packages\requests\adapters.py", line 222, in send
    r.content
  File "C:\Python27\lib\site-packages\requests\models.py", line 550, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
  File "C:\Python27\lib\site-packages\requests\models.py", line 496, in generate
    chunk = self.raw.read(chunk_size)
  File "C:\Python27\lib\site-packages\requests\packages\urllib3\response.py", line 148, in read
    return self._fp.read(amt)
  File "C:\Python27\lib\httplib.py", line 561, in read
    s = self.fp.read(amt)
  File "C:\Python27\lib\httplib.py", line 1298, in read
    return s + self._file.read(amt - len(s))
  File "C:\Python27\lib\socket.py", line 380, in read
    data = self._sock.recv(left)
socket.error: [Errno 10054] An existing connection was forcibly closed by the remote host

If instead I try to extend the update to use the "data" argument (which puts the data into the body of the post rather than the url), something like:

response = requests.post(server, cookies = {"sid": sid}, params=params, data=data)

where params= {
"cmd": "webnotes.client.save"
}
and data= {
"doclist": json.dumps(doclist) 
}

I get the following result from ERPNext:

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n  File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n    execute_cmd(cmd)\\n  File \\"../lib/webnotes/handler.py\\", line 191, in execute_cmd\\n    ret = call(method, webnotes.form_dict)\\n  File \\"../lib/webnotes/handler.py\\", line 210, in call\\n    return fn(**newargs)\\n TypeError: save() takes exactly 1 argument (0 given)\\n"'}

Can you suggest the right approach for updating either individual BOM Items or the entire BOM?

Thank you for your help.


 
Jonathan,

The way to do this would be to first get, update and push.

You can send the list of dicts (we call it a doclist) via a POST request. It should work - where are you getting stuck? Is there a specific error message?

- Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 17-Jan-2013, at 12:49 AM, Jonathan <ir...@gmail.com> wrote:

Thanks for the reply. What we are trying to do is update a complex doctype from a script--specifically we are trying to update a BOM--that is to say, update some subset of BOM Items for a given BOM. The first approach was to try get_doc on an individual BOM Item, passing in the parent BOM name and the item_code of the particular Bom Item as parameters. Various experiments along those lines got us the response that get takes 2 arguments and only 1 is given.

The next approach was to read the entire BOM using get_doc (this works fine), modify the fields in question, then call update. But this puts the entire pile of json into the url. Experiments trying to move the data into the body of the POST didn't get anywhere.

Can you suggest a way forward?

Thanks very much.

- j

On Saturday, January 12, 2013 4:28:50 AM UTC+1, rushabh wrote:
Jonathan, you have to "get" the customer after save, rename it and save gain. The system will only save if the incoming record's "modified" property matches with the one in the database to maintain version conflicts.

Sent from mobile

On 12-Jan-2013, at 12:00 AM, Jonathan <ir...@gmail.com> wrote:

Hi, sorry, me again.

We are trying to create--and optionally update--a Customer doctype based on the script that started this thread.  We are able to create a customer, but so far we have not been able to create a customer where the customer_name is different from the name.  In other words we have a unique name for the Customer ("johndoe123"), which is what we want the doctype to be referenced by, but we want the customer's name to be "John Doe". Once the Customer doctype is created we can change the customer name using the ERPNext API, but we were unable to create the customer that way or update it thereafter. In particular, the update function returns a message that says "Document has been modified after you have opened it."

Could you point us in the right direction?

Thanks.

On Monday, January 7, 2013 3:47:39 PM UTC+1, Jonathan wrote:
Thanks for the suggestion. The problem seems to be the weird parameter-doubling from the 'requests' module.  Now the login is working...

- j

On Monday, January 7, 2013 3:19:45 PM UTC+1, rushabh wrote:
The test runs fine on my setup. I think your installation may be messed up.

What do you get when you run that from the browser?

Sent from mobile

On 07-Jan-2013, at 7:32 PM, Jonathan <ir...@gmail.com> wrote:

Here's the redacted url returned from response.get().  Odd that all the params are doubled.

https://{server}/server.py?pwd={password}&cmd=login&usr={user}&pwd={password}&cmd=login&usr={user}

We are using the sample code llinked to earlier in the forum, only changing the server, user, and password parameters at the top (we also changed response.json.get() to response.json().get()--the code wouldn't work otherwise).

Thanks.

On Monday, January 7, 2013 2:43:00 PM UTC+1, rushabh wrote:
Can you post the entire url? I think you need to pass login id and password as the url parameters

For example you can login via:

server.py?cmd=login&usr=Administrator&pwd=admin

If you are passwords are correctly set.


On Mon, Jan 7, 2013 at 6:40 PM, Amin Zayani <za...@gmail.com> wrote:
Thanks for the quick reply.  We should have thought to test the simplest server.py url. We get back the following json in response to the login.

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n  File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n execute_cmd(cmd)\\n  Fil
e \\"../lib/webnotes/handler.py\\", line 176, in execute_cmd\\n method = get_method(cmd)\\n  File \\"../lib/webnotes/handler.py\\", line 218, in ge
t_method\\n    method = globals()[cmd]\\n KeyError: u\\"[\'login\', \'login\']\\"\\n"'}

Any suggestions?

Thanks again.

PS: my colleague Jonathan will join this thread

On Monday, January 7, 2013 1:10:56 PM UTC+1, rushabh wrote:
Amin,

Thanks for making the 3rd party API script available. We are newbies at ERPNext, so please excuse the following questions if the answers should be obvious.

In our tests using the sample code fromhttps://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py, we have not been able to get past login--we get a 404 response.  We are trying variations of "http://{our local erpnext server}/webnotes/erpnext_master/public/server.py" as the server address.  Our ERPNext is installed simply on a Ubuntu 12.10 virtual machine on a local server and is also accessible outside our LAN through a subdomain of our site, so we were trying, for example, "http://{our local erpnext server}/public/server.py". Can you give us any hints about what the url should be? (We also tried "client.py" instead of "server.py").

Don't use /public/server.py --- just use {local erpnext server}/server.py

Since all requests are passed via server.py (and this should be accessible via your browser). So set "server" to that url (which is server.py replaced by app.html)

We are also not entirely certain that we have updated ERPNext correctly in order to install the correct "client.py" file into the proper location. Can you tell us how to ascertain whether we have the correct file and it's in the expected place?  Once it's in the right place do we need to set any permissions? (because the repository updated is webnotes framework and we only update our ERPNext repository version)

the webclient.py file can be anywhere because it accesses the system via http requests.

Also webclient.py is a template and you can use that code to access data from anywhere.


Thanks.

On Monday, January 7, 2013 6:08:22 AM UTC+1, rushabh wrote:


On Mon, Jan 7, 2013 at 10:32 AM, Rushabh Mehta <rm...@gmail.com> wrote:
Just updated client.py with

webnotes.client.get

pass "doctype" and "name" as parameters

example:

cmd=webnotes.client.get&doctype=[doctype]&name=[name]

you will get a JSON object with a list of main record and the child records (if any)


On Fri, Jan 4, 2013 at 7:42 PM, Amin Zayani <za...@gmail.com> wrote:
Great!
Any chance you add a "read" method to fetch data from ERPNext? And include a simple example for fetching some doctype?

Thanks

On Wednesday, December 19, 2012 12:41:39 PM UTC+1, rushabh wrote:
Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.


Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh



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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/yzLMPR9UcxsJ.

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

 

 








Twitter: @rushabh_mehta



--



Twitter: @rushabh_mehta



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

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/QpP1CwrCuW8J.

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

 

 





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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9sfw-iCSHTkJ.


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



--



Twitter: @rushabh_mehta



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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/AtBNp4DGZjsJ.

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

 

 




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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/d1YRSsSA8U8J.

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

 

 




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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/sso_-D03AMEJ.

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

 

 





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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/BiY2q-sq-2gJ.

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

 

 





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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/NDrHqRjqDQEJ.

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

 

 





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.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/hwlxXe3VleYJ.

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

 

 





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.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/2mC-a8e_t0cJ.

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

 

 




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.

To post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/xHprbk2WeAgJ.

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

 

 

Jonathan,

You are right, docstatus=0 is saved, 1 is submitted and 2 is cancelled. After every save, submit, a new doclist is returned in the response. Check the docstatus of the docs in that list, the status should have been updated.

best,
Rushabh


On Wed, Feb 6, 2013 at 9:19 PM, Jonathan <ir...@gmail.com> wrote:
Thanks for the quick turnaround. Is there a way to tell whether a document is saved, submitted, or cancelled? I had guessed docstatus, but that doesn't seem to change, at least between saved and submittted.

Cheers,

- j


On Wednesday, February 6, 2013 4:29:42 AM UTC+1, rushabh wrote:
Added submit and cancel methods. Check webclient.py



On 05-Feb-2013, at 10:47 PM, Jonathan <ir...@gmail.com> wrote:

Hi Rushabh,

Is there already a script equivalent to "submit", or if not would you consider adding it?

Thanks very much.

- j


Hi Rushabh,

Thanks, that great--I am already using the new code.

- j

On Wednesday, January 30, 2013 6:37:22 AM UTC+1, rushabh wrote:
Here you go:

https://github.com/webnotes/wnframework/commit/067411da16c6764ade1a7c5bdb6abd35f39f9409


W: https://erpnext.com
T: @rushabh_mehta

On 29-Jan-2013, at 9:36 PM, Jonathan <ir...@gmail.com> wrote:

Hi Rushabh,

I have updated all the scripts, but I am happy enough if it all works under Linux.

Would it be possible to have a generalization of get_doc along the following lines:

def get_doc(server, doctype, name, value):
return request(server, { "cmd":"webnotes.client.get", "doctype":doctype, name:value})

because, for example for retrieving a sales order, I may know the purchase order number but not the sales order name.

Thanks.

- j





Jonathan,

Great.

Are you running the latest update of the requests module? I did not encounter this error on my Mac.


Anyways, I updated the webclient.py to use posts when required.

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 21-Jan-2013, at 11:16 PM, Jonathan <ir...@gmail.com> wrote:

Hi Rushabh,

Had to change the update() method to use both params and data arguments, and the requests module under both mac and windows didn't seem to fill in the POST request body. Finally got it all to work under linux.

def request(server, params=None, data=None):
global sid
if not sid: login()
response = requests.post(server, cookies = {"sid": sid}, params=params, data=data)


Thanks for the suggestions.

- j


On Monday, January 21, 2013 3:30:54 PM UTC+1, rushabh wrote:
Jonathan,

Your second approach is correct. You need to do a POST. You are not able send 2 items because of the URL limit in GET.

From the traceback, the parameters are not getting mapped correctly - can you debug the POST a bit?

I am sure you are pretty close to the solution.

best,
Rushabh



Hi. I am still unable to get update to work and am asking two specific questions.

1. We have a BOM doctype which contains a number of individual BOM Item doctypes. Is it possible to read and update an individual BOM Item from a BOM doctype, or must one read the entire BOM and update the whole thing at once? So far I have only managed to read the entire BOM, but not an individual BOM Item.

2: Since I cannot so far read individual BOM Items, I am trying to update the entire BOM doctype. My update script works successfully if the BOM contains only a single BOM Item, but fails if there are two BOM Items. Why is that?

My script uses the same functions for get_doc(), login(), update(), etc. that you posted here: https://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py. In the original update function, the doclist is added to the params argument of requests.post(), which means the entire doclist is added to the request url. Specifically, I am doing the following:

doc = get_doc("BOM", bom)
rows = doc.json().get("message")
for row in rows
# change Qty if a certain condition is met
update(rows)

If there is one BOM Item in the BOM, the update is successful. With two or more Bom Items, I get the following traceback:

Traceback (most recent call last):
File "...\updateqty.py", line 187, in <module>
main()
File "...\updateqty.py", line 182, in main
update(server, rows);
File "...\updateqty.py", line 50, in update
"doclist": json.dumps(doclist)
File "...\updateqty.py", line 62, in request
response = requests.post(server, cookies = {"sid": sid}, params=params)
File "C:\Python27\lib\site-packages\requests\api.py", line 87, in post
return request('post', url, data=data, **kwargs)
File "C:\Python27\lib\site-packages\requests\api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 279, in request
resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 374, in send
r = adapter.send(request, **kwargs)
File "C:\Python27\lib\site-packages\requests\adapters.py", line 222, in send
r.content
File "C:\Python27\lib\site-packages\requests\models.py", line 550, in content
self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
File "C:\Python27\lib\site-packages\requests\models.py", line 496, in generate
chunk = self.raw.read(chunk_size)
File "C:\Python27\lib\site-packages\requests\packages\urllib3\response.py", line 148, in read
return self._fp.read(amt)
File "C:\Python27\lib\httplib.py", line 561, in read
s = self.fp.read(amt)
File "C:\Python27\lib\httplib.py", line 1298, in read
return s + self._file.read(amt - len(s))
File "C:\Python27\lib\socket.py", line 380, in read
data = self._sock.recv(left)
socket.error: [Errno 10054] An existing connection was forcibly closed by the remote host

If instead I try to extend the update to use the "data" argument (which puts the data into the body of the post rather than the url), something like:

response = requests.post(server, cookies = {"sid": sid}, params=params, data=data)

where params= {
"cmd": "webnotes.client.save"
}
and data= {
"doclist": json.dumps(doclist)
}

I get the following result from ERPNext:

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n execute_cmd(cmd)\\n File \\"../lib/webnotes/handler.py\\", line 191, in execute_cmd\\n ret = call(method, webnotes.form_dict)\\n File \\"../lib/webnotes/handler.py\\", line 210, in call\\n return fn(**newargs)\\n TypeError: save() takes exactly 1 argument (0 given)\\n"'}

Can you suggest the right approach for updating either individual BOM Items or the entire BOM?

Thank you for your help.


Jonathan,

The way to do this would be to first get, update and push.

You can send the list of dicts (we call it a doclist) via a POST request. It should work - where are you getting stuck? Is there a specific error message?

- Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 17-Jan-2013, at 12:49 AM, Jonathan <ir...@gmail.com> wrote:

Thanks for the reply. What we are trying to do is update a complex doctype from a script--specifically we are trying to update a BOM--that is to say, update some subset of BOM Items for a given BOM. The first approach was to try get_doc on an individual BOM Item, passing in the parent BOM name and the item_code of the particular Bom Item as parameters. Various experiments along those lines got us the response that get takes 2 arguments and only 1 is given.

The next approach was to read the entire BOM using get_doc (this works fine), modify the fields in question, then call update. But this puts the entire pile of json into the url. Experiments trying to move the data into the body of the POST didn't get anywhere.

Can you suggest a way forward?

Thanks very much.

- j

On Saturday, January 12, 2013 4:28:50 AM UTC+1, rushabh wrote:
Jonathan, you have to "get" the customer after save, rename it and save gain. The system will only save if the incoming record's "modified" property matches with the one in the database to maintain version conflicts.

Sent from mobile

On 12-Jan-2013, at 12:00 AM, Jonathan <ir...@gmail.com> wrote:

Hi, sorry, me again.

We are trying to create--and optionally update--a Customer doctype based on the script that started this thread. We are able to create a customer, but so far we have not been able to create a customer where the customer_name is different from the name. In other words we have a unique name for the Customer ("johndoe123"), which is what we want the doctype to be referenced by, but we want the customer's name to be "John Doe". Once the Customer doctype is created we can change the customer name using the ERPNext API, but we were unable to create the customer that way or update it thereafter. In particular, the update function returns a message that says "Document has been modified after you have opened it."

Could you point us in the right direction?

Thanks.

On Monday, January 7, 2013 3:47:39 PM UTC+1, Jonathan wrote:
Thanks for the suggestion. The problem seems to be the weird parameter-doubling from the 'requests' module. Now the login is working...

- j

On Monday, January 7, 2013 3:19:45 PM UTC+1, rushabh wrote:
The test runs fine on my setup. I think your installation may be messed up.

What do you get when you run that from the browser?

Sent from mobile

On 07-Jan-2013, at 7:32 PM, Jonathan <ir...@gmail.com> wrote:

Here's the redacted url returned from response.get(). Odd that all the params are doubled.

https://{server}/server.py?pwd={password}&cmd=login&usr={user}&pwd={password}&cmd=login&usr={user}

We are using the sample code llinked to earlier in the forum, only changing the server, user, and password parameters at the top (we also changed response.json.get() to response.json().get()--the code wouldn't work otherwise).

Thanks.

On Monday, January 7, 2013 2:43:00 PM UTC+1, rushabh wrote:
Can you post the entire url? I think you need to pass login id and password as the url parameters

For example you can login via:

server.py?cmd=login&usr=Administrator&pwd=admin

If you are passwords are correctly set.


On Mon, Jan 7, 2013 at 6:40 PM, Amin Zayani <za...@gmail.com> wrote:
Thanks for the quick reply. We should have thought to test the simplest server.py url. We get back the following json in response to the login.


{u'message': u'', u'exc': u'"Traceback (innermost last):\n File \"…/lib/webnotes/handler.py<u>&quot;, line 159, in handle\n execute_cmd(cmd)\n Fil

e \"…/lib/webnotes/handler.py<u>&quot;, line 176, in execute_cmd\n method = get_method(cmd)\n File \"…/lib/webnotes/handler.py<u>&quot;, line 218, in ge

t_method\n method = globals()[cmd]\n KeyError: u\"[&#39;login&#39;, &#39;login&#39;]\"\n"'}


Any suggestions?

Thanks again.


PS: my colleague Jonathan will join this thread


On Monday, January 7, 2013 1:10:56 PM UTC+1, rushabh wrote:

Amin,


Thanks for making the 3rd party API script available. We are newbies at ERPNext, so please excuse the following questions if the answers should be obvious.


In our tests using the sample code fromhttps://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py, we have not been able to get past login–we get a 404 response. We are trying variations of "http://{our local erpnext server}/webnotes/erpnext_master/public/server.py" as the server address. Our ERPNext is installed simply on a Ubuntu 12.10 virtual machine on a local server and is also accessible outside our LAN through a subdomain of our site, so we were trying, for example, "http://{our local erpnext server}/public/server.py". Can you give us any hints about what the url should be? (We also tried "client.py" instead of "server.py").


Don't use /public/server.py --- just use {local erpnext server}/server.py

Since all requests are passed via server.py (and this should be accessible via your browser). So set "server" to that url (which is server.py replaced by app.html)


We are also not entirely certain that we have updated ERPNext correctly in order to install the correct "client.py" file into the proper location. Can you tell us how to ascertain whether we have the correct file and it's in the expected place? Once it's in the right place do we need to set any permissions? (because the repository updated is webnotes framework and we only update our ERPNext repository version)


the webclient.py file can be anywhere because it accesses the system via http requests.

Also webclient.py is a template and you can use that code to access data from anywhere.



Thanks.

On Monday, January 7, 2013 6:08:22 AM UTC+1, rushabh wrote:



On Mon, Jan 7, 2013 at 10:32 AM, Rushabh Mehta <rm...@gmail.com> wrote:
Just updated client.py with

webnotes.client.get

pass "doctype" and "name" as parameters


example:

cmd=webnotes.client.get&doctype=[doctype]&name=[name]

you will get a JSON object with a list of main record and the child records (if any)


On Fri, Jan 4, 2013 at 7:42 PM, Amin Zayani <za...@gmail.com> wrote:
Great!
Any chance you add a "read" method to fetch data from ERPNext? And include a simple example for fetching some doctype?

Thanks

On Wednesday, December 19, 2012 12:41:39 PM UTC+1, rushabh wrote:
Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.


Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh



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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/yzLMPR9UcxsJ.

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












Twitter: @rushabh_mehta



--



Twitter: @rushabh_mehta



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

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.





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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9sfw-iCSHTkJ.


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





--



Twitter: @rushabh_mehta



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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/AtBNp4DGZjsJ.

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







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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/d1YRSsSA8U8J.

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







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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/sso_-D03AMEJ.

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








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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/BiY2q-sq-2gJ.

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








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

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/NDrHqRjqDQEJ.

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








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.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/hwlxXe3VleYJ.

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








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.

To post to this group, send email to erpnext-dev…@googlegroups.com.




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.

To post to this group, send email to er…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/xHprbk2WeAgJ.


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





--



Twitter: @rushabh_mehta



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.

To post to this group, send email to er...@googlegroups.com.

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

 

 


Hi Rushabh,


Would there be any chance of adding a “print” to the API? I guess it would take doctype, name, and a format as arguments, and return (or somehow give access to) the pdf.

Thanks.

- j



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.

To post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/MvjaH0TPKJEJ.

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

 

 

Jonathan,

Unfortunately thats not easy at the moment because our prints are build in the client (using JS). We are aware its a bad design and its on our re-write agenda. Will keep you updated on the forum when its done. Estimating about a month or so.

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 10-Mar-2013, at 1:14 PM, Jonathan <ir...@gmail.com> wrote:


Hi Rushabh,

Would there be any chance of adding a "print" to the API? I guess it would take doctype, name, and a format as arguments, and return (or somehow give access to) the pdf.

Thanks.

- j



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.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/MvjaH0TPKJEJ.

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

 

 




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.

To post to this group, send email to er...@googlegroups.com.

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

 

 

Hi Rushabh,


is there any method to attach a file to adoctype using the API?

Thanks

Amin

On Wednesday, December 19, 2012 12:41:39 PM UTC+1, rushabh wrote:
Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.


Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh



W: https://erpnext.com
T: @rushabh_mehta



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.

To post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/uxcE1Yw0GUsJ.

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

 

 

Amin,

Here are the query (form) parameters for a POST call:

cmd=uploadfile
from_form=1
filename=[name of file]
filedata=[file data encoded as base64]
doctype=[name of doctype to attach to]
docname=[doc name to attach to]

OR to attach a file as URL

cmd=uploadfile
from_form=1
file_url=[url of the file to be attached]
doctype=[name of doctype to attach to]
docname=[doc name to attach to]

best,
Rushabh




On Tue, May 7, 2013 at 9:35 PM, Amin Zayani <za...@gmail.com> wrote:
Hi Rushabh,

is there any method to attach a file to adoctype using the API?

Thanks

Amin

On Wednesday, December 19, 2012 12:41:39 PM UTC+1, rushabh wrote:
Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.


Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta



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.

To post to this group, send email to er…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/uxcE1Yw0GUsJ.


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





--



Twitter: @rushabh_mehta



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.

To post to this group, send email to er...@googlegroups.com.

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

 

 

Hi Rushabh,


now that the print templates are server generated, is there any chance to have a “print” method accessible by the API?

Best regards,

Amin

On Monday, March 11, 2013 5:27:13 AM UTC+1, rushabh wrote:
Jonathan,

Unfortunately thats not easy at the moment because our prints are build in the client (using JS). We are aware its a bad design and its on our re-write agenda. Will keep you updated on the forum when its done. Estimating about a month or so.

best,
Rushabh



W: https://erpnext.com
T: @rushabh_mehta

On 10-Mar-2013, at 1:14 PM, Jonathan <ir...@gmail.com> wrote:


Hi Rushabh,

Would there be any chance of adding a "print" to the API? I guess it would take doctype, name, and a format as arguments, and return (or somehow give access to) the pdf.

Thanks.

- j



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.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/MvjaH0TPKJEJ.

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

 

 




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.

To post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/f6c65220-2fd5-4a3b-8a28-94133c81e0f3%40googlegroups.com?hl=en.

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

 

 

Already is!

Example:

http://frappe.erpnext.com/print?doctype=Sales%20Invoice&name=INV-13-14-00027&format=SalesInvoice

or

http://frappe.erpnext.com/web.py?page=print&doctype=Sales%20Invoice&name=INV-13-14-00027&format=SalesInvoice

pass doctype, name, format and style to "print"

or pass page=print to server.py

(you need to be logged it to check this)

The only print format we have ready out of the box for server-side is SalesInvoice.

best,
Rushabh

W: https://erpnext.com
T: @rushabh_mehta

On 30-May-2013, at 7:59 PM, Amin Zayani <za...@gmail.com> wrote:

Hi Rushabh,

now that the print templates are server generated, is there any chance to have a "print" method accessible by the API?

Best regards,

Amin

On Monday, March 11, 2013 5:27:13 AM UTC+1, rushabh wrote:
Jonathan,

Unfortunately thats not easy at the moment because our prints are build in the client (using JS). We are aware its a bad design and its on our re-write agenda. Will keep you updated on the forum when its done. Estimating about a month or so.

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 10-Mar-2013, at 1:14 PM, Jonathan <ir...@gmail.com> wrote:


Hi Rushabh,

Would there be any chance of adding a "print" to the API? I guess it would take doctype, name, and a format as arguments, and return (or somehow give access to) the pdf.

Thanks.

- j



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.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/MvjaH0TPKJEJ.

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

 

 





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.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/f6c65220-2fd5-4a3b-8a28-94133c81e0f3%40googlegroups.com?hl=en.

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

 

 




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.

To post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/58A617B5-847F-4F8A-AB79-B7644F297D37%40erpnext.com?hl=en.

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

 

 


Hi Rushabh,

In certain doctypes, such as Sales Order, there is a button “Get Taxes and Charges” which calculates additional charges based on one of the templates found in “Sales Taxes and Charges Master List”. We would like to invoke this functionality from the API, but it is all located in the ERPNext javascript client. One really nasty hack would be to bring up the page in a headless browser and “click” the button from a script. But trying to do this more cleanly by duplicating the calculation logic in our script, I have not had any luck accessing the templates from the API. 

Do you have any suggestions for how to move forward?

Thanks.

- j

 
Already is!

Example:


or


pass doctype, name, format and style to “print”

or pass page=print to server.py

(you need to be logged it to check this)

The only print format we have ready out of the box for server-side is SalesInvoice.

best,
Rushabh

On 30-May-2013, at 7:59 PM, Amin Zayani <za...@gmail.com> wrote:

Hi Rushabh,

now that the print templates are server generated, is there any chance to have a "print" method accessible by the API?

Best regards,

Amin

On Monday, March 11, 2013 5:27:13 AM UTC+1, rushabh wrote:
Jonathan,

Unfortunately thats not easy at the moment because our prints are build in the client (using JS). We are aware its a bad design and its on our re-write agenda. Will keep you updated on the forum when its done. Estimating about a month or so.

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 10-Mar-2013, at 1:14 PM, Jonathan <ir...@gmail.com> wrote:


Hi Rushabh,

Would there be any chance of adding a "print" to the API? I guess it would take doctype, name, and a format as arguments, and return (or somehow give access to) the pdf.

Thanks.

- j



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.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/MvjaH0TPKJEJ.

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

 

 





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.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/f6c65220-2fd5-4a3b-8a28-94133c81e0f3%40googlegroups.com?hl=en.

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

 

 




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.

To post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/cdbbdedf-5b8d-4fe6-a684-af48c0a0ecdb%40googlegroups.com?hl=en.

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

 

 

Hi Jonathan,

We have ported the calculation code to the server side, but it is still in testing. It should be released by end of this month.

This will calculate everything again on the server side. So it solves the problem for users pushing through API and also opens up the possibility of transaction import.

If you want it earlier, you can switch to the "responsive" branch of erpnext and wnframework repositories. (Warning: it is in alpha stage and under testing, though we are using it on our account)

Thanks,
Anand.

On 03-Jun-2013, at 3:56 PM, Jonathan <ir...@gmail.com> wrote:


Hi Rushabh,

In certain doctypes, such as Sales Order, there is a button "Get Taxes and Charges" which calculates additional charges based on one of the templates found in "Sales Taxes and Charges Master List". We would like to invoke this functionality from the API, but it is all located in the ERPNext javascript client. One really nasty hack would be to bring up the page in a headless browser and "click" the button from a script. But trying to do this more cleanly by duplicating the calculation logic in our script, I have not had any luck accessing the templates from the API. 

Do you have any suggestions for how to move forward?

Thanks.

- j

 
Already is!

Example:


or


pass doctype, name, format and style to "print"

or pass page=print to server.py

(you need to be logged it to check this)

The only print format we have ready out of the box for server-side is SalesInvoice.

best,
Rushabh

W: https://erpnext.com
T: @rushabh_mehta

On 30-May-2013, at 7:59 PM, Amin Zayani <za...@gmail.com> wrote:

Hi Rushabh,

now that the print templates are server generated, is there any chance to have a "print" method accessible by the API?

Best regards,

Amin

On Monday, March 11, 2013 5:27:13 AM UTC+1, rushabh wrote:
Jonathan,

Unfortunately thats not easy at the moment because our prints are build in the client (using JS). We are aware its a bad design and its on our re-write agenda. Will keep you updated on the forum when its done. Estimating about a month or so.

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 10-Mar-2013, at 1:14 PM, Jonathan <ir...@gmail.com> wrote:


Hi Rushabh,

Would there be any chance of adding a "print" to the API? I guess it would take doctype, name, and a format as arguments, and return (or somehow give access to) the pdf.

Thanks.

- j



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.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/MvjaH0TPKJEJ.

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

 

 





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.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/f6c65220-2fd5-4a3b-8a28-94133c81e0f3%40googlegroups.com?hl=en.

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

 

 





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.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/cdbbdedf-5b8d-4fe6-a684-af48c0a0ecdb%40googlegroups.com?hl=en.

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

 

 




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.

To post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/A98A6075-C8D5-4FFE-8609-1207FBF62A5D%40erpnext.com?hl=en.

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

 

 

Hi Anand,

Sorry I am just now getting back to this. Perhaps I didn't phrase the original question very well. I am interested in somehow triggering this calculation from  the Web Service API, and preferably without importing client.py. Is that now possible?

Thanks.

- j



On Monday, June 3, 2013 12:32:52 PM UTC+2, Anand Doshi wrote:
Hi Jonathan,

We have ported the calculation code to the server side, but it is still in testing. It should be released by end of this month.

This will calculate everything again on the server side. So it solves the problem for users pushing through API and also opens up the possibility of transaction import.

If you want it earlier, you can switch to the "responsive" branch of erpnext and wnframework repositories. (Warning: it is in alpha stage and under testing, though we are using it on our account)

Thanks,
Anand.

On 03-Jun-2013, at 3:56 PM, Jonathan <ir...@gmail.com> wrote:


Hi Rushabh,

In certain doctypes, such as Sales Order, there is a button "Get Taxes and Charges" which calculates additional charges based on one of the templates found in "Sales Taxes and Charges Master List". We would like to invoke this functionality from the API, but it is all located in the ERPNext javascript client. One really nasty hack would be to bring up the page in a headless browser and "click" the button from a script. But trying to do this more cleanly by duplicating the calculation logic in our script, I have not had any luck accessing the templates from the API. 

Do you have any suggestions for how to move forward?

Thanks.

- j

 
Already is!

Example:


or


pass doctype, name, format and style to "print"

or pass page=print to server.py

(you need to be logged it to check this)

The only print format we have ready out of the box for server-side is SalesInvoice.

best,
Rushabh

W: https://erpnext.com
T: @rushabh_mehta

On 30-May-2013, at 7:59 PM, Amin Zayani <za...@gmail.com> wrote:

Hi Rushabh,

now that the print templates are server generated, is there any chance to have a "print" method accessible by the API?

Best regards,

Amin

On Monday, March 11, 2013 5:27:13 AM UTC+1, rushabh wrote:
Jonathan,

Unfortunately thats not easy at the moment because our prints are build in the client (using JS). We are aware its a bad design and its on our re-write agenda. Will keep you updated on the forum when its done. Estimating about a month or so.

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 10-Mar-2013, at 1:14 PM, Jonathan <ir...@gmail.com> wrote:


Hi Rushabh,

Would there be any chance of adding a "print" to the API? I guess it would take doctype, name, and a format as arguments, and return (or somehow give access to) the pdf.

Thanks.

- j



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.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/MvjaH0TPKJEJ.

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

 

 





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.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/f6c65220-2fd5-4a3b-8a28-94133c81e0f3%40googlegroups.com?hl=en.

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

 

 





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.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/cdbbdedf-5b8d-4fe6-a684-af48c0a0ecdb%40googlegroups.com?hl=en.

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.
Hi Jonathan,

Calculations are triggered automatically on save, in the validate method. So insert/save/submit calls will trigger calculations.

Thanks,
Anand.

On 19-Aug-2013, at 8:40 PM, Jonathan <ir...@gmail.com> wrote:

Hi Anand,

Sorry I am just now getting back to this. Perhaps I didn't phrase the original question very well. I am interested in somehow triggering this calculation from  the Web Service API, and preferably without importing client.py. Is that now possible?

Thanks.

- j



On Monday, June 3, 2013 12:32:52 PM UTC+2, Anand Doshi wrote:
Hi Jonathan,

We have ported the calculation code to the server side, but it is still in testing. It should be released by end of this month.

This will calculate everything again on the server side. So it solves the problem for users pushing through API and also opens up the possibility of transaction import.

If you want it earlier, you can switch to the "responsive" branch of erpnext and wnframework repositories. (Warning: it is in alpha stage and under testing, though we are using it on our account)

Thanks,
Anand.

On 03-Jun-2013, at 3:56 PM, Jonathan <ir...@gmail.com> wrote:


Hi Rushabh,

In certain doctypes, such as Sales Order, there is a button "Get Taxes and Charges" which calculates additional charges based on one of the templates found in "Sales Taxes and Charges Master List". We would like to invoke this functionality from the API, but it is all located in the ERPNext javascript client. One really nasty hack would be to bring up the page in a headless browser and "click" the button from a script. But trying to do this more cleanly by duplicating the calculation logic in our script, I have not had any luck accessing the templates from the API. 

Do you have any suggestions for how to move forward?

Thanks.

- j

 
Already is!

Example:


or


pass doctype, name, format and style to "print"

or pass page=print to server.py

(you need to be logged it to check this)

The only print format we have ready out of the box for server-side is SalesInvoice.

best,
Rushabh

W: https://erpnext.com
T: @rushabh_mehta

On 30-May-2013, at 7:59 PM, Amin Zayani <za...@gmail.com> wrote:

Hi Rushabh,

now that the print templates are server generated, is there any chance to have a "print" method accessible by the API?

Best regards,

Amin

On Monday, March 11, 2013 5:27:13 AM UTC+1, rushabh wrote:
Jonathan,

Unfortunately thats not easy at the moment because our prints are build in the client (using JS). We are aware its a bad design and its on our re-write agenda. Will keep you updated on the forum when its done. Estimating about a month or so.

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 10-Mar-2013, at 1:14 PM, Jonathan <ir...@gmail.com> wrote:


Hi Rushabh,

Would there be any chance of adding a "print" to the API? I guess it would take doctype, name, and a format as arguments, and return (or somehow give access to) the pdf.

Thanks.

- j



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.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/MvjaH0TPKJEJ.

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

 

 





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.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/f6c65220-2fd5-4a3b-8a28-94133c81e0f3%40googlegroups.com?hl=en.

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

 

 





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.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/cdbbdedf-5b8d-4fe6-a684-af48c0a0ecdb%40googlegroups.com?hl=en.

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.



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.
Hi Anand,

Thanks for the very quick clarification. That is super.

The next thing to ask about is access to "print" functionality from the Web Service API. In other words, would it be possible to have a print function which given a doctype and an id (for example, a particular invoice) and maybe a template id, returns the html or pdf that would be generated by hitting the "print" button from within ERPNext?

Thanks,

- j

On Monday, August 19, 2013 5:15:14 PM UTC+2, Anand Doshi wrote:
Hi Jonathan,

Calculations are triggered automatically on save, in the validate method. So insert/save/submit calls will trigger calculations.

Thanks,
Anand.

On 19-Aug-2013, at 8:40 PM, Jonathan <ir...@gmail.com> wrote:

Hi Anand,

Sorry I am just now getting back to this. Perhaps I didn't phrase the original question very well. I am interested in somehow triggering this calculation from  the Web Service API, and preferably without importing client.py. Is that now possible?

Thanks.

- j



On Monday, June 3, 2013 12:32:52 PM UTC+2, Anand Doshi wrote:
Hi Jonathan,

We have ported the calculation code to the server side, but it is still in testing. It should be released by end of this month.

This will calculate everything again on the server side. So it solves the problem for users pushing through API and also opens up the possibility of transaction import.

If you want it earlier, you can switch to the "responsive" branch of erpnext and wnframework repositories. (Warning: it is in alpha stage and under testing, though we are using it on our account)

Thanks,
Anand.

On 03-Jun-2013, at 3:56 PM, Jonathan <ir...@gmail.com> wrote:


Hi Rushabh,

In certain doctypes, such as Sales Order, there is a button "Get Taxes and Charges" which calculates additional charges based on one of the templates found in "Sales Taxes and Charges Master List". We would like to invoke this functionality from the API, but it is all located in the ERPNext javascript client. One really nasty hack would be to bring up the page in a headless browser and "click" the button from a script. But trying to do this more cleanly by duplicating the calculation logic in our script, I have not had any luck accessing the templates from the API. 

Do you have any suggestions for how to move forward?

Thanks.

- j

 
Already is!

Example:


or


pass doctype, name, format and style to "print"

or pass page=print to server.py

(you need to be logged it to check this)

The only print format we have ready out of the box for server-side is SalesInvoice.

best,
Rushabh

W: https://erpnext.com
T: @rushabh_mehta

On 30-May-2013, at 7:59 PM, Amin Zayani <za...@gmail.com> wrote:

Hi Rushabh,

now that the print templates are server generated, is there any chance to have a "print" method accessible by the API?

Best regards,

Amin

On Monday, March 11, 2013 5:27:13 AM UTC+1, rushabh wrote:
Jonathan,

Unfortunately thats not easy at the moment because our prints are build in the client (using JS). We are aware its a bad design and its on our re-write agenda. Will keep you updated on the forum when its done. Estimating about a month or so.

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 10-Mar-2013, at 1:14 PM, Jonathan <ir...@gmail.com> wrote:


Hi Rushabh,

Would there be any chance of adding a "print" to the API? I guess it would take doctype, name, and a format as arguments, and return (or somehow give access to) the pdf.

Thanks.

- j



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.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/MvjaH0TPKJEJ.

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

 

 





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.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/f6c65220-2fd5-4a3b-8a28-94133c81e0f3%40googlegroups.com?hl=en.

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

 

 





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.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/cdbbdedf-5b8d-4fe6-a684-af48c0a0ecdb%40googlegroups.com?hl=en.

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.



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.
Jonathan,

The next thing to ask about is access to "print" functionality from the Web Service API. In other words, would it be possible to have a print function which given a doctype and an id (for example, a particular invoice) and maybe a template id, returns the html or pdf that would be generated by hitting the "print" button from within ERPNext?

Already posted on this thread earlier. Pls check.


Thanks,

- j

On Monday, August 19, 2013 5:15:14 PM UTC+2, Anand Doshi wrote:
Hi Jonathan,

Calculations are triggered automatically on save, in the validate method. So insert/save/submit calls will trigger calculations.

Thanks,
Anand.

On 19-Aug-2013, at 8:40 PM, Jonathan <ir...@gmail.com> wrote:

Hi Anand,

Sorry I am just now getting back to this. Perhaps I didn't phrase the original question very well. I am interested in somehow triggering this calculation from  the Web Service API, and preferably without importing client.py. Is that now possible?

Thanks.

- j



On Monday, June 3, 2013 12:32:52 PM UTC+2, Anand Doshi wrote:
Hi Jonathan,

We have ported the calculation code to the server side, but it is still in testing. It should be released by end of this month.

This will calculate everything again on the server side. So it solves the problem for users pushing through API and also opens up the possibility of transaction import.

If you want it earlier, you can switch to the "responsive" branch of erpnext and wnframework repositories. (Warning: it is in alpha stage and under testing, though we are using it on our account)

Thanks,
Anand.

On 03-Jun-2013, at 3:56 PM, Jonathan <ir...@gmail.com> wrote:


Hi Rushabh,

In certain doctypes, such as Sales Order, there is a button "Get Taxes and Charges" which calculates additional charges based on one of the templates found in "Sales Taxes and Charges Master List". We would like to invoke this functionality from the API, but it is all located in the ERPNext javascript client. One really nasty hack would be to bring up the page in a headless browser and "click" the button from a script. But trying to do this more cleanly by duplicating the calculation logic in our script, I have not had any luck accessing the templates from the API. 

Do you have any suggestions for how to move forward?

Thanks.

- j

 
Already is!

Example:


or


pass doctype, name, format and style to "print"

or pass page=print to server.py

(you need to be logged it to check this)

The only print format we have ready out of the box for server-side is SalesInvoice.

best,
Rushabh

W: https://erpnext.com
T: @rushabh_mehta

On 30-May-2013, at 7:59 PM, Amin Zayani <za...@gmail.com> wrote:

Hi Rushabh,

now that the print templates are server generated, is there any chance to have a "print" method accessible by the API?

Best regards,

Amin

On Monday, March 11, 2013 5:27:13 AM UTC+1, rushabh wrote:
Jonathan,

Unfortunately thats not easy at the moment because our prints are build in the client (using JS). We are aware its a bad design and its on our re-write agenda. Will keep you updated on the forum when its done. Estimating about a month or so.

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 10-Mar-2013, at 1:14 PM, Jonathan <ir...@gmail.com> wrote:


Hi Rushabh,

Would there be any chance of adding a "print" to the API? I guess it would take doctype, name, and a format as arguments, and return (or somehow give access to) the pdf.

Thanks.

- j



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.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/MvjaH0TPKJEJ.

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

 

 





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.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/f6c65220-2fd5-4a3b-8a28-94133c81e0f3%40googlegroups.com?hl=en.

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

 

 





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.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/cdbbdedf-5b8d-4fe6-a684-af48c0a0ecdb%40googlegroups.com?hl=en.

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.




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.
Oops, very sorry about that--it must be the drugs.

Cheers,

- j


On Monday, August 19, 2013 7:25:59 PM UTC+2, rushabh wrote:
Jonathan,

The next thing to ask about is access to "print" functionality from the Web Service API. In other words, would it be possible to have a print function which given a doctype and an id (for example, a particular invoice) and maybe a template id, returns the html or pdf that would be generated by hitting the "print" button from within ERPNext?

Already posted on this thread earlier. Pls check.


Thanks,

- j

On Monday, August 19, 2013 5:15:14 PM UTC+2, Anand Doshi wrote:
Hi Jonathan,

Calculations are triggered automatically on save, in the validate method. So insert/save/submit calls will trigger calculations.

Thanks,
Anand.

On 19-Aug-2013, at 8:40 PM, Jonathan <ir...@gmail.com> wrote:

Hi Anand,

Sorry I am just now getting back to this. Perhaps I didn't phrase the original question very well. I am interested in somehow triggering this calculation from  the Web Service API, and preferably without importing client.py. Is that now possible?

Thanks.

- j



On Monday, June 3, 2013 12:32:52 PM UTC+2, Anand Doshi wrote:
Hi Jonathan,

We have ported the calculation code to the server side, but it is still in testing. It should be released by end of this month.

This will calculate everything again on the server side. So it solves the problem for users pushing through API and also opens up the possibility of transaction import.

If you want it earlier, you can switch to the "responsive" branch of erpnext and wnframework repositories. (Warning: it is in alpha stage and under testing, though we are using it on our account)

Thanks,
Anand.

On 03-Jun-2013, at 3:56 PM, Jonathan <ir...@gmail.com> wrote:


Hi Rushabh,

In certain doctypes, such as Sales Order, there is a button "Get Taxes and Charges" which calculates additional charges based on one of the templates found in "Sales Taxes and Charges Master List". We would like to invoke this functionality from the API, but it is all located in the ERPNext javascript client. One really nasty hack would be to bring up the page in a headless browser and "click" the button from a script. But trying to do this more cleanly by duplicating the calculation logic in our script, I have not had any luck accessing the templates from the API. 

Do you have any suggestions for how to move forward?

Thanks.

- j

 
Already is!

Example:


or


pass doctype, name, format and style to "print"

or pass page=print to server.py

(you need to be logged it to check this)

The only print format we have ready out of the box for server-side is SalesInvoice.

best,
Rushabh

W: https://erpnext.com
T: @rushabh_mehta

On 30-May-2013, at 7:59 PM, Amin Zayani <za...@gmail.com> wrote:

Hi Rushabh,

now that the print templates are server generated, is there any chance to have a "print" method accessible by the API?

Best regards,

Amin

On Monday, March 11, 2013 5:27:13 AM UTC+1, rushabh wrote:
Jonathan,

Unfortunately thats not easy at the moment because our prints are build in the client (using JS). We are aware its a bad design and its on our re-write agenda. Will keep you updated on the forum when its done. Estimating about a month or so.

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 10-Mar-2013, at 1:14 PM, Jonathan <ir...@gmail.com> wrote:


Hi Rushabh,

Would there be any chance of adding a "print" to the API? I guess it would take doctype, name, and a format as arguments, and return (or somehow give access to) the pdf.

Thanks.

- j



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.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/MvjaH0TPKJEJ.

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

 

 





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.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/f6c65220-2fd5-4a3b-8a28-94133c81e0f3%40googlegroups.com?hl=en.

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

 

 





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.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/cdbbdedf-5b8d-4fe6-a684-af48c0a0ecdb%40googlegroups.com?hl=en.

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.




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.