[FIX] account_voucher: avoid error if no partner
The field partner_id is not required on an account.voucher but the validation was failing if none was set (opw 611663). This patch makes a fallback on the account of the voucher if neither a partner nor a writeoff account is specified.
This commit is contained in:
parent
397e83554b
commit
85b08a75f6
|
@ -1337,10 +1337,14 @@ class account_voucher(osv.osv):
|
|||
if voucher.payment_option == 'with_writeoff':
|
||||
account_id = voucher.writeoff_acc_id.id
|
||||
write_off_name = voucher.comment
|
||||
elif voucher.type in ('sale', 'receipt'):
|
||||
elif voucher.partner_id:
|
||||
if voucher.type in ('sale', 'receipt'):
|
||||
account_id = voucher.partner_id.property_account_receivable.id
|
||||
else:
|
||||
account_id = voucher.partner_id.property_account_payable.id
|
||||
else:
|
||||
# fallback on account of voucher
|
||||
account_id = voucher.account_id.id
|
||||
sign = voucher.type == 'payment' and -1 or 1
|
||||
move_line = {
|
||||
'name': write_off_name or name,
|
||||
|
|
Loading…
Reference in New Issue