[IMP] stock: Improve the Merge inventories wizard put the warning to use in list view

bzr revid: sbh@tinyerp.com-20100909130311-n51aas1gcgpf09kx
This commit is contained in:
sbh (Open ERP)
2010-09-09 18:33:11 +05:30
parent 5feb1fd1e1
commit 52b56ef04a
+19 -7
View File
@@ -25,7 +25,25 @@ from tools.translate import _
class stock_inventory_merge(osv.osv_memory):
_name = "stock.inventory.merge"
_description = "Merge Inventory"
def fields_view_get(self, cr, uid, view_id=None, view_type='form',
context=None, toolbar=False, submenu=False):
"""
Changes the view dynamically
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param context: A standard dictionary
@return: New arch of view.
"""
if not context:
context={}
res = super(stock_inventory_merge, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False)
if context.get('active_model','') == 'stock.inventory' and len(context['active_ids']) < 2:
raise osv.except_osv(_('Warning'),
_('Please select multiple physical inventories to merge in the list view.'))
return res
def do_merge(self, cr, uid, ids, context):
""" To merge selected Inventories.
@param self: The object pointer.
@@ -37,13 +55,7 @@ class stock_inventory_merge(osv.osv_memory):
"""
invent_obj = self.pool.get('stock.inventory')
invent_line_obj = self.pool.get('stock.inventory.line')
invent_lines = {}
if len(context['active_ids']) < 2:
raise osv.except_osv(_('Warning'),
_('Please select at least two inventories.'))
for inventory in invent_obj.browse(cr, uid, context['active_ids'], context=context):
if inventory.state == "done":
raise osv.except_osv(_('Warning'),