Skip to content

Conversation

@danal-odoo
Copy link

@danal-odoo danal-odoo commented Dec 9, 2025

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.

Task-5382939

@robodoo
Copy link

robodoo commented Dec 9, 2025

Pull request status dashboard

@danal-odoo danal-odoo force-pushed the 19.0-sale_order_zero_stock_blockage-danal branch 2 times, most recently from c9eec9e to 2e9864a Compare December 9, 2025 06:11
@bit-odoo
Copy link

Hello @danal-odoo
Can you please add a test for this?

@danal-odoo danal-odoo force-pushed the 19.0-sale_order_zero_stock_blockage-danal branch 3 times, most recently from b717203 to acb5010 Compare December 11, 2025 18:40
…cient 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.

Task-5382939
@danal-odoo danal-odoo force-pushed the 19.0-sale_order_zero_stock_blockage-danal branch from acb5010 to 498b7cf Compare December 11, 2025 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants