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

Good day everyone.


Is there a way to execute custom code after a sale order is created succesfully? I was thinking inherit sale order and override or extend the create method not sure if thats the proper/right way.


Thanks in advance


อวตาร
ละทิ้ง

when you need to execute your function, on creation of the sale order or on confirming the sale order ?

Yes you have to override create or write method..

ผู้เขียน

Thanks Ray, that worked just fine. 

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

Take a look at how we do this in the sale_purchase module:

https://github.com/odoo/odoo/blob/15.0/addons/sale_purchase/models/sale_order.py#L24

There is an internal function that we override.

(you would do the same in your own module: call super and then your code)

def _action_confirm(self):
result = super(SaleOrder, self)._action_confirm()
for order in self:
order.order_line.sudo()._purchase_service_generation()
return result

More documentation at https://www.odoo.com/documentation/15.0/developer/howtos/rdtraining/13_inheritance.html

อวตาร
ละทิ้ง