[FIX] Stock : Creation of invoice from picking should respect the journal and its view over opened invoice

lp bug: https://launchpad.net/bugs/724198 fixed

bzr revid: jvo@tinyerp.com-20110310123623-26cw8ewgr22fr0j2
This commit is contained in:
JMA(OpenERP) 2011-03-10 18:06:23 +05:30 committed by Jay Vora (OpenERP)
parent 126fec64ff
commit 4e7c00fa4d
1 changed files with 23 additions and 21 deletions

View File

@ -34,41 +34,43 @@ class stock_invoice_onshipping(osv.osv_memory):
return [] return []
model_pool = self.pool.get(model) model_pool = self.pool.get(model)
acct_obj = self.pool.get('account.journal') journal_obj = self.pool.get('account.journal')
res_ids = context and context.get('active_ids', []) res_ids = context and context.get('active_ids', [])
vals=[] vals = []
pick_types = list(set(map(lambda x: x.type, model_pool.browse(cr, uid, res_ids, context=context)))) browse_picking = model_pool.browse(cr, uid, res_ids, context=context)
for type in pick_types:
if type == 'out': for pick in browse_picking:
value = acct_obj.search(cr, uid, [('type', 'in',('sale','purchase_refund') )]) src_usage = pick.move_lines[0].location_id.usage
for jr_type in acct_obj.browse(cr, uid, value, context=context): dest_usage = pick.move_lines[0].location_dest_id.usage
t1 = jr_type.id,jr_type.name type = pick.type
vals.append(t1) if type == 'out' and dest_usage == 'supplier':
journal_type = 'purchase_refund'
elif type == 'in': elif type == 'out' and dest_usage == 'customer':
value = acct_obj.search(cr, uid, [('type', 'in',('purchase','sale_refund') )]) journal_type = 'sale'
for jr_type in acct_obj.browse(cr, uid, value, context=context): elif type == 'in' and src_usage == 'supplier':
t1 = jr_type.id,jr_type.name journal_type = 'purchase'
vals.append(t1) elif type == 'in' and src_usage == 'customer':
journal_type = 'sale_refund'
else: else:
value = acct_obj.search(cr, uid, [('type', 'in',('cash','bank','general','situation') )]) journal_type = 'sale'
for jr_type in acct_obj.browse(cr, uid, value, context=context):
t1 = jr_type.id,jr_type.name value = journal_obj.search(cr, uid, [('type', '=',journal_type )])
vals.append(t1) for jr_type in journal_obj.browse(cr, uid, value, context=context):
t1 = jr_type.id,jr_type.name
if t1 not in vals:
vals.append(t1)
return vals return vals
_name = "stock.invoice.onshipping" _name = "stock.invoice.onshipping"
_description = "Stock Invoice Onshipping" _description = "Stock Invoice Onshipping"
_columns = { _columns = {
'journal_id': fields.selection(_get_journal_id, 'Destination Journal',required=True), 'journal_id': fields.selection(_get_journal_id, 'Destination Journal',required=True),
'group': fields.boolean("Group by partner"), 'group': fields.boolean("Group by partner"),
'invoice_date': fields.date('Invoiced date'), 'invoice_date': fields.date('Invoiced date'),
} }
def view_init(self, cr, uid, fields_list, context=None): def view_init(self, cr, uid, fields_list, context=None):
if context is None: if context is None:
context = {} context = {}