From d3514a24d20edc42aa28a52a4deb2caa47af7e4b Mon Sep 17 00:00:00 2001 From: Suherdy Yacob Date: Thu, 26 Feb 2026 15:24:52 +0700 Subject: [PATCH] first commit --- .gitignore | 19 +++++++++++++++++++ README.md | 12 ++++++++++++ __init__.py | 1 + __manifest__.py | 11 +++++++++++ models/__init__.py | 1 + models/stock_picking.py | 15 +++++++++++++++ 6 files changed, 59 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 __init__.py create mode 100644 __manifest__.py create mode 100644 models/__init__.py create mode 100644 models/stock_picking.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b5d72ab --- /dev/null +++ b/.gitignore @@ -0,0 +1,19 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# OS generated files +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db + +# Editors +*.swp +*~ +.idea/ +.vscode/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..2734fb2 --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +# Stock Fix Unpicked Backorder + +## Overview +This module patches an issue in Odoo 19 where validating a partial stock picking and choosing "No Backorder" causes Odoo to explicitly cancel any stock move lines that have not been manually marked as `picked`. This cancellation results in their quantity being zeroed out, even if the line's quantity perfectly matched its demand. + +## Technical Details +Odoo 19's `stock.picking` validation skips automatically marking lines as `picked = True` if *any* other line in the transfer was manually processed/picked. When `cancel_backorder=True` is provided (via the "No Backorder" wizard), the `_action_done` method of `stock.move` cancels moves that are not picked or have <= 0 quantity. + +This module overrides `_pre_action_done_hook` on `stock.picking` to ensure that any move with a `quantity > 0` is automatically marked as `picked = True` right before the validation logic runs. + +## Usage +Simply install the module. The fix is applied automatically during the backorder validation flow. diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/__manifest__.py b/__manifest__.py new file mode 100644 index 0000000..ef803c1 --- /dev/null +++ b/__manifest__.py @@ -0,0 +1,11 @@ +{ + 'name': 'Stock Fix Unpicked Backorder', + 'version': '19.0.1.0.0', + 'category': 'Inventory/Inventory', + 'summary': 'Fixes Odoo 19 issue where lines with quantity are zeroed out on No Backorder', + 'depends': ['stock'], + 'data': [], + 'installable': True, + 'auto_install': False, + 'license': 'LGPL-3', +} diff --git a/models/__init__.py b/models/__init__.py new file mode 100644 index 0000000..ae4c272 --- /dev/null +++ b/models/__init__.py @@ -0,0 +1 @@ +from . import stock_picking diff --git a/models/stock_picking.py b/models/stock_picking.py new file mode 100644 index 0000000..54bfe46 --- /dev/null +++ b/models/stock_picking.py @@ -0,0 +1,15 @@ +from odoo import models + +class StockPicking(models.Model): + _inherit = 'stock.picking' + + def _pre_action_done_hook(self): + # Odoo 17 skips auto-setting `picked = True` if _any_ line was manually picked. + # This causes unpicked lines with `quantity > 0` to be cancelled + # when the user selects "No Backorder", zeroing out their quantity. + # We enforce that any line with quantity > 0 is treated as picked. + for picking in self: + for move in picking.move_ids: + if move.quantity > 0 and not move.picked: + move.picked = True + return super()._pre_action_done_hook()