- should it be move.state, instead of pick.state?
- and what about the case when user return some/all products?
Typically, from the functional point of view, you can receive either all, none or some of the goods you ordered. There is also the option for the supplier to provide half of the goods in one go and the other half on backorder. So ultimately it is pretty hard to determine what has or has not been delivered yet and how you should handle the PO afterwards.
If you want to cancel the PO and base the decision on wheter or not goods have been delivered, you will have to decide if you should be able to cancel if a part of the order has already been delivered. If this is the case, use the related order moves. If you want only the entire to cancel, you should base that decision on the picking. Remember, 1 picking order can still hold 1 or more move lines related to a purchase order.
Note: This reasoning will only work if standard Odoo functionality is used. If you somehow modified the PO process, this might no longer be valid.
If anyone have the same issue, I update the code and you can check it from the following gist.
That code will allow you to cancel PO if it already have some shipment 'done' and returned all the shipment ('done').
That code cover the following use cases:
- PO already have some delivery 'done', but suddendly the supplier have no stock of the remaining product in PO lines
- user mistakenly add wrong product in PO lines, but some delivery already 'done'
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
About This Community
|Asked: 11/4/14, 11:32 PM|
|Seen: 922 times|
|Last updated: 3/16/15, 8:10 AM|