This question has been flagged

I have a custom module that marks pickings to done. On pickings with more multiple lines, I'm getting extra stock moves that have "Extra Move" in the description. If I have two lines on a picking, I'll get the correct stock move for each line, plus one "Extra Move" for each line. If I have three line on a picking, I'll get the correct stock move for each line, plus TWO "Extra Move"s for each line.
I don't understand what an "Extra Move" is or what it's use case is. I also don't know if this is a bug in my module, or elsewhere.
My code is as follows;

Sorry about he formatting, but the forums screws with every attempt to paste and format the code.

# Get the stock picking that the row refers totock_picking = (self.env["stock.picking"].search([("name", "=", stock_picking_ref)]))# Insert a new request record and retrive a reference to it request_id = self.env["integration.request"].create({'request_type':self.id,'reference':stock_picking.name,'name':stock_picking.name,'stock_pick':stock_picking.id,'state':'In Progress'})# Ensure we don't mess with pickings already doneif stock_picking.state == 'assigned':
    # Update stock picking with carrier and tracking information    stock_picking.write({'carrier_tracking_ref': tracking_no,'shipped_date': date,'shipped_weight': weight,'shipped_cost': carriage_cost})    for pack in stock_picking.pack_operation_ids:
        if pack.product_qty > 0:
            # Set transfered quantities to transfer all            pack.write({'qty_done': pack.product_qty})            self.env["integration.request_item"].create({'request':request_id.id, 'product':pack.product_id.id, 'quantity':pack.product_qty})    else:
        pack.unlink()    stock_picking.do_transfer()

Avatar
Discard
Author

Please ignore this post. The problem was in my custom module with the do_transfer() being called for each picking item rather than each picking.