I try to install merge.picking modul.
It cannot be use, because drop some exception when check the field.
I hack some parts from the code, and it's will be run, avoiding the problems when the code try to understand what is the diff. between the models.
this is merge_picking.py
def is_compatible_many2one(self, cr, uid, target, merge, context=None):
fields_pool = self.pool.get("ir.model.fields")
fields_search = fields_pool.search(cr, uid, [('ttype','=','many2one'),('model','=','stock.picking'),('relation','<>',self._name)])
failedfields = []
for field in fields_pool.browse(cr, uid, fields_search, context):
# don't handle specialhandlers fields as incompatible
if field.name in self.get_specialhandlers().keys():
continue
# compare fields
related_target_id = getattr(target, field.name)
related_merge_id = getattr(merge, field.name)
if (related_target_id.id != related_merge_id.id):
failedfields.append(field)
failedfields = [] # modify here always be empty
return {'result': (len(failedfields)==0), 'fields': failedfields}
I hack the failed fields and it will be ok. But this code drop the other place also the error, and I cut off also.
def do_target(self, cr, uid, ids, context=None):
# look if we got compatible views
picking_pool = self.pool.get('stock.picking')
found = False
found_incompatible = False
incompatible_notes = _('Near misses:')
for session in self.browse(cr, uid, ids):
# search if there are any compatible merges at all
similiar_ids = picking_pool.search(cr, uid, [('id','<>',session.target_picking_id.id),
('state','=',session.target_picking_id.state),
('type','=',session.target_picking_id.type),
('invoice_state','=',session.target_picking_id.invoice_state),
])
# ensure that many2one relations are compatible
for merge in picking_pool.browse(cr, uid, similiar_ids):
is_compatible = self.is_compatible_many2one(cr, uid, session.target_picking_id, merge, context)
found = True
if (is_compatible['result']):
found = True
else:
found_incompatible = True
for f in is_compatible['fields']:
desc = self.get_fieldname_translation(cr, uid, f, context)
incompatible_notes += "\n" + _('%s: %s (%s) differs.') % (str(merge.name), desc, f.name)
found = True # modify here always be true
found_incompatible = False # modify here always be true
if not found:
if (found_incompatible):
raise osv.except_osv(_('Note'),_('There are no compatible pickings to be merged.') + "\n" + incompatible_notes)
else:
raise osv.except_osv(_('Note'),_('There are no compatible pickings to be merged.'))
return self.return_view(cr, uid, 'merge_picking_form_init', ids[0])
# else:
return self.return_view(cr, uid, 'merge_picking_form_target', ids[0])
Now it can be use under 6,1. I tested it, the code run it without problems.
I think this is safe because some other item can be guarantee what you can merge. Example wizzard domain filtering in merge_picking_view.xml
Now i need to make some modification in sales modul, because when I merge the delivery orders and invoice it, the sales order view progressbar cannot find the items. (never be go on 100%)