Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
1350 Lượt xem

Hi,

I want to add some custom Python code to the create_from_ui() function in the point_of_sale module (or any other function that can intercept before the order goes through). I've tried to create a model which inherits pos.order and used super but haven't been able to get it to work.

Does anyone know how I can override that function or otherwise intercept the pos order before it goes through and run custom code on it?

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

Hi,

This worked to add the custom code, but in the code I am using requests.get() but it fails with Connection Refused. It doesn't seem to be an issue with the endpoint I am calling as I tested it from Postman with no issue. Is there any setting within Odoo that needs to be changed to call another external API?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

Try the below code:

class PosOrder(models.Model):

    _inherit = 'pos.order'

   

    @api.model

    def create_from_ui(self, orders, draft=False):

        order_ids = super(PosOrder, self).create_from_ui(orders, draft)

       

        #Your code here

       

         return order_ids


Hope it helps

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 9 24
1424
1
thg 8 24
9600
3
thg 2 25
3655
0
thg 5 24
46
1
thg 4 24
3410