Multi Company - Create Quotation with Discount throws error

OpenERP Configuration

Group Company
->Sub Company1 (User - SubCompany1User)
 ->Cash (Sub Company1) - (Journal Config - Accounting->Configuration->Journals->Journals)
 ->D01-Lump Sum-Discount (Account head for discount - Accounting->Configuration->Accounts->Accounts)
->Sub Company2 (User - SubCompany2User)
 ->Cash (Sub Company1) - (Journal Config - Accounting->Configuration->Journals->Journals)
 ->D01-Lump Sum-Discount (Account head for discount - Accounting->Configuration->Accounts->Accounts)

Requirement: Users should be able to create quotation for the associated company with discount.

Issue: When SubCompany1User user logs in and creates Quotation with discount head D01 and confirms the sale it gives error

File "/usr/lib/python2.6/site-packages/openerp-7.0_20130301_002301-py2.6.egg/openerp/addons/bahmni_sale_discount/invoice.py", line 256, in _update_discount_head
acc_journal_id = self.pool.get('account.journal').search(cr, uid,[('name','=','Cash')])[0]
IndexError: list index out of range.

Reproducible - To reproduce this on Demo - Change Journal name “Cash” to “PettyCash” and create quotation with discount and confirm.

Reason: This line has hardcoded the name of journal as “Cash” whereas in our config the the journal “Cash” has company name as suffix.

acc_journal_id = self.pool.get('account.journal').search(cr, uid,[('name','=','Cash')])[0]The newly synced customer has Company set to Group Company.

Possible Solutions:

  1. No Code Change: Keep all Cash journals as “Cash” and do not change the name.

  2. Code Change: Change this line to

    acc_journal_id = self.pool.get('account.journal').search(cr, uid,[('name','ilike','Cash')])[0]