Send Purchase Order to External System and Check the order status with their APIs

Hello everyone,

I would like to develop custom app that can send purchase order from my app to external system and check order status with using their public APIs.

So hope expert can help me with detailed guides.

Regards

Hi James,

This is a relatively common use case well suited to Frappe. The place to start would be the framework documentation: https://frappeframework.com

Hi peterg, thanks for your reply.

Yes. But I would like to know how should I start at first?
I created base custom app and when and where , how should I develop code at first?

Should I develop sending oridering POST requests when submitting purchase order?
Also should I customize purchase order doctype?

Thanks

There are a number of different ways of going about what you’re describing, and the best choice depends on the particularities of your needs. Based on why you’ve described so far, the easiest solution would probably be to create an event hook before submit:

https://frappeframework.com/docs/user/en/python-api/hooks#crud-events

https://frappeframework.com/docs/user/en/basics/doctypes/controllers#controller-hooks

Yes. I think we can use before_submit hook for purchase order document.
And develop API integration code into the customized function. Is that right?

If I am going to integrate two external system(ext_system1, ext_system2),
then should I develop two custom apps because we can’t know right external system that the purchase order should send?

Also when going to check the order status that created in external system, how should I approach it?

I’m really appreciate your expertise.

I can’t imagine that you would want two separate apps for most applications, unless you intend to distribute them as standalone integrations. Once the hook method is called, you can perform whatever business logic you’d like before, during, and after the external the external API calls. I’m not sure what you mean by checking business logic, but anything you can describe with python is possible.

When creating purchase order, should I add custom field ‘product supplier’ to purchase order doctype and user can input or select external system supplier name.
And when submit, we can post ordering request to their API.
Is this workflow right?

Also should I use daily cron job for checking created order status and where should I show the order status in dashboard?

Sorry for my misunderstanding and tricky questions.

It really depends on what you’re trying to do. The purchase order already has a supplier field. You don’t need to add another one.

You’d probably want a custom field for order status, which can be updated periodically via a scheduler job. To display on the dashboard, you can read that field in a chart or shortcut count.

Hello peterg,

when submit purchase order, we should post order to supplier’s api.
The supplier provides oauth authorization for access their api.
Then, where could we store client-id and secret-key , access token after authorization?

That’s a broad design question that is hard to answer without full understanding of your project. There’s already an OAuth Client doctype with full authorization lifecycle code, which may or may not suit your needs.