Skip to content
Draft
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
94 changes: 94 additions & 0 deletions sale_stock_picking_variable_qty/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
===============================
Sale Stock Picking Variable Qty
===============================

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

.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-workflow/tree/16.0/sale_stock_picking_variable_qty
:alt: OCA/stock-logistics-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/stock-logistics-workflow-16-0/stock-logistics-workflow-16-0-sale_stock_picking_variable_qty
: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/stock-logistics-workflow&target_branch=16.0
:alt: Try me on Runboat

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

Handle variable done quantity in multi-step deliveries.

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

Known issues / Roadmap
======================

- Detect what's a backorder and what's not...
- Add setting at picking type (maybe we don't want this behavior all the
time)

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-workflow/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/stock-logistics-workflow/issues/new?body=module:%20sale_stock_picking_variable_qty%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
-------

* Moduon

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.

.. |maintainer-rafaelbn| image:: https://github.com/rafaelbn.png?size=40px
:target: https://github.com/rafaelbn
:alt: rafaelbn
.. |maintainer-chienandalu| image:: https://github.com/chienandalu.png?size=40px
:target: https://github.com/chienandalu
:alt: chienandalu

Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-rafaelbn| |maintainer-chienandalu|

This module is part of the `OCA/stock-logistics-workflow <https://github.com/OCA/stock-logistics-workflow/tree/16.0/sale_stock_picking_variable_qty>`_ 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 sale_stock_picking_variable_qty/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions sale_stock_picking_variable_qty/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2025 Moduon Team S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)
{
"name": "Sale Stock Picking Variable Qty",
"summary": "Handle variable quantity in multi-step deliveries",
"version": "16.0.1.0.0",
"development_status": "Alpha",
"category": "Inventory/Delivery",
"website": "https://github.com/OCA/stock-logistics-workflow",
"author": "Moduon, Odoo Community Association (OCA)",
"maintainers": ["rafaelbn", "chienandalu"],
"license": "LGPL-3",
"depends": [
"sale_stock",
],
"data": [],
}
1 change: 1 addition & 0 deletions sale_stock_picking_variable_qty/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import stock_move
42 changes: 42 additions & 0 deletions sale_stock_picking_variable_qty/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2025 Moduon Team S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)
from odoo import models
from odoo.tools import float_compare


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

def _get_final_sale_line_id(self):
# Consider only pick/pack moves
return (self.browse(self._rollup_move_dests(set()))).sale_line_id

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

def _adjust_variable_quantity(self):
"""For moves where qty_done ≠ qty_demanded spread that new quantity across every
move_dest_id.
"""
# TODO: Make this optionable (by operation or whatever)
# It doesn't make sense to analyize 0 qty moves as they're clearly not done
for move in self.filtered("quantity_done"):
# Nothing to do if the demand fits the qty done, let's avoid changes
rounding = move.product_uom.rounding
if (
float_compare(
move.quantity_done,
move.product_uom_qty,
precision_rounding=rounding,
)
== 0
):
continue
sale_line = move._get_final_sale_line_id()
if not sale_line:
continue
# The quantity of the move might be a partial of the sale line demand
locked_sale_line_qty = sale_line.product_uom_qty - move.product_uom_qty
# Finally we adjust just the variable demand corresponding to this move
sale_line.product_uom_qty = locked_sale_line_qty + move.quantity_done
1 change: 1 addition & 0 deletions sale_stock_picking_variable_qty/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Handle variable done quantity in multi-step deliveries.
2 changes: 2 additions & 0 deletions sale_stock_picking_variable_qty/readme/ROADMAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Detect what's a backorder and what's not...
- Add setting at picking type (maybe we don't want this behavior all the time)
Loading