Browse Source

[FIX] Fiexed UT

pull/437/head
Nikul Chaudhary 5 years ago
parent
commit
f9b6f86d37
  1. 2
      contract_sale_invoicing/models/contract.py
  2. 29
      contract_sale_invoicing/tests/test_contract_sale_invoicing.py

2
contract_sale_invoicing/models/contract.py

@ -43,7 +43,7 @@ class ContractContract(models.Model):
return invoices return invoices
so_domain = rec.get_sale_order_domain() so_domain = rec.get_sale_order_domain()
sales = self.env['sale.order'].search(so_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() invoice_ids = sales.action_invoice_create()
invoices |= self.env['account.invoice'].browse(invoice_ids)[:1] invoices |= self.env['account.invoice'].browse(invoice_ids)[:1]

29
contract_sale_invoicing/tests/test_contract_sale_invoicing.py

@ -45,3 +45,32 @@ class TestContractSaleInvoicing(TestContractBase):
self.sale_order.action_confirm() self.sale_order.action_confirm()
self.contract.recurring_create_invoice() self.contract.recurring_create_invoice()
self.assertEqual(self.sale_order.invoice_status, 'to 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)
Loading…
Cancel
Save