From 2c58dd113b3ec9e7be8db6c6f1779e23f91d64de Mon Sep 17 00:00:00 2001 From: Maxime Richez Date: Sun, 10 Dec 2017 12:44:40 +0100 Subject: [PATCH] Set inventory lines readonly until inventory date and location are filled Date and location fields are required but become readonly when you start filling lines manually even if those fields are not filled. When you save your inventory, you have to delete all your lines to fill those mandatory fields... issue6978 review36861002 --- inventory.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/inventory.py b/inventory.py index 4fef065412..d422d56bee 100644 --- a/inventory.py +++ b/inventory.py @@ -40,8 +40,12 @@ class Inventory(Workflow, ModelSQL, ModelView): 'stock.location', 'Lost and Found', required=True, domain=[('type', '=', 'lost_found')], states=STATES, depends=DEPENDS) lines = fields.One2Many( - 'stock.inventory.line', 'inventory', 'Lines', states=STATES, - depends=DEPENDS) + 'stock.inventory.line', 'inventory', 'Lines', + states={ + 'readonly': (STATES['readonly'] | ~Eval('location') + | ~Eval('date')), + }, + depends=['location', 'date'] + DEPENDS) company = fields.Many2One('company.company', 'Company', required=True, states={ 'readonly': (Eval('state') != 'draft') | Eval('lines', [0]),