Skip to content

Commit

Permalink
[ADD] sale_stock_prebook_stock_available_to_promise_release:
Browse files Browse the repository at this point in the history
Take moves into account when computing the previous promised qty
Keep date_priority of Confirmed sale.orders which were reserved before
  • Loading branch information
mt-software-de committed Feb 5, 2025
1 parent cfe2d01 commit 7822a9d
Show file tree
Hide file tree
Showing 13 changed files with 668 additions and 0 deletions.
84 changes: 84 additions & 0 deletions sale_stock_prebook_stock_available_to_promise_release/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
=====================================================
sale_stock_prebook_stock_available_to_promise_release
=====================================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:cfcd333bb77a206dbb3dc49862d1eba49ca6007c6d3330b39481aebb787df450
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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/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%2Fsale_workflow-lightgray.png?logo=github
:target: https://github.com/OCA/sale_workflow/tree/14.0/sale_stock_prebook_stock_available_to_promise_release
:alt: OCA/sale_workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/sale_workflow-14-0/sale_workflow-14-0-sale_stock_prebook_stock_available_to_promise_release
: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/sale_workflow&target_branch=14.0
:alt: Try me on Runboat

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

Extends the previous available qty to promised with moves of a reservation

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale_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/sale_workflow/issues/new?body=module:%20sale_stock_prebook_stock_available_to_promise_release%0Aversion:%2014.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
~~~~~~~

* MT Software

Contributors
~~~~~~~~~~~~

* Michael Tietz (MT Software) <[email protected]>

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-mt-software-de| image:: https://github.com/mt-software-de.png?size=40px
:target: https://github.com/mt-software-de
:alt: mt-software-de

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

|maintainer-mt-software-de|

This module is part of the `OCA/sale_workflow <https://github.com/OCA/sale_workflow/tree/14.0/sale_stock_prebook_stock_available_to_promise_release>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2023 Michael Tietz (MT Software) <[email protected]>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
{
"name": "sale_stock_prebook_stock_available_to_promise_release",
"summary": "Extends the previous available qty to promised with moves of a reservation",
"version": "14.0.1.0.0",
"author": "MT Software, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/sale-workflow",
"depends": [
"sale_stock_prebook",
"stock_available_to_promise_release",
],
"maintainers": ["mt-software-de"],
"license": "LGPL-3",
"auto_install": True,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import stock_move
from . import sale
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2023 Michael Tietz (MT Software) <[email protected]>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from odoo import models


class SaleOrder(models.Model):
_inherit = "sale.order"

def _action_confirm(self):
moves = self._get_reservation_pickings().move_lines
if moves:
date_priority_of_reservation = moves[0].date_priority
self = self.with_context(
date_priority_of_reservation=date_priority_of_reservation
)
return super()._action_confirm()


class SaleOrderLine(models.Model):
_inherit = "sale.order.line"

def _prepare_procurement_values(self, group_id=False):
values = super()._prepare_procurement_values(group_id)
date_priority_of_reservation = self.env.context.get(
"date_priority_of_reservation"
)
if date_priority_of_reservation:
values["date_priority"] = date_priority_of_reservation
return values
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2023 Michael Tietz (MT Software) <[email protected]>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from odoo import models


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

def _previous_promised_qty_sql_moves_before_matches(self):
match_sql = super()._previous_promised_qty_sql_moves_before_matches()
res = """
(
{match_sql}
OR
COALESCE(m.used_for_sale_reservation, False) = COALESCE(move.need_release, False)
)
""".format(
match_sql=match_sql
)
return res

def _previous_promised_qty_sql_moves_no_release(self):
sql_no_release = super()._previous_promised_qty_sql_moves_no_release()
return f"""
(
{sql_no_release}
)
AND (
m.used_for_sale_reservation IS false OR m.used_for_sale_reservation IS NULL
)"""
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Michael Tietz (MT Software) <[email protected]>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Extends the previous available qty to promised with moves of a reservation
Loading

0 comments on commit 7822a9d

Please sign in to comment.