From ac0f2c94c5ebf37540f7854da5ce2b8e25030082 Mon Sep 17 00:00:00 2001 From: Mateu Griful Date: Fri, 17 Dec 2021 12:40:19 +0100 Subject: [PATCH] [14.0][IMP] stock_cycle_count: check modify --- stock_cycle_count/models/stock_inventory.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/stock_cycle_count/models/stock_inventory.py b/stock_cycle_count/models/stock_inventory.py index 210c02dec..15b187f78 100644 --- a/stock_cycle_count/models/stock_inventory.py +++ b/stock_cycle_count/models/stock_inventory.py @@ -90,11 +90,7 @@ class StockInventory(models.Model): def write(self, vals): for inventory in self: - if ( - inventory.cycle_count_id - and "state" not in vals.keys() - and inventory.state == "draft" - ): + if inventory._allow_write(vals): raise UserError( _( "You cannot modify the configuration of an Inventory " @@ -102,3 +98,8 @@ class StockInventory(models.Model): ) ) return super(StockInventory, self).write(vals) + + def _allow_write(self, vals): + return ( + self.cycle_count_id and "state" not in vals.keys() and self.state == "draft" + )