跳至內容
選單
此問題已被標幟
2 回覆
1120 瀏覽次數

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?

頭像
捨棄
作者 最佳答案

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?

頭像
捨棄
最佳答案

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

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
0
9月 24
1248
1
8月 24
9385
3
2月 25
3276
0
5月 24
46
1
4月 24
3214