Skip to content

Commit

Permalink
TA#70700 [14.0][ADD] stock_picking_remove_reservation (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
abenzbiria authored Nov 5, 2024
1 parent 65a080d commit 2ed79fb
Show file tree
Hide file tree
Showing 14 changed files with 214 additions and 0 deletions.
1 change: 1 addition & 0 deletions .docker_files/main/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"stock_picking_groupby_parent_affiliate",
"stock_picking_product_supplier",
"stock_picking_responsible_editable",
"stock_picking_remove_reservation",
"stock_picking_secondary_unit_demand",
"stock_picking_show_address",
"stock_picking_split_qty",
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ COPY stock_picking_barcode /mnt/extra-addons/stock_picking_barcode
COPY stock_picking_delivery_carrier_required /mnt/extra-addons/stock_picking_delivery_carrier_required
COPY stock_picking_groupby_parent_affiliate /mnt/extra-addons/stock_picking_groupby_parent_affiliate
COPY stock_picking_responsible_editable /mnt/extra-addons/stock_picking_responsible_editable
COPY stock_picking_remove_reservation /mnt/extra-addons/stock_picking_remove_reservation
COPY stock_picking_secondary_unit_demand /mnt/extra-addons/stock_picking_secondary_unit_demand
COPY stock_picking_show_address /mnt/extra-addons/stock_picking_show_address
COPY stock_picking_split_qty /mnt/extra-addons/stock_picking_split_qty
Expand Down
29 changes: 29 additions & 0 deletions stock_picking_remove_reservation/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Stock Picking Remove Reservation
================================
Odoo provides a server action called 'Correct inconsistencies for reservation' to fix any
desynchronization between quants and their move lines.

This action is only accessible via the server actions menu in the technical panel.

This module allows the same feature to be integrated directly into the stock picking
form and unreserve move lines for the active picking.

Usage
-----
As a user with access to transfers (stock picking), when I receive the error message:

.. image:: static/description/stock_picking_error_message.png

I need to click on "Desynchronize the reservation."

.. image:: static/description/stock_picking_select_items.png

.. image:: static/description/stock_picking_remove_reservation.png





Contributors
------------
* Numigi (tm) and all its contributors (https://bit.ly/numigiens)
4 changes: 4 additions & 0 deletions stock_picking_remove_reservation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# © 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import wizard
19 changes: 19 additions & 0 deletions stock_picking_remove_reservation/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# © 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Stock Picking Remove Reservation",
"version": "14.0.1.0.0",
"author": "Numigi",
"maintainer": "Numigi",
"website": "https://bit.ly/numigi-com",
"license": "AGPL-3",
"category": "Stock",
"depends": ["stock"],
"summary": "Allow to force stock picking unreservation.",
"data": [
"security/ir.model.access.csv",
"wizard/stock_picking_unreserve_view.xml",
],
"installable": True,
}
85 changes: 85 additions & 0 deletions stock_picking_remove_reservation/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_picking_remove_reservation
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-04 21:14+0000\n"
"PO-Revision-Date: 2024-11-04 21:14+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: stock_picking_remove_reservation
#: model_terms:ir.ui.view,arch_db:stock_picking_remove_reservation.stock_picking_unreserve_view
msgid "Cancel"
msgstr "Annuler"

#. module: stock_picking_remove_reservation
#: model:ir.model.fields,field_description:stock_picking_remove_reservation.field_stock_picking_unreserve__create_uid
msgid "Created by"
msgstr "Créé par"

#. module: stock_picking_remove_reservation
#: model:ir.model.fields,field_description:stock_picking_remove_reservation.field_stock_picking_unreserve__create_date
msgid "Created on"
msgstr "Créé le"

#. module: stock_picking_remove_reservation
#: model:ir.model.fields,field_description:stock_picking_remove_reservation.field_stock_picking_unreserve__display_name
msgid "Display Name"
msgstr "Nom d'affichage"

#. module: stock_picking_remove_reservation
#: model:ir.model.fields,field_description:stock_picking_remove_reservation.field_stock_picking_unreserve__id
msgid "ID"
msgstr "ID"

#. module: stock_picking_remove_reservation
#: model:ir.model.fields,field_description:stock_picking_remove_reservation.field_stock_picking_unreserve____last_update
msgid "Last Modified on"
msgstr "Dernière mise-à-jour le"

#. module: stock_picking_remove_reservation
#: model:ir.model.fields,field_description:stock_picking_remove_reservation.field_stock_picking_unreserve__write_uid
msgid "Last Updated by"
msgstr "Dernière mise à jour par"

