From 2080ea0f0acfb0e03372e8abd264a5fb72d7d431 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Thu, 27 Nov 2014 13:25:54 +0100 Subject: [PATCH] [FIX] stock: on stock picking invoicing, allow to pick a journal if no move line --- addons/stock/wizard/stock_invoice_onshipping.py | 35 ++++++++++++----------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/addons/stock/wizard/stock_invoice_onshipping.py b/addons/stock/wizard/stock_invoice_onshipping.py index 7c960c5..ed559d1 100644 --- a/addons/stock/wizard/stock_invoice_onshipping.py +++ b/addons/stock/wizard/stock_invoice_onshipping.py @@ -46,23 +46,24 @@ class stock_invoice_onshipping(osv.osv_memory): browse_picking = model_pool.browse(cr, uid, res_ids, context=context) for pick in browse_picking: - if not pick.move_lines: - continue - src_usage = pick.move_lines[0].location_id.usage - dest_usage = pick.move_lines[0].location_dest_id.usage - type = pick.type - if type == 'out' and dest_usage == 'supplier': - journal_type = 'purchase_refund' - elif type == 'out' and dest_usage == 'customer': - journal_type = 'sale' - elif type == 'in' and src_usage == 'supplier': - journal_type = 'purchase' - elif type == 'in' and src_usage == 'customer': - journal_type = 'sale_refund' - else: - journal_type = 'sale' - - value = journal_obj.search(cr, uid, [('type', '=',journal_type )]) + domain = [('type', 'in', ['sale', 'sale_refund', 'purchase', 'purchase_refund'])] + if pick.move_lines: + src_usage = pick.move_lines[0].location_id.usage + dest_usage = pick.move_lines[0].location_dest_id.usage + type = pick.type + if type == 'out' and dest_usage == 'supplier': + journal_type = 'purchase_refund' + elif type == 'out' and dest_usage == 'customer': + journal_type = 'sale' + elif type == 'in' and src_usage == 'supplier': + journal_type = 'purchase' + elif type == 'in' and src_usage == 'customer': + journal_type = 'sale_refund' + else: + journal_type = 'sale' + domain = [('type', '=', journal_type)] + + value = journal_obj.search(cr, uid, domain) for jr_type in journal_obj.browse(cr, uid, value, context=context): t1 = jr_type.id,jr_type.name if t1 not in vals: -- 1.7.10.4