From b4e25ccf730e8c945f862d40c9f49cfb6d00519a Mon Sep 17 00:00:00 2001 From: lreficent Date: Fri, 8 Sep 2017 13:55:59 +0200 Subject: [PATCH] cycle_count: fix cycle count state issue --- stock_cycle_count/models/stock_inventory.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/stock_cycle_count/models/stock_inventory.py b/stock_cycle_count/models/stock_inventory.py index b3788c077..860ce03a6 100644 --- a/stock_cycle_count/models/stock_inventory.py +++ b/stock_cycle_count/models/stock_inventory.py @@ -34,11 +34,23 @@ class StockInventory(models.Model): string='Accuracy', compute='_compute_inventory_accuracy', digits=(3, 2), store=True, group_operator="avg") + def _update_cycle_state(self): + for inv in self: + if inv.cycle_count_id and inv.state == 'done': + inv.cycle_count_id.state = 'done' + return True + @api.multi def action_done(self): - if self.cycle_count_id: - self.cycle_count_id.state = 'done' - return super(StockInventory, self).action_done() + res = super(StockInventory, self).action_done() + self._update_cycle_state() + return res + + @api.multi + def action_force_done(self): + res = super(StockInventory, self).action_force_done() + self._update_cycle_state() + return res @api.multi def write(self, vals):