From cd73bc33e988ada6986d75d9efcd5c807dece741 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 4 Aug 2008 19:16:01 +0200 Subject: [PATCH] Set location and company readonly when there is inventory lines --- inventory.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/inventory.py b/inventory.py index 020ad8423f..e2a128aa33 100644 --- a/inventory.py +++ b/inventory.py @@ -17,7 +17,9 @@ class Inventory(OSV): location = fields.Many2One( 'stock.location', 'Location', required=True, - domain="[('type', '=', 'storage')]", states=STATES) + domain="[('type', '=', 'storage')]", states={ + 'readonly': "state != 'open' or bool(lines)", + }) date = fields.Date('Date') lost_found = fields.Many2One( 'stock.location', 'Lost and Found', required=True, @@ -28,7 +30,9 @@ class Inventory(OSV): 'stock.move', 'inventory_move_rel', 'inventory', 'move', 'Generated moves') company = fields.Many2One( - 'company.company', 'Company', required=True, states=STATES) + 'company.company', 'Company', required=True, states={ + 'readonly': "state != 'open' or bool(lines)", + }) state = fields.Selection(