Skip to content

Instantly share code, notes, and snippets.

@josemoralesp
Created January 18, 2017 04:12
Show Gist options
  • Save josemoralesp/81fe601ea1048b4e51a2a32095fc8e0d to your computer and use it in GitHub Desktop.
Save josemoralesp/81fe601ea1048b4e51a2a32095fc8e0d to your computer and use it in GitHub Desktop.
def validate_pickings(self, pickings):
"""Method used to validate pickings no matter the number of steps used in the picking process
"""
pick = pickings.filtered(lambda a: a.state in ('confirmed', 'assigned'))
# Confirming Pick
pick.action_confirm()
pick.action_assign()
value = self.trans.\
with_context({'active_model': 'stock.picking',
'active_id': pick.id,
'active_ids': [pick.id]}).default_get([])
line = []
for ope in value.get('item_ids', []):
line.append((0, 0, ope))
value['item_ids'] = line
value['picking_id'] = pick.id
# Creating an object of the pack window
trans_id = self.trans.create(value)
# Validating wizard
trans_id.do_detailed_transfer()
self.assertEqual(pick.state, 'done', 'The pick was not validated')
return pickings.filtered(lambda a: a.state in ('confirmed', 'assigned')) and validate_pickings(pickings) or pickings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment