From ffeca732fb32305110a302002ba038ea9db754ed Mon Sep 17 00:00:00 2001 From: Bertrand Chenal Date: Sat, 25 Oct 2008 15:45:32 +0200 Subject: [PATCH] Internal packing: Added readonly on moves dynamicaly to avoid typing error --- packing.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packing.py b/packing.py index 88264103e9..082665668a 100644 --- a/packing.py +++ b/packing.py @@ -660,15 +660,16 @@ class PackingInternal(OSV): states={'readonly': "state != 'draft'",}) from_location = fields.Many2One( 'stock.location', "From Location", required=True, - states={ 'readonly': "state != 'draft'", }, + states={ 'readonly': "state != 'draft' or bool(moves)", }, domain="[('type', '=', 'storage')]", ) to_location = fields.Many2One('stock.location', "To Location", required=True, states={ - 'readonly': "state != 'draft'", + 'readonly': "state != 'draft' or bool(moves)", }, domain="[('type', '=', 'storage')]") moves = fields.One2Many( 'stock.move', 'packing_internal', 'Moves', - states={'readonly': "state != 'draft'"}, + states={'readonly': "state != 'draft' or "\ + "not(bool(from_location) and bool (to_location))"}, context="{'from_location': from_location," "'to_location': to_location," "'planned_date': planned_date}",