freakboy3742 / pyxero

Python API for accessing the REST API of the Xero accounting tool.
BSD 3-Clause "New" or "Revised" License
280 stars 209 forks source link

How to create Invoice with invoice information(contract Id, metadata)? #253

Open seniorMLstar opened 5 years ago

seniorMLstar commented 5 years ago

Hi PyXero team! I would like to get quick help from you. I just came from this Xero API Previewer page: https://app.xero.com/Preview/invoices/POST xeroapi

As you can see, there is an option to post invoice with XML file. I tried to implement invoice creation feature using PyXero like this: invoice = xero.invoices.filter(Contract_ContractID=CONTRACT_ID) invoice.post(some_data)

But it is showing me an error "{AttributeError}'Manager' object has no attribute 'post'" I am not sure what is the solution to create an invoice with captured contract id and json or xml based data.

I would like to get the solution from you as soon as possible. Thank you

IdlePhysicist commented 5 years ago

Hi there, I have no solution for you, but I can say that Xero has no Contract field/attribute. Perhaps you mean Contact?

Also the invoice object has no attribute post (as your error shows) you probably need to use invoice.put(data) to create a new invoice, or invoice.save(data) to update an existing invoice.

Have a look at this code in the PyXero README file. It shows example get, filter, put, and save methods for the contacts object, they will work for the invoice object also.

I hope this helps you some.

seniorMLstar commented 5 years ago

I mean Contact,