콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
25282 화면

Guys,

I have a REST API and for example, let's image this is my endpoint:

www.nabvigator360.com/api/order/create

This is a POSt request to add a new order. I need to create a form (view) in Odoo and connect with this endpoint.

Can we do this in Odoo? (community edition or enterprise edition)


And also I need to create another view and display all the added orders in Odoo.


(My endpoints use my database)


Thank you in advance.

아바타
취소
베스트 답변

Hello,

Yes this is defiantly possible, I have done a few integrations which work off the same principle. You would NEED to create a custom module as Odoo doesn't allow you to import Python libraries into Python code through the UI.

You would use the Requests Python library to make such requests. It is pretty simple to get the hang of if you haven't used the library before. You just put your end endpoint, data and headers if required (Quickstart). 

You just need to define the trigger which calls your endpoint, from your question it looks like when you create the Sales Order. You could override the create function and put your, this would look something like this: 

    @api.model_create_multi
    @api.returns('self', lambda value: value.id)
    def create(self, vals_list):
        records = super(sales_test, self).create(vals_list)
        for vals in vals_list:
            response = requests.post("https://ptsv2.com/t/z4za5-1610576490/post", data=vals)
            response.raise_for_status()
        return records

This is the result that I get in my endpoint: Image

You may need to configure the when you want to make your calls but this should get you started. Feel free to email me and I would happily send you the module I have created to get you started.

Hope this helps,

Thanks, 

아바타
취소
작성자

Thank you so much. I will check this and let you know. Really appreciate your quick response.

Is it possible to load the data from the Rest API on tree view?

This seems so helpful, can I get your email please, the one in your profile seems not working well.

관련 게시물 답글 화면 활동
4
3월 15
17436
3
12월 23
21866
2
7월 25
2691
3
7월 25
521
1
7월 25
209