1
votes

I'm trying to override button "confirm order" in module "Purchase". This button will change a quotation into a purchase order (state: Purchase Confirmed), simultaneous automatically create a new receipt in module "Warehouse" so when I click button "Receive Products", I can see the receipt.

I tried to super many different functions but when i clicked the button, it just changed state, not create a new receipt. Beside, I found out that this button is from workflow and its function may be "wkf_confirm_order" but it didn't work.

@api.multi
def purchase_confirm(self):
    #super(purchase_order,self).wkf_bid_received()
    super(purchase_order,self).wkf_confirm_order()
    #super(purchase_order,self).wkf_approve_order()
    return True

Please, help me to find the correct function. I really appreciate your help. Thanks in advance.

2

2 Answers

1
votes

To know which function of that model will be called while you click on that button you need to follow these steps.

  • Start developer mode
  • Click on Purchase Orders menu
  • Click on EDIT WORKFLOW option from the debug menu

enter image description here

  • Then open that workflow record in diagram view by clicking on diagram view.

enter image description here

  • Then it will open entire workflow of purchase order

enter image description here

  • Click on confirm order action, it will open activity wizard from where you can see which action has been done while you click on that button.

enter image description here

Click here to know more about workflow.

1
votes

This is the correct syntax of overriding a method in python

def my_method(self):
    #do task before my_method
    result=super(MyClass,self).my_method()
    #do task after my_method by using result
    return result

try this code:

@api.multi
def purchase_confirm(self):
    #do task before confirm
    res=super(purchase_order,self).purchase_confirm()
    #do task after confirm by using res
    return res