details: https://code.tryton.org/tryton/commit/8443fa348a0d
branch: default
user: Cédric Krier <[email protected]>
date: Thu Nov 27 16:28:21 2025 +0100
description:
Remove warning for inventory in the future
Since #10591 we can skip the warning of stock move in the future for
newly
created moves.
diffstat:
modules/sale_stock_quantity/tests/scenario_sale_stock_quantity.rst | 8 +-
modules/stock/exceptions.py | 4 -
modules/stock/inventory.py | 28
+---------
modules/stock/message.xml | 3 -
4 files changed, 7 insertions(+), 36 deletions(-)
diffs (112 lines):
diff -r 9bbe5251be9e -r 8443fa348a0d
modules/sale_stock_quantity/tests/scenario_sale_stock_quantity.rst
--- a/modules/sale_stock_quantity/tests/scenario_sale_stock_quantity.rst
Thu Nov 27 16:26:20 2025 +0100
+++ b/modules/sale_stock_quantity/tests/scenario_sale_stock_quantity.rst
Thu Nov 27 16:28:21 2025 +0100
@@ -13,7 +13,7 @@
>>> 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 @@
... ['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 @@
>>> 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 -r 9bbe5251be9e -r 8443fa348a0d modules/stock/exceptions.py
--- a/modules/stock/exceptions.py Thu Nov 27 16:26:20 2025 +0100
+++ b/modules/stock/exceptions.py Thu Nov 27 16:28:21 2025 +0100
@@ -36,10 +36,6 @@
pass
-class InventoryFutureWarning(UserWarning):
- pass
-
-
class ProductCostPriceError(ValidationError):
pass
diff -r 9bbe5251be9e -r 8443fa348a0d modules/stock/inventory.py
--- a/modules/stock/inventory.py Thu Nov 27 16:26:20 2025 +0100
+++ b/modules/stock/inventory.py Thu Nov 27 16:28:21 2025 +0100
@@ -15,8 +15,7 @@
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 @@
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 @@
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 -r 9bbe5251be9e -r 8443fa348a0d modules/stock/message.xml
--- a/modules/stock/message.xml Thu Nov 27 16:26:20 2025 +0100
+++ b/modules/stock/message.xml Thu Nov 27 16:28:21 2025 +0100
@@ -119,9 +119,6 @@
<record model="ir.message" id="msg_move_effective_date_in_the_future">
<field name="text">The moves "%(moves)s" have effective dates in
the future.</field>
</record>
- <record model="ir.message" id="msg_inventory_date_in_the_future">
- <field name="text">The inventories "%(inventories)s" have dates in
the future.</field>
- </record>
<record model="ir.message" id="msg_stock_reporting_company">
<field name="text">Company</field>
</record>