details: https://code.tryton.org/tryton/commit/918e2afe7c97
branch: default
user: Cédric Krier <[email protected]>
date: Thu Jul 16 11:04:37 2026 +0200
description:
Make locations readonly on stock move when linked to a shipment without
being edited from it
This ensures that the domain from the shipment fields can not be
skipped.
Closes #12564
diffstat:
modules/stock/move.py | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
diffs (42 lines):
diff -r 1e6c3426d11d -r 918e2afe7c97 modules/stock/move.py
--- a/modules/stock/move.py Thu Jul 16 11:03:16 2026 +0200
+++ b/modules/stock/move.py Thu Jul 16 11:04:37 2026 +0200
@@ -18,7 +18,7 @@
from trytond.model.exceptions import AccessError
from trytond.modules.product import price_digits, round_price
from trytond.pool import Pool
-from trytond.pyson import Bool, Eval, Id, If, TimeDelta
+from trytond.pyson import Bool, Equal, Eval, Id, If, TimeDelta
from trytond.tools import cached_property
from trytond.transaction import Transaction, without_check_access
@@ -237,7 +237,13 @@
])
from_location = fields.Many2One(
'stock.location', "From Location",
- required=True, states=STATES,
+ required=True,
+ states={
+ 'readonly': (
+ STATES['readonly']
+ | (Eval('shipment')
+ & Equal(Eval('_parent_shipment.id', None), None))),
+ },
domain=[
LOCATION_DOMAIN,
('id', '!=', Eval('to_location', -1)),
@@ -256,7 +262,13 @@
'on_change_with_from_location_name')
to_location = fields.Many2One(
'stock.location', "To Location",
- required=True, states=STATES,
+ required=True,
+ states={
+ 'readonly': (
+ STATES['readonly']
+ | (Eval('shipment')
+ & Equal(Eval('_parent_shipment.id', None), None))),
+ },
domain=[
LOCATION_DOMAIN,
('id', '!=', Eval('from_location', -1)),