summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Ledoux <dle@odoo.com>2014-11-27 13:25:54 +0100
committerDenis Ledoux <dle@odoo.com>2014-11-27 13:26:57 +0100
commit2080ea0f0acfb0e03372e8abd264a5fb72d7d431 (patch)
tree883c9419a03e9d828152c2a386be077f2d83e08f
parent043f7b84b83ec0c40274af30e2731b1c05c3d520 (diff)
[FIX] stock: on stock picking invoicing, allow to pick a journal if no move line
-rw-r--r--addons/stock/wizard/stock_invoice_onshipping.py35
1 files changed, 18 insertions, 17 deletions
diff --git a/addons/stock/wizard/stock_invoice_onshipping.py b/addons/stock/wizard/stock_invoice_onshipping.py
index 7c960c5e617..ed559d1e341 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: