[FIX] stock:Cancelling periodic inventory is now cancel account move
lp bug: https://launchpad.net/bugs/458901 fixed bzr revid: aag@tinyerp.co.in-20110103104933-qip7fqkxbl5gyaar
This commit is contained in:
parent
29f17b697c
commit
b430f760ae
|
@ -2573,8 +2573,19 @@ class stock_inventory(osv.osv):
|
|||
""" Cancels the stock move and change inventory state to draft.
|
||||
@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):
|
||||
self.pool.get('stock.move').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)
|
||||
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'])
|
||||
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'})
|
||||
return True
|
||||
|
||||
|
|
|
@ -170,8 +170,8 @@
|
|||
<group col="2" colspan="2">
|
||||
<field name="state"/>
|
||||
</group>
|
||||
<group col="2" colspan="2">
|
||||
<button name="action_cancel_inventary" states="draft" string="Cancel Inventory" type="object" icon="gtk-cancel"/>
|
||||
<group col="3" colspan="2">
|
||||
<button name="action_cancel_inventary" states="draft,confirm,done" string="Cancel Inventory" type="object" icon="gtk-cancel"/>
|
||||
<button name="action_confirm" states="draft" string="Confirm Inventory" type="object" icon="gtk-apply"/>
|
||||
<button name="action_done" states="confirm" string="Validate Inventory" type="object" icon="gtk-jump-to"/>
|
||||
<button name="action_cancel" states="cancel" string="Set to Draft" type="object" icon="gtk-convert"/>
|
||||
|
|
Loading…
Reference in New Issue