[FIX] account: recursively find proper partner to link to journal items, as discussed in bugs 1160365 and 1151947
lp bug: https://launchpad.net/bugs/1160365 fixed lp bug: https://launchpad.net/bugs/1151947 fixed bzr revid: odo@openerp.com-20130407212333-34jahthhppcz2wju
This commit is contained in:
parent
eb3ffc52ed
commit
ad1650854e
|
@ -1260,9 +1260,7 @@ class account_invoice(osv.osv):
|
||||||
ref = invoice.reference
|
ref = invoice.reference
|
||||||
else:
|
else:
|
||||||
ref = self._convert_ref(cr, uid, invoice.number)
|
ref = self._convert_ref(cr, uid, invoice.number)
|
||||||
partner = invoice.partner_id
|
partner = self.pool['res.partner']._find_accounting_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
|
# Pay attention to the sign for both debit/credit AND amount_currency
|
||||||
l1 = {
|
l1 = {
|
||||||
'debit': direction * pay_amount>0 and direction * pay_amount,
|
'debit': direction * pay_amount>0 and direction * pay_amount,
|
||||||
|
@ -1733,15 +1731,17 @@ class res_partner(osv.osv):
|
||||||
'invoice_ids': fields.one2many('account.invoice.line', 'partner_id', 'Invoices', readonly=True),
|
'invoice_ids': fields.one2many('account.invoice.line', 'partner_id', 'Invoices', readonly=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
def _find_accounting_partner(self, part):
|
def _find_accounting_partner(self, partner):
|
||||||
'''
|
'''
|
||||||
Find the partner for which the accounting entries will be created
|
Find the partner for which the accounting entries will be created
|
||||||
'''
|
'''
|
||||||
|
# FIXME: after 7.0, to replace by function field partner.commercial_id
|
||||||
|
|
||||||
#if the chosen partner is not a company and has a parent company, use the parent for the journal entries
|
#if the chosen partner is not a company and has a parent company, use the parent for the journal entries
|
||||||
#because you want to invoice 'Agrolait, accounting department' but the journal items are for 'Agrolait'
|
#because you want to invoice 'Agrolait, accounting department' but the journal items are for 'Agrolait'
|
||||||
if part.parent_id and not part.is_company:
|
while not partner.is_company and partner.parent_id:
|
||||||
part = part.parent_id
|
partner = partner.parent_id
|
||||||
return part
|
return partner
|
||||||
|
|
||||||
def copy(self, cr, uid, id, default=None, context=None):
|
def copy(self, cr, uid, id, default=None, context=None):
|
||||||
default = default or {}
|
default = default or {}
|
||||||
|
|
Loading…
Reference in New Issue