Skip to content

Commit

Permalink
[FIX] sale_stock: cancel sale order in multistep delivery
Browse files Browse the repository at this point in the history
In case the warehouse is set in 2 or 3 steps delivery, validating the
first picking forbid any sales order cancellation.

This commit allows this flow by cancelling only active picking when
cancelling a sale order.

closes #68315

Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
  • Loading branch information
Whenrow committed Mar 25, 2021
1 parent ac50df6 commit abc9ee8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion addons/sale_stock/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def action_cancel(self):
if sale_order.state == 'sale' and sale_order.order_line:
sale_order_lines_quantities = {order_line: (order_line.product_uom_qty, 0) for order_line in sale_order.order_line}
documents = self.env['stock.picking']._log_activity_get_documents(sale_order_lines_quantities, 'move_ids', 'UP')
self.mapped('picking_ids').action_cancel()
self.mapped('picking_ids').filtered(lambda p: p.state != 'done').action_cancel()
if documents:
filtered_documents = {}
for (parent, responsible), rendering_context in documents.items():
Expand Down

7 comments on commit abc9ee8

@pedrobaeza
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amoyaux this is provoking a side effect: deliveries with only one step that has been validated, allows the sales order to be cancelled, and be deleted after that, removing as well the link sale <-> picking and leaving dangling pickings, which is a problem in several of our customers. Isn't there any other solution?

@Whenrow
Copy link
Contributor Author

@Whenrow Whenrow commented on abc9ee8 Oct 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pedrobaeza Hello. You get a message on the picking anyway. If you still need to block your flow I would suggest removing the button from the sale order view in case of one of the picking is done

@pedrobaeza
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for answering, William. Yeah, we've got always that option, but changing the behavior in the middle of the version cycle seems awkward and has produced problems on the instances where they were relying on the block that this provoked previously. Now some users have removed sales orders that have been delivered, and there are dangling pickings without SO.

@pedrobaeza
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Whenrow are you going to do such button change or restore the restriction? I think it's important to preserve the consistency.

@Kassim123
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This modification really messed up everything big time. @pedrobaeza's statement is correct. @Whenrow

@pedrobaeza
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We developed this module for preserving the behavior: https://odoo-community.org/shop/sale-stock-cancel-restriction-10003#attr=16959

@Kassim123
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you brother!

Please sign in to comment.