odoo/tutorials#1050
Created by Darshil Naliyapara (danal)
Blocked
- Merge method
- Review
-
CI
- ci/style: (runtime 33s)
- ci/tutorial: (runtime 113s)
- label
- odoo-dev:19.0-sale_order_zero_stock_blockage-danal
- head
- 498b7cf28104267936ce25ce5df1366734984181
| odoo/tutorials | |
|---|---|
| 19.0 | #1050 missing r+ |
| master |
[ADD] sale_order_zero_stock_blockage: add manager approval on insufficient stock
Currently, a sales user can confirm a Quotation even if it contains no
products or if the products have insufficient stock compared to the
order quantity. This leads to the creation of invalid Sales Orders,
which negatively impacts inventory planning and invoicing.
This module introduces a validation to the Sales Order confirmation
process to prevent these issues.
The following checks are added:
1. Prevent confirmation if the order has no lines.
2. Prevent confirmation if the product stock is insufficient.
To bypass the insufficient stock restriction, a user with the 'Sales Manager'
group must enable the new 'Approval' (zero_stock_approval) field on the
order.
Technical details:
- Model sale.order: Added zero_stock_approval Boolean field.
- Method fields_get: Overridden to set zero_stock_approval as
readonly for users who are not in the sales_team.group_sale_manager group.
- Method action_confirm: Added logic to raise a UserError if:
- The order has no lines.
- A product's qty_available is less than product_uom_qty (for
goods) and the zero_stock_approval is not enabled.
- added TestCases.