--- stock_invoice_onshipping.py 2010-11-18 18:01:33.000000000 +0100 +++ stock_invoice_onshipping.py.new 2010-11-18 18:05:41.000000000 +0100 @@ -81,10 +81,19 @@ invoice_ids = [] for picking in picking_obj.browse(cr, uid, context.get('active_ids', []), context=context): if picking.invoice_state == '2binvoiced': + type = self._get_type(picking) + if type == 'in_invoice': + context.update({'type': 'in_invoice', 'journal_type': 'purchase'}) + elif type == 'in_refund': + context.update({'type': 'in_refund', 'journal_type': 'purchase_refund'}) + elif type == 'out_refund': + context.update({'type': 'out_refund', 'journal_type': 'sale_refund'}) + else: + context.update({'type': 'out_invoice', 'journal_type': 'sale'}) res = picking_obj.action_invoice_create(cr, uid, [picking.id], journal_id = onshipdata_obj['journal_id'], group=onshipdata_obj['group'], - type=self._get_type(picking), + type=type, context=context) invoice_ids.extend(res.values())