diff --git a/modules/sale_stock_quantity/tests/scenario_sale_stock_quantity.rst b/modules/sale_stock_quantity/tests/scenario_sale_stock_quantity.rst
index 0ab34cffaf..ac6c0b0a93 100644
--- a/modules/sale_stock_quantity/tests/scenario_sale_stock_quantity.rst
+++ b/modules/sale_stock_quantity/tests/scenario_sale_stock_quantity.rst
@@ -13,7 +13,7 @@ Imports::
>>> from trytond.modules.account_invoice.tests.tools import (
... create_payment_term, set_fiscalyear_invoice_sequences)
>>> from trytond.modules.company.tests.tools import create_company
- >>> from trytond.modules.stock.exceptions import InventoryFutureWarning
+ >>> from trytond.modules.stock.exceptions import MoveFutureWarning
>>> from trytond.tests.tools import activate_modules
>>> today = dt.date.today()
@@ -25,6 +25,8 @@ Activate modules::
... ['sale_stock_quantity', 'stock_supply'],
... create_company, create_chart)
+ >>> Warning = Model.get('res.user.warning')
+
Create fiscal year::
>>> fiscalyear = set_fiscalyear_invoice_sequences(
@@ -170,8 +172,8 @@ Make an inventory of 3 products in 2 days::
>>> inventory_line.expected_quantity = 5.0
>>> try:
... inventory.click('confirm')
- ... except InventoryFutureWarning as e:
- ... Model.get('res.user.warning')(user=config.user, name=e.name).save()
+ ... except MoveFutureWarning as warning:
+ ... Warning(user=config.user, name=warning.name).save()
>>> inventory.click('confirm')
>>> inventory.state
'done'
diff --git a/modules/stock/exceptions.py b/modules/stock/exceptions.py
index 36f3ae6073..34788edc33 100644
--- a/modules/stock/exceptions.py
+++ b/modules/stock/exceptions.py
@@ -36,10 +36,6 @@ class MoveFutureWarning(UserWarning):
pass
-class InventoryFutureWarning(UserWarning):
- pass
-
-
class ProductCostPriceError(ValidationError):
pass
diff --git a/modules/stock/inventory.py b/modules/stock/inventory.py
index 921306ad59..4051a72b2d 100644
--- a/modules/stock/inventory.py
+++ b/modules/stock/inventory.py
@@ -15,8 +15,7 @@ from trytond.tools import grouped_slice, is_full_text, lstrip_wildcard
from trytond.transaction import Transaction
from trytond.wizard import Button, StateTransition, StateView, Wizard
-from .exceptions import (
- InventoryCountWarning, InventoryFutureWarning, InventoryValidationError)
+from .exceptions import InventoryCountWarning, InventoryValidationError
class Inventory(Workflow, ModelSQL, ModelView, ChatMixin):
@@ -153,29 +152,7 @@ class Inventory(Workflow, ModelSQL, ModelView, ChatMixin):
def confirm(cls, inventories):
pool = Pool()
Move = pool.get('stock.move')
- Date = pool.get('ir.date')
- Warning = pool.get('res.user.warning')
transaction = Transaction()
- today_cache = {}
-
- def in_future(inventory):
- if inventory.company not in today_cache:
- with Transaction().set_context(company=inventory.company.id):
- today_cache[inventory.company] = Date.today()
- today = today_cache[inventory.company]
- if inventory.date > today:
- return inventory
- future_inventories = sorted(filter(in_future, inventories))
- if future_inventories:
- names = ', '.join(i.rec_name for i in future_inventories[:5])
- if len(future_inventories) > 5:
- names + '...'
- warning_name = Warning.format('date_future', future_inventories)
- if Warning.check(warning_name):
- raise InventoryFutureWarning(warning_name,
- gettext('stock.msg_inventory_date_in_the_future',
- inventories=names))
-
moves = []
for inventory in inventories:
keys = set()
@@ -193,8 +170,7 @@ class Inventory(Workflow, ModelSQL, ModelView, ChatMixin):
if moves:
with transaction.set_context(_product_replacement=False):
Move.save(moves)
- with transaction.set_context(_skip_warnings=True):
- Move.do(moves)
+ Move.do(moves)
@classmethod
@ModelView.button
diff --git a/modules/stock/message.xml b/modules/stock/message.xml
index 9bf5368963..4c38169176 100644
--- a/modules/stock/message.xml
+++ b/modules/stock/message.xml
@@ -119,9 +119,6 @@ because the type does not support moves and location has existing moves.
The moves "%(moves)s" have effective dates in the future.
-
- The inventories "%(inventories)s" have dates in the future.
-
Company