[FIX] account: default partner format

When creating a new account.move.line, the computation of the default values should accept both `id` and `(id, name)` format.
The key partner_id may be containing a tuple so browsing should only be done on the first element of the tuple.
Fixes #3386
This commit is contained in:
Martin Trigaux 2014-10-31 08:38:34 +01:00
parent b8f1ed147e
commit aa9914568b
1 changed files with 7 additions and 2 deletions

View File

@ -274,8 +274,13 @@ class account_move_line(osv.osv):
journal_data = journal_obj.browse(cr, uid, context['journal_id'], context=context)
account = total > 0 and journal_data.default_credit_account_id or journal_data.default_debit_account_id
#map the account using the fiscal position of the partner, if needed
part = data.get('partner_id') and partner_obj.browse(cr, uid, data['partner_id'], context=context) or False
if account and data.get('partner_id'):
if isinstance(data.get('partner_id'), (int, long)):
part = partner_obj.browse(cr, uid, data['partner_id'], context=context)
elif isinstance(data.get('partner_id'), (tuple, list)):
part = partner_obj.browse(cr, uid, data['partner_id'][0], context=context)
else:
part = False
if account and part:
account = fiscal_pos_obj.map_account(cr, uid, part and part.property_account_position or False, account.id)
account = account_obj.browse(cr, uid, account, context=context)
data['account_id'] = account and account.id or False