From 39f8b5aff77ad91e38101c17ff55f977ece5cb06 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 25 Nov 2015 11:31:00 +0100 Subject: [PATCH] [FIX] stock: error if not assigned When the user validates a picking without going through the manual reservation process, Odoo tries to assign the picking then performs the transfer. However, if the picking could not be assigned, no pack operation is created and the picking will simply be set to done. The fix raises an error if the picking could not be assigned completely. Another solution is to use a force_assign instead of action_assign, but that could lead to the creation of negative stock moves without warning the user. We therefore prefer to stay on the safe side and force the user to manually handle the reservation. Note: the original issue was that the Owner of the picking was not copied on the quant when validating right away. The reason was that no pack operation was created. opw-654423 --- addons/stock/i18n/stock.pot | 6 ++++++ addons/stock/wizard/stock_immediate_transfer.py | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/addons/stock/i18n/stock.pot b/addons/stock/i18n/stock.pot index 5831d645738..dad94c6f1b4 100644 --- a/addons/stock/i18n/stock.pot +++ b/addons/stock/i18n/stock.pot @@ -1201,6 +1201,12 @@ msgstr "" msgid "Corridor (X)" msgstr "" +#. module: stock +#: code:addons/stock/wizard/stock_immediate_transfer.py:31 +#, python-format +msgid "Could not reserve all requested products. Please use the 'Mark as Todo' button to handle the reservation manually." +msgstr "" + #. module: stock #: model:ir.ui.view,arch_db:stock.view_backorder_confirmation msgid "Create Backorder" diff --git a/addons/stock/wizard/stock_immediate_transfer.py b/addons/stock/wizard/stock_immediate_transfer.py index 9b21300b666..d118b6746c5 100644 --- a/addons/stock/wizard/stock_immediate_transfer.py +++ b/addons/stock/wizard/stock_immediate_transfer.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from openerp import models, fields, api +from openerp import models, fields, api, _ from openerp.tools import float_compare +from openerp.exceptions import UserError class stock_immediate_transfer(models.TransientModel): _name = 'stock.immediate.transfer' @@ -26,6 +27,8 @@ class stock_immediate_transfer(models.TransientModel): self.pick_id.action_confirm() if self.pick_id.state != 'assigned': self.pick_id.action_assign() + if self.pick_id.state != 'assigned': + raise UserError(_("Could not reserve all requested products. Please use the \'Mark as Todo\' button to handle the reservation manually.")) for pack in self.pick_id.pack_operation_ids: if pack.product_qty > 0: pack.write({'qty_done': pack.product_qty})