From 0da076980aef9519b41373e6eaf17b5481532019 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 8 Sep 2008 19:23:11 +0200 Subject: [PATCH] Set supplier required Add readonly on supplier and warehouse when there is at least on incoming moves --- packing.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packing.py b/packing.py index cc63c0445f..636f69c1e2 100644 --- a/packing.py +++ b/packing.py @@ -24,14 +24,18 @@ class PackingIn(OSV): states={'readonly': "state != 'draft'",}) supplier = fields.Many2One('relationship.party', 'Supplier', states={ - 'readonly': "state != 'draft'", - }, on_change=['supplier']) + 'readonly': "state != 'draft' or bool(incoming_moves)", + }, on_change=['supplier'], required=True) contact_address = fields.Many2One('relationship.address', 'Contact Address', states={ 'readonly': "state != 'draft'", }, domain="[('party', '=', supplier)]") warehouse = fields.Many2One('stock.location', "Warehouse", - required=True, states=STATES, domain="[('type', '=', 'warehouse')]") + required=True, domain="[('type', '=', 'warehouse')]", + states={ + 'readonly': "state in ('cancel', 'done') or " \ + "bool(incoming_moves)", + }) incoming_moves = fields.Function('get_incoming_moves', type='one2many', relation='stock.move', string='Incoming Moves', fnct_inv='set_incoming_moves', add_remove="[" \