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

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

아바타
취소