credativ team mailing list archive
-
credativ team
-
Mailing list archive
-
Message #06144
[Branch ~credativ/openobject-addons/6.1] Rev 7072: [FIX] Default journal on purchase-related invoices now respects ir_values defaults.
------------------------------------------------------------
revno: 7072
committer: Tom Pickering <tom.pickering@xxxxxxxxxxxxxx>
branch nick: addons
timestamp: Fri 2015-07-03 09:46:28 +0100
message:
[FIX] Default journal on purchase-related invoices now respects ir_values defaults.
modified:
purchase/purchase.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 'purchase/purchase.py'
--- purchase/purchase.py 2015-01-12 12:48:37 +0000
+++ purchase/purchase.py 2015-07-03 08:46:28 +0000
@@ -340,11 +340,18 @@
inv_line_obj = self.pool.get('account.invoice.line')
fiscal_obj = self.pool.get('account.fiscal.position')
property_obj = self.pool.get('ir.property')
+ ir_values_obj = self.pool.get('ir.values')
for order in self.browse(cr, uid, ids, context=context):
pay_acc_id = order.partner_id.property_account_payable.id
- journal_ids = journal_obj.search(cr, uid, [('type', '=','purchase'),('company_id', '=', order.company_id.id)], limit=1)
- if not journal_ids:
+ journal_ids = journal_obj.search(cr, uid, [('type', '=','purchase'),('company_id', '=', order.company_id.id)])
+ res_journal_default = ir_values_obj.get(cr, uid, 'default', 'type=in_invoice', ['account.invoice'])
+ journal_id = None
+ 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 purchase journal defined for this company: "%s" (id:%d)') % (order.company_id.name, order.company_id.id))
@@ -378,7 +385,7 @@
'currency_id': order.pricelist_id.currency_id.id,
'address_invoice_id': order.partner_address_id.id,
'address_contact_id': order.partner_address_id.id,
- 'journal_id': len(journal_ids) and journal_ids[0] or False,
+ 'journal_id': journal_id,
'invoice_line': [(6, 0, inv_lines)],
'origin': order.name,
'fiscal_position': order.fiscal_position.id or order.partner_id.property_account_position.id,