Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Help review canceling purchase code

By
Ben Bernard
on 11/4/14, 11:32 PM 920 views

https://github.com/odoo/odoo/blob/b55cd571f522ae4ebf94ae4ac4924e6de50c13a0/addons/purchase/purchase.py#L684

  • should it be move.state, instead of pick.state?
  • and what about the case when user return some/all products?
0

Ben Bernard

--Ben Bernard--
1083
| 4 3 6
Jakarta, Indonesia
--Ben Bernard--
Ben Bernard
On 11/5/14, 9:59 PM

If anyone have the same issue, I update the code and you can check it from the following gist.

https://gist.github.com/bbn-bernard/87a0f46af030e3d459e1

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'

 

0

Ludo - Neobis

--Ludo - Neobis--
2387
| 2 2 5
Hoogvliet, Netherlands
--Ludo - Neobis--

Developer

Ludo - Neobis
On 11/5/14, 3:39 AM

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.

My issue is that in default code (and configuration) there is no way to cancel PO if some stock picking (incoming shipment) already done. I think it should be still can be cancelled as long as the incoming shipment is returned and process the delivery order (until 'done'). I update the code with that logic, but I'm still not sure the effect functionally.

Ben Bernard
on 11/5/14, 5:15 AM

Partially agree with you there. The thing is prob. what we mean by the term "cancel". In my opinion it means something like "never happened". In that case and your situation, the PO did happen, which is proven by the items sent to you. If you return the items, still the original PO has taken place and I would personally therefore never cancel it. Unfortunately I can't think of an suitable alternative solution to this problem.

Ludo - Neobis
on 11/5/14, 7:19 AM

Your Answer

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

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 11/4/14, 11:32 PM
Seen: 920 times
Last updated: 3/16/15, 8:10 AM