From f9b6f86d379e6c4bc3a0af9ecf7c0448de805470 Mon Sep 17 00:00:00 2001 From: Nikul Chaudhary Date: Thu, 26 Dec 2019 17:20:06 +0530 Subject: [PATCH] [FIX] Fiexed UT --- contract_sale_invoicing/models/contract.py | 2 +- .../tests/test_contract_sale_invoicing.py | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/contract_sale_invoicing/models/contract.py b/contract_sale_invoicing/models/contract.py index 5b83022a..da33eef0 100644 --- a/contract_sale_invoicing/models/contract.py +++ b/contract_sale_invoicing/models/contract.py @@ -43,7 +43,7 @@ class ContractContract(models.Model): return invoices so_domain = rec.get_sale_order_domain() sales = self.env['sale.order'].search(so_domain) - if sales and self.group_by == 'sale_order': + if sales and rec.group_by == 'sale_order': invoice_ids = sales.action_invoice_create() invoices |= self.env['account.invoice'].browse(invoice_ids)[:1] diff --git a/contract_sale_invoicing/tests/test_contract_sale_invoicing.py b/contract_sale_invoicing/tests/test_contract_sale_invoicing.py index 0e0d5134..52df38e7 100644 --- a/contract_sale_invoicing/tests/test_contract_sale_invoicing.py +++ b/contract_sale_invoicing/tests/test_contract_sale_invoicing.py @@ -45,3 +45,32 @@ class TestContractSaleInvoicing(TestContractBase): self.sale_order.action_confirm() self.contract.recurring_create_invoice() self.assertEqual(self.sale_order.invoice_status, 'to invoice') + + def test_contract_sale_invoicing(self): + contract_copy = self.contract.copy({ + 'filter_with': 'contract', + 'group_by': 'contract', + 'invoicing_sales': True + }) + so_val = { + 'date_order': '2016-02-15', + 'contract_id': contract_copy.id + } + sale_order_copy1 = self.sale_order.copy(so_val) + sale_order_copy2 = self.sale_order.copy(so_val) + sale_order_copy1.action_confirm() + sale_order_copy2.action_confirm() + self.env['contract.contract'].cron_recurring_create_invoice() + contract_line_list = [contract_copy.contract_line_ids.id, + self.contract.contract_line_ids.id] + invoice_line = self.env['account.invoice.line'].search([ + ('contract_line_id', 'in', contract_line_list)], order='id asc') + self.assertEqual(invoice_line[0].quantity, 1) + self.assertEqual(invoice_line[0].product_id, + sale_order_copy1.order_line.product_id) + self.assertEqual(invoice_line[1].quantity, 1) + self.assertEqual(invoice_line[1].product_id, + sale_order_copy1.order_line.product_id) + self.assertEqual(invoice_line[2].quantity, 3) + self.assertEqual(invoice_line[2].product_id, + sale_order_copy1.order_line.product_id)