Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions product_state_shortage/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

======================
Product State Shortage
======================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:b09ee549fbc946d01a69212107d01ea12d27fa070ee391708bb4bbdbbcc5eddd
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github
:target: https://github.com/OCA/product-attribute/tree/16.0/product_state_shortage
:alt: OCA/product-attribute
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-product_state_shortage
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/product-attribute&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module extends the ``product.state`` and ``stock.move`` models to
manage product states during stock operations. It introduces the concept
of a shortage state, allowing products to automatically revert to their
default state when stock receipts are validated.

**Table of contents**

.. contents::
:local:

Use Cases / Context
===================

**Business Need**

This module addresses the need to manage product states effectively in
scenarios where stock shortages occur. It ensures that products marked
as in shortage automatically revert to their default state when new
stock is received.

**Approach**

The module introduces a boolean field ``is_shortage`` in the
``product.state`` model. When enabled, it triggers a reset of the
product state upon stock receipt validation.

Configuration
=============

To configure this module, you need to:

1. Navigate to the **Inventory** module.
2. Go to **Sales > Configuration > Products > Product States**.
3. Create or edit a product state and enable the **Is Shortage State**
checkbox.
4. Save the changes.

This configuration ensures that products in the specified state will
automatically revert to the default state upon stock receipt validation.

Usage
=====

To use this module, you need to:

1. Navigate to the **Inventory** module.
2. Go to **Sales > Configuration > Products > Product States** and
create a state with the **Is Shortage State** checkbox enabled.
3. Assign the shortage state to products as needed.
4. When stock receipts are validated, products in the shortage state
will automatically revert to the default state.

This module does not impact the user interface beyond the described
configuration and usage steps.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-attribute/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/product-attribute/issues/new?body=module:%20product_state_shortage%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* ACSONE SA/NV

Contributors
------------

- Nicolas Delbovier nicolas.delbovier@acsone.com
(https://www.acsone.eu/)

Other credits
-------------

The development of this module has been financially supported by:

- ACSONE SA/NV

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/product-attribute <https://github.com/OCA/product-attribute/tree/16.0/product_state_shortage>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions product_state_shortage/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
18 changes: 18 additions & 0 deletions product_state_shortage/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2026 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Product State Shortage",
"summary": """Enables to declare a product state as a "shortage" state.
Such a state will automatically resolve to default state whenever new stock
is received for this product avoiding the need for manual intervention""",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/product-attribute",
"depends": ["product_state", "stock"],
"data": [
"views/product_state.xml",
],
"demo": [],
}
3 changes: 3 additions & 0 deletions product_state_shortage/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import stock_move
from . import product_state
from . import product_template
14 changes: 14 additions & 0 deletions product_state_shortage/models/product_state.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2026 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ProductState(models.Model):
_inherit = "product.state"

is_shortage = fields.Boolean(
string="Is Shortage State",
help="If checked, products in this state will automatically revert to the "
"default state when a stock receipt is validated.",
)
13 changes: 13 additions & 0 deletions product_state_shortage/models/product_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2026 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models


class ProductTemplate(models.Model):

_inherit = "product.template"

def _reset_default_state(self):
if default_state := self._get_default_product_state():
self.write({"product_state_id": default_state.id})
22 changes: 22 additions & 0 deletions product_state_shortage/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2026 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models


class StockMove(models.Model):
_inherit = "stock.move"

def _action_done(self, cancel_backorder=False):
res = super()._action_done(cancel_backorder=cancel_backorder)

incoming_moves = self.filtered(lambda m: m.picking_code == "incoming")
if incoming_moves:
shortage_products_to_reset = incoming_moves.product_id.filtered(
lambda p: p.product_state_id.is_shortage
)

if shortage_products_to_reset:
shortage_products_to_reset.product_tmpl_id._reset_default_state()

return res
8 changes: 8 additions & 0 deletions product_state_shortage/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
To configure this module, you need to:

1. Navigate to the **Inventory** module.
2. Go to **Sales > Configuration > Products > Product States**.
3. Create or edit a product state and enable the **Is Shortage State** checkbox.
4. Save the changes.

This configuration ensures that products in the specified state will automatically revert to the default state upon stock receipt validation.
7 changes: 7 additions & 0 deletions product_state_shortage/readme/CONTEXT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
**Business Need**

This module addresses the need to manage product states effectively in scenarios where stock shortages occur. It ensures that products marked as in shortage automatically revert to their default state when new stock is received.

**Approach**

The module introduces a boolean field `is_shortage` in the `product.state` model. When enabled, it triggers a reset of the product state upon stock receipt validation.
1 change: 1 addition & 0 deletions product_state_shortage/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Nicolas Delbovier <nicolas.delbovier@acsone.com> (https://www.acsone.eu/)
3 changes: 3 additions & 0 deletions product_state_shortage/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The development of this module has been financially supported by:

- ACSONE SA/NV
1 change: 1 addition & 0 deletions product_state_shortage/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module extends the `product.state` and `stock.move` models to manage product states during stock operations. It introduces the concept of a shortage state, allowing products to automatically revert to their default state when stock receipts are validated.
8 changes: 8 additions & 0 deletions product_state_shortage/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
To use this module, you need to:

1. Navigate to the **Inventory** module.
2. Go to **Sales > Configuration > Products > Product States** and create a state with the **Is Shortage State** checkbox enabled.
3. Assign the shortage state to products as needed.
4. When stock receipts are validated, products in the shortage state will automatically revert to the default state.

This module does not impact the user interface beyond the described configuration and usage steps.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading