From 50360307630d8fc4c555d6b2ff2f292c78e96f26 Mon Sep 17 00:00:00 2001 From: "aag (OpenERP)" Date: Thu, 6 Jan 2011 17:47:55 +0530 Subject: [PATCH] [FIX] stock:ON Cancel Inventory cancel account move lp bug: https://launchpad.net/bugs/458901 fixed bzr revid: aag@tinyerp.co.in-20110106121755-a86ls9pynldwwg79 --- addons/stock/stock.py | 18 +++++++++--------- addons/stock/stock_view.xml | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 656f3e0c1b9..3cc75fe5c2d 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2559,33 +2559,33 @@ class stock_inventory(osv.osv): self.write(cr, uid, [inv.id], {'state': 'confirm', 'move_ids': [(6, 0, move_ids)]}) return True - def action_cancel(self, cr, uid, ids, context=None): - """ Cancels the stock move and change inventory state to draft. + def action_cancel_inventary(self, cr, uid, ids, context=None): + """ Cancels both stock move and inventory @return: True """ move_obj = self.pool.get('stock.move') account_move_obj = self.pool.get('account.move') for inv in self.browse(cr, uid, ids, context=context): - move_obj.action_cancel(cr, uid, [x.id for x in inv.move_ids], context) + move_obj.action_cancel(cr, uid, [x.id for x in inv.move_ids],context=context) for move in inv.move_ids: account_move_ids = account_move_obj.search(cr, uid, [('name','=',move.name)]) if account_move_ids: - account_move_data_l = account_move_obj.read(cr, uid, account_move_ids, ['state']) + account_move_data_l = account_move_obj.read(cr, uid, account_move_ids, ['state'],context=context) for account_move in account_move_data_l: if account_move['state'] == 'posted': raise osv.except_osv(_('UserError'), _('You can not cancel inventory which has any account move with posted state.')) - account_move_obj.unlink(cr, uid, [account_move['id']]) - self.write(cr, uid, [inv.id], {'state': 'draft'}) + account_move_obj.unlink(cr, uid, [account_move['id']],context=context) + self.write(cr, uid, [inv.id], {'state': 'cancel'},context=context) return True - def action_cancel_inventary(self, cr, uid, ids, context=None): - """ Cancels both stock move and inventory + def action_cancel_draft(self, cr, uid, ids, context=None): + """ Cancels the stock move and change inventory state to draft. @return: True """ for inv in self.browse(cr, uid, ids, context=context): self.pool.get('stock.move').action_cancel(cr, uid, [x.id for x in inv.move_ids], context) - self.write(cr, uid, [inv.id], {'state':'cancel'}) + self.write(cr, uid, [inv.id], {'state':'draft'}) return True stock_inventory() diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index 9e1ff3e67f0..85c1231b75a 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -174,7 +174,7 @@