| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Odoo Apps Dependencies |
•
Purchase (purchase)
• Invoicing (account) • Discuss (mail) |
| Lines of code | 27 |
| Technical Name |
purchase_safe_cancel |
| License | OPL-1 |
Block unsafe Purchase Order cancellation in Odoo 19.
Prevent cancelling Purchase Orders that still have net received quantities. Keep your inventory history clean and force a proper return workflow instead of silently cancelling already received orders.
- There are completed receipt/return operations linked to this order.
- Some products still have a net received quantity.
- Please create Return Transfers first, then cancel again.
Why Purchase Safe Cancel?
In Odoo 19, it is possible to cancel a Purchase Order even if products have already been received. This can easily create confusion: the PO looks cancelled, but the stock is still in the warehouse. This module adds a safety layer without changing your normal workflow.
Buyers can cancel a Purchase Order after receiving goods. The PO disappears from the product purchase history, but the stock remains on hand. This breaks traceability.
The module checks each line of the PO. If any line still has
qty_received > 0, cancellation is blocked and the user is guided to create
a Return Transfer instead.
You only cancel Purchase Orders that have no remaining received quantities. Returns are handled properly and your stock and purchase history stay consistent.
Key behaviour & technical details
No new menus, no extra buttons – just a safe extension of the standard Cancel action.
- Extends purchase.order » button_cancel().
- If all lines have
qty_received = 0, cancellation is allowed. - If any line has
qty_received > 0, cancellation is blocked. - A clear message is shown to the user with:
- Completed receipts/returns linked to the PO.
- Products and their net received quantities.
- Compatible with Odoo 19 (Community & Enterprise).
- Does not modify any core Odoo file.
- Pure Python logic, no JavaScript, no view changes.
- Simple installation:
- Drop into your addons path.
- Update Apps list.
- Install Purchase Safe Cancel.
purchase
Screenshots
Real Odoo 19 screenshots showing how Purchase Safe Cancel behaves in different scenarios.
The incoming shipment for the Purchase Order is in Done state, showing the received quantities for each product.
A standard Purchase Order where both lines have been fully received. In this state, the module will prevent cancellation until the quantities are properly returned.
When trying to cancel a Purchase Order that still has net received quantities, the module blocks the action and shows a detailed message listing completed pickings and products with remaining received quantities.
The user opens the Return wizard from the receipt to send back the received quantities. This is the correct step required before cancelling the Purchase Order.
The Purchase Order has been fully returned and safely cancelled. All lines now show 0 received quantity, while the chatter keeps a clear history of the quantity updates.
FAQ
qty_received = 0, the cancellation is allowed again and
Odoo's standard cancellation logic is executed.
Odoo Proprietary License v1.0 This software and associated files (the "Software") may only be used (executed, modified, executed after modifications) if you have purchased a valid license from the authors, typically via Odoo Apps, or if you have received a written agreement from the authors of the Software (see the COPYRIGHT file). You may develop Odoo modules that use the Software as a library (typically by depending on it, importing it and using its resources), but without copying any source code or material from the Software. You may distribute those modules under the license of your choice, provided that this license is compatible with the terms of the Odoo Proprietary License (For example: LGPL, MIT, or proprietary licenses similar to this one). It is forbidden to publish, distribute, sublicense, or sell copies of the Software or modified copies of the Software. The above copyright notice and this permission notice must be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Please log in to comment on this module