From 82fbe03ff8af3aeb15920499bb6f294025e92db2 Mon Sep 17 00:00:00 2001 From: Jordi Ballester Date: Wed, 15 Mar 2017 13:25:12 +0100 Subject: [PATCH] [FIX] purchase: update tests to effectively create invoices of type purchase, not Default value is out_invoice aka an invoice of type sale. However here we would like to test invoices of type purchase. Otherwise extending tests for specific purchase-related invoice code is not possible. This is done using the magical context key type. Closes #15886 --- addons/purchase/tests/test_purchase_order.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/addons/purchase/tests/test_purchase_order.py b/addons/purchase/tests/test_purchase_order.py index 88848cfcdb1..4c723b320cb 100644 --- a/addons/purchase/tests/test_purchase_order.py +++ b/addons/purchase/tests/test_purchase_order.py @@ -76,10 +76,11 @@ class TestPurchaseOrder(AccountingTestCase): self.picking.do_new_transfer() self.assertEqual(self.po.order_line.mapped('qty_received'), [5.0, 5.0], 'Purchase: all products should be received"') - self.invoice = self.AccountInvoice.create({ - 'partner_id': self.partner_id.id, - 'purchase_id': self.po.id, - 'account_id': self.partner_id.property_account_payable_id.id, - }) + self.invoice = self.AccountInvoice.with_context( + type='in_invoice').create({ + 'partner_id': self.partner_id.id, + 'purchase_id': self.po.id, + 'account_id': self.partner_id.property_account_payable_id.id, + }) self.invoice.purchase_order_change() self.assertEqual(self.po.order_line.mapped('qty_invoiced'), [5.0, 5.0], 'Purchase: all products should be invoiced"')