Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
5 ตอบกลับ
32037 มุมมอง

Hello,

I want to develop API for adding customer or product and also generate PDF. How it can be done in odoo or in python? How this created API test in postman? please suggest me good documentation for both.  

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

For creating new API and handling external API's you can refer our following blogs

Creating API For External Entities In Odoo

Handling External APIs in Odoo

Odoo Official XMLRPC API Documentation

Update:

Also refer the blog regarding the configuration of Postman for sending the API requests

https://www.cybrosys.com/blog/configure-postman-for-sending-api-requests

Regards

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

See how can postman is used for the mobile api development in Odoo : https://www.youtube.com/watch?v=wGvuRbCyytk&t=23s

Thanks

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

https://www.odoo.com/documentation/12.0/webservices/odoo.html

https://odoo-restapi.readthedocs.io/en/latest/

อวตาร
ละทิ้ง

import requests

@api.onchange('btn_funtion')

def get_details(self):

http = urllib3.PoolManager()

URL = 'https://vpic.nhtsa.dot.gov/api/vehicles/DecodeVin/' + str(self.vin_number) + '?format=json&modelyear=2011'

datas = http.request('GET', URL)

datas = json.loads(datas.data.decode('utf-8'))

datas = datas.get('Results')

its a simple button funtion using python request library to connect to US vehicle dipartment

คำตอบที่ดีที่สุด

Hi  SSS,

Creating an API in Odoo to add customers or products and generate PDFs can be done using Odoo's built-in controller system with the @http.route decorator. You’ll define endpoints within custom modules using Odoo’s http.Controller and handle requests in JSON format. To generate PDFs, you can use Odoo's built-in QWeb templating engine or external libraries like ReportLab if you're working outside Odoo. For a pure Python setup (outside Odoo), you can create RESTful APIs using frameworks like Flask or FastAPI and generate PDFs using reportlab, WeasyPrint, or pdfkit.

To test your API in Postman, define the method (POST/GET), input the endpoint URL (e.g., http://localhost:8069/api/add_customer), and add a JSON body with the required fields. Don’t forget to include headers like Content-Type: application/json and authorization if needed.


Regards

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Thanks @shalin wilson and @\Cybrosys Techno Solutions Pvt.Ltd​ 

For your help and time. Information given by both of you helpful

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
4
ก.ย. 19
3798
1
ก.ย. 23
1523
2
พ.ย. 22
5208
1
มิ.ย. 22
7484
1
ก.ย. 21
2470