From bf119dcff6bc265cfb1f6dde56ce0e004b539cdd Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Wed, 6 Dec 2017 10:51:57 +0100 Subject: [PATCH] [FIX] account: predicting receivable/payable on partner in tests Before this commit, when a localization defined default payable or receivable accounts on partners (like l10n_do does) The reconciliation tests that involve an invoice on the one hand and a payment on the other hand broke just because the accounts of the payment and the one of the invoice did not match After this commit, we force the receivable or payable account to be the partner's (if available) and the tests do not break --- addons/account/tests/test_reconciliation.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/account/tests/test_reconciliation.py b/addons/account/tests/test_reconciliation.py index c0430d720c9..3b0198b3f09 100644 --- a/addons/account/tests/test_reconciliation.py +++ b/addons/account/tests/test_reconciliation.py @@ -19,13 +19,14 @@ class TestReconciliation(AccountingTestCase): self.res_currency_model = self.registry('res.currency') self.res_currency_rate_model = self.registry('res.currency.rate') - self.partner_agrolait_id = self.env.ref("base.res_partner_2").id + partner_agrolait = self.env.ref("base.res_partner_2") + self.partner_agrolait_id = partner_agrolait.id self.currency_swiss_id = self.env.ref("base.CHF").id self.currency_usd_id = self.env.ref("base.USD").id self.currency_euro_id = self.env.ref("base.EUR").id self.env.ref('base.main_company').write({'currency_id': self.currency_euro_id}) - self.account_rcv = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_receivable').id)], limit=1) - self.account_rsa = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_payable').id)], limit=1) + self.account_rcv = partner_agrolait.property_account_receivable_id or self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_receivable').id)], limit=1) + self.account_rsa = partner_agrolait.property_account_payable_id or self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_payable').id)], limit=1) self.product = self.env.ref("product.product_product_4") self.bank_journal_euro = self.env['account.journal'].create({'name': 'Bank', 'type': 'bank', 'code': 'BNK67'})