From 8dbdbf713f998f6bc3b96c1e5cd838185d6b56d1 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Wed, 28 Nov 2012 12:12:52 +0100 Subject: [PATCH] [FIX] account: pay_and_reconcile() function fixed as per new behavior (accounting entries are created for the parent company if needed) bzr revid: qdp-launchpad@openerp.com-20121128111252-1m37zos11iwg9xyr --- addons/account/account_invoice.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 5a599759f7d..6804d5116f1 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -1245,12 +1245,15 @@ class account_invoice(osv.osv): ref = invoice.reference else: ref = self._convert_ref(cr, uid, invoice.number) + partner = invoice.partner_id + if partner.parent_id and not partner.is_company: + partner = partner.parent_id # Pay attention to the sign for both debit/credit AND amount_currency l1 = { 'debit': direction * pay_amount>0 and direction * pay_amount, 'credit': direction * pay_amount<0 and - direction * pay_amount, 'account_id': src_account_id, - 'partner_id': invoice.partner_id.id, + 'partner_id': partner.id, 'ref':ref, 'date': date, 'currency_id':currency_id, @@ -1261,7 +1264,7 @@ class account_invoice(osv.osv): 'debit': direction * pay_amount<0 and - direction * pay_amount, 'credit': direction * pay_amount>0 and direction * pay_amount, 'account_id': pay_account_id, - 'partner_id': invoice.partner_id.id, + 'partner_id': partner.id, 'ref':ref, 'date': date, 'currency_id':currency_id,