credativ team mailing list archive
-
credativ team
-
Mailing list archive
-
Message #06132
[Branch ~credativ/openobject-addons/6.1] Rev 7065: [FIX] Choose the default sales journal if set in ir.values instead of the first
------------------------------------------------------------
revno: 7065
committer: Craig Gowing (credativ) <craig.gowing@xxxxxxxxxxxxxx>
branch nick: addons
timestamp: Tue 2014-12-30 13:34:57 +0000
message:
[FIX] Choose the default sales journal if set in ir.values instead of the first
modified:
sale/sale.py
--
lp:~credativ/openobject-addons/6.1
https://code.launchpad.net/~credativ/openobject-addons/6.1
Your team credativ is subscribed to branch lp:~credativ/openobject-addons/6.1.
To unsubscribe from this branch go to https://code.launchpad.net/~credativ/openobject-addons/6.1/+edit-subscription
=== modified file 'sale/sale.py'
--- sale/sale.py 2013-10-22 09:35:21 +0000
+++ sale/sale.py 2014-12-30 13:34:57 +0000
@@ -415,10 +415,19 @@
"""
if context is None:
context = {}
- journal_ids = self.pool.get('account.journal').search(cr, uid,
- [('type', '=', 'sale'), ('company_id', '=', order.company_id.id)],
- limit=1)
- if not journal_ids:
+
+ obj_journal = self.pool.get('account.journal')
+ ir_values_obj = self.pool.get('ir.values')
+
+ journal_ids = obj_journal.search(cr, uid, [('company_id','=',order.company_id.id), ('type', '=', 'sale')])
+ journal_id = False
+ res_journal_default = ir_values_obj.get(cr, uid, 'default', 'type=out_invoice', ['account.invoice'])
+ for r in res_journal_default:
+ if r[1] == 'journal_id' and r[2] in journal_ids:
+ journal_id = r[2]
+ journal_id = journal_id or journal_ids and journal_ids[0] or False
+
+ if not journal_id:
raise osv.except_osv(_('Error !'),
_('There is no sales journal defined for this company: "%s" (id:%d)') % (order.company_id.name, order.company_id.id))
@@ -429,7 +438,7 @@
'reference': order.client_order_ref or order.name,
'account_id': order.partner_id.property_account_receivable.id,
'partner_id': order.partner_id.id,
- 'journal_id': journal_ids[0],
+ 'journal_id': journal_id,
'address_invoice_id': order.partner_invoice_id.id,
'address_contact_id': order.partner_order_id.id,
'invoice_line': [(6, 0, lines)],