#. module: stock_picking_remove_reservation
#: model:ir.model.fields,field_description:stock_picking_remove_reservation.field_stock_picking_unreserve__write_date
msgid "Last Updated on"
msgstr "Dernière mise à jour le"

#. module: stock_picking_remove_reservation
#: model:ir.actions.act_window,name:stock_picking_remove_reservation.action_stock_picking_unreserve
msgid "Remove reservation"
msgstr "Supprimer la réservation"

#. module: stock_picking_remove_reservation
#: model_terms:ir.ui.view,arch_db:stock_picking_remove_reservation.stock_picking_unreserve_view
msgid "Unreserve"
msgstr "Annuler la réservation"

#. module: stock_picking_remove_reservation
#: model_terms:ir.ui.view,arch_db:stock_picking_remove_reservation.stock_picking_unreserve_view
msgid "Unreserve Stock Move Lines"
msgstr "Annuler la réservation des lignes de mouvement de stock"

#. module: stock_picking_remove_reservation
#: model_terms:ir.ui.view,arch_db:stock_picking_remove_reservation.stock_picking_unreserve_view
msgid ""
"You should run this action only when you encounter a picking validation "
"issue related to the reservation"
msgstr ""
"Vous ne devez exécuter cette action que lorsque vous rencontrez un problème de "
"validation de picking lié à la réservation."

#. module: stock_picking_remove_reservation
#: model:ir.model,name:stock_picking_remove_reservation.model_stock_picking_unreserve
msgid "stock.picking.unreserve"
msgstr ""
2 changes: 2 additions & 0 deletions stock_picking_remove_reservation/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_stock_picking_unreserve,access_stock_picking_unreserve,model_stock_picking_unreserve,stock.group_stock_manager,1,1,1,1
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions stock_picking_remove_reservation/wizard/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# © 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import stock_picking_unreserve
37 changes: 37 additions & 0 deletions stock_picking_remove_reservation/wizard/stock_picking_unreserve.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# © 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models


class StockPickingUnreserve(models.TransientModel):
_name = "stock.picking.unreserve"

def action_remove_reservation(self):
""""
This function was inspired by the server action Correct inconsistencies for
reservation and allows for the desynchronization of the active pickings
"""
context = dict(self._context or {})
if context.get('active_ids', False):
picking_ids = self.env['stock.picking'].browse(context.get('active_ids'))
for picking in picking_ids:
move_line_to_recompute_ids = []
picking.move_line_ids.with_context(bypass_reservation_update=True).sudo().write(
{'product_uom_qty': 0})
move_line_to_recompute_ids += picking.move_line_ids.ids
for line in picking.move_line_ids:
quants = self.env['stock.quant'].search([
('product_id', '=', line.product_id.id),
('location_id', '=', line.location_id.id),
('lot_id', '=', line.lot_id.id),
('package_id', '=', line.package_id.id),
('owner_id', '=', line.owner_id.id),
('quantity', '!=', 0)])
for quant in quants:
quant.sudo().write({'reserved_quantity': 0})
if move_line_to_recompute_ids:
self.env['stock.move.line'].browse(
move_line_to_recompute_ids).move_id._recompute_state()

return {'type': 'ir.actions.act_window_close'}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>

<record id="stock_picking_unreserve_view" model="ir.ui.view">
<field name="name">Unreserve Stock Move Lines</field>
<field name="model">stock.picking.unreserve</field>
<field name="arch" type="xml">
<form string="Unreserve">
<separator string="Unreserve Stock Move Lines"/>
<form class="o_form_label">You should run this action only when you encounter a picking validation issue related to the reservation</form>
<footer>
<button string="Unreserve" name="action_remove_reservation" type="object" default_focus="1" class="btn-primary"/>
<button string="Cancel" class="btn-secondary" special="cancel"/>
</footer>
</form>
</field>
</record>

<record id="action_stock_picking_unreserve" model="ir.actions.act_window">
<field name="name">Remove reservation</field>
<field name="groups_id" eval="[(4,ref('stock.group_stock_manager'))]"/>
<field name="res_model">stock.picking.unreserve</field>
<field name="view_mode">form</field>
<field name="view_id" ref="stock_picking_unreserve_view"/>
<field name="target">new</field>
<field name="binding_model_id" ref="stock.model_stock_picking" />
<field name="binding_view_types">list</field>
</record>

</data>
</odoo>

0 comments on commit 2ed79fb

Please sign in to comment.