Skip to content

[ADD] zero_stock_sale_approval: add zero stock approval field on sale order#1292

Draft
moahi-odoo wants to merge 1 commit into
odoo:19.0from
odoo-dev:19.0-zero-stock-approval-moahi
Draft

[ADD] zero_stock_sale_approval: add zero stock approval field on sale order#1292
moahi-odoo wants to merge 1 commit into
odoo:19.0from
odoo-dev:19.0-zero-stock-approval-moahi

Conversation

@moahi-odoo
Copy link
Copy Markdown

Sales users were able to confirm orders even when stock was not available. This could lead to wrong commitments, stock issues, and lack of proper control.

Introduced a zero stock approval mechanism in sale orders. Added a Boolean field zero_stock_approval to control confirmation behavior.

  • Created a new module for zero stock approval
  • Added zero_stock_approval field in sale.order model
  • Restricted field editing to Admin/Sales Manager only
  • Updated action_confirm to validate stock before confirming
  • Blocked confirmation when stock is insufficient unless approval is enabled
  • Extended sale order form view to display the new field

@robodoo
Copy link
Copy Markdown

robodoo commented May 25, 2026

Pull request status dashboard

… order

Sales users were able to confirm orders even when stock was not available.
This could lead to wrong commitments, stock issues, and lack of proper control.

Introduced a zero stock approval mechanism in sale orders.
Added a Boolean field zero_stock_approval to control confirmation behavior.

- Created a new module for zero stock approval
- Added zero_stock_approval field in sale.order model
- Restricted field editing to Admin/Sales Manager only
- Updated action_confirm to validate stock before confirming
- Blocked confirmation when stock is insufficient unless approval is enabled
- Extended sale order form view to display the new field
@moahi-odoo moahi-odoo force-pushed the 19.0-zero-stock-approval-moahi branch from bc4833e to 53a9861 Compare May 25, 2026 12:03
@moahi-odoo moahi-odoo requested review from mash-odoo and sumai-odoo and removed request for mash-odoo and sumai-odoo June 2, 2026 13:32
Copy link
Copy Markdown

@mash-odoo mash-odoo left a comment

Choose a reason for hiding this comment

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

Hello!
Good work on the task..
I have added some questions...please have a look at it..

{
'name': 'Sale Zero Stock Approval',
'description': 'Grant permission to confirm approved orders without stock.',
'depends': ['sale_management', 'sale_stock'],
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This won't be installed directly, and user wouldn't know the features coming along with this modules. So don't you think we should do something such that this module also get installed once it's dependency is installed?

and not self.env.user.has_group("sales_team.group_sale_manager")
and item.product_id.type == "consu"
and item.product_id.is_storable
and item.product_id.qty_available < item.product_uom_qty
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why use qty_available and not free_qty? Can you walk me through your approach here?

Also, I think item.product_id.qty_available this will give global stock?
Should availability be checked against the order's warehouse instead of global stock? 🤔

and not self.env.user.has_group("sales_team.group_sale_manager")
and item.product_id.type == "consu"
and item.product_id.is_storable
and item.product_id.qty_available < item.product_uom_qty
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is this comparison correct? Like will it work fine acroos all the UOM's?

class SaleZeroStock(models.Model):
_inherit = 'sale.order'

zero_stock_approval = fields.Boolean(string="Approval by Manager", default=False)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should approval reset automatically when: order lines change, quantities change, product changes?
Like what if its approved but the SOL is changed later?

Also maybe you can keep a track history on approval to know who approved and when

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