From 08416b2335f2657c0202d8879c2cf437b02b072f Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Mon, 23 May 2016 14:29:46 +0200 Subject: [PATCH] [FIX] account: partner_id set on a bank fee Used case: -Create several customer invoices and validate them -Register a payment without any partner_id and in a bank statement for an amount a bit lower than the total of the invoice (the difference is the paypal fees) -Reconcile the invoices with the payment and create a write-off for the paypal fees -When you close the bank statement, check the journal items, the paypal fees are automatically assigned with a partner. Fix: -When creating the account move line for the fee, if all the account move lines linked to the move are for different partners then you cannot determine the partner of the fee. opw:674822 --- addons/account/account_move_line.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index e7509edecdc..fe893b9ccbe 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -275,8 +275,9 @@ class account_move_line(osv.osv): #we propose to continue the same move by copying the ref, the name, the partner... move = move_obj.browse(cr, uid, move_id, context=context) data.setdefault('name', move.line_id[-1].name) + same_partner = len({l.partner_id for l in move.line_id}) == 1 for l in move.line_id: - data['partner_id'] = data.get('partner_id') or l.partner_id.id + data['partner_id'] = data.get('partner_id') or (same_partner and l.partner_id.id) data['ref'] = data.get('ref') or l.ref total += (l.debit or 0.0) - (l.credit or 0.0)