self.assertEqual(sale_line_deli.amt_to_invoice,0.0,'Amount to invoice for delivered qty SO line should zero, since its state is draft')
self.assertEqual(sale_line_deli.amt_invoiced,0.0,'Amount invoiced for delivered qty SO line should zero, since its state is draft, and there is no invoice at this moment')
self.assertEqual(sale_line_ord.amt_to_invoice,0.0,'Amount to invoice for ordered qty SO line should zero, since its state is draft')
self.assertEqual(sale_line_ord.amt_invoiced,0.0,'Amount invoiced for ordered qty SO line should zero, since its state is draft, and there is no invoice at this moment')
# confirm SO
order.action_confirm()
self.assertEqual(sale_line_deli.amt_to_invoice,0.0,'Amount to invoice for delivered SO line is still zero, since its delivered quantity is zero')
self.assertEqual(sale_line_deli.amt_invoiced,0.0,'Amount invoiced for delivered SO line is still zero, since its delivered quantity is zero, and there is no invoice at this moment')
self.assertEqual(sale_line_ord.amt_to_invoice,40.0,'Amount to invoice for ordered SO line should be 40, even if there is no invoice')
self.assertEqual(sale_line_ord.amt_invoiced,0.0,'Amount invoiced for ordered SO line should zero, there is no invoice at this moment')
self.assertEqual(sale_line_deli.amt_to_invoice,0.0,'Amount to invoice for delivered SO line is still zero, since its delivered quantity (on SO line) is zero')
self.assertEqual(sale_line_deli.amt_invoiced,0.0,'Amount invoiced for delivered SO line is still zero, since its delivered quantity (on SO line) is zero, and there is no invoice at this moment')
self.assertEqual(sale_line_ord.amt_to_invoice,40.0,'Amount to invoice for ordered SO line should be 40, since there is a draft invoice')
self.assertEqual(sale_line_ord.amt_invoiced,0.0,'Amount invoiced for ordered SO line should zero, there is no validated invoice at this moment')
# validate invoice
invoice_1.invoice_validate()
self.assertEqual(sale_line_deli.amt_to_invoice,0.0,'Amount to invoice for delivered SO line is still zero, since its delivered quantity (on SO line) is zero')
self.assertEqual(sale_line_deli.amt_invoiced,0.0,'Amount invoiced for delivered SO line is still zero, since its delivered quantity (on SO line) is zero, and there is no invoice at this moment')
self.assertEqual(sale_line_ord.amt_to_invoice,0.0,'Amount to invoice for ordered SO line is zero, since the invoice is validated')
self.assertEqual(sale_line_ord.amt_invoiced,40.0,'Amount invoiced for ordered SO line should 40, there is a validated invoice at this moment')
# deliver 2 unit of product_deli
sale_line_deli.write({'qty_delivered':2})
self.assertEqual(sale_line_deli.amt_to_invoice,1000.0,'Amount to invoice for delivered SO line is now 1000, since its delivered quantity (on SO line) is 2 (unit price = 500)')
self.assertEqual(sale_line_deli.amt_invoiced,0.0,'Amount invoiced for delivered SO line is still zero, since there is no invoice at this moment for this product')
self.assertEqual(sale_line_ord.amt_to_invoice,0.0,'Amount to invoice for ordered SO line is zero, since the invoice is validated')
self.assertEqual(sale_line_ord.amt_invoiced,40.0,'Amount invoiced for ordered SO line should 40, there is a validated invoice at this moment')
self.assertEqual(sale_line_deli.amt_to_invoice,0.0,'Amount to invoice for delivered SO line is 0, since this is all invoiced')
self.assertEqual(sale_line_deli.amt_invoiced,1000.0,'Amount invoiced for delivered SO line is now 1000, since the invoice for this product is validated')
self.assertEqual(sale_line_ord.amt_to_invoice,0.0,'Amount to invoice for ordered SO line is zero, since the invoice is validated')
self.assertEqual(sale_line_ord.amt_invoiced,40.0,'Amount invoiced for ordered SO line should 40, there is a validated invoice at this moment')
self.assertEqual(sale_line_deli.amt_to_invoice,0.0,'Amount to invoice for delivered SO line is now 0: nothing should change as the invoice is in draft state')
self.assertEqual(sale_line_deli.amt_invoiced,1000.0,'Amount invoiced for delivered SO line is still 1000, even if we change price of unvalidated invoice')
self.assertEqual(sale_line_ord.amt_to_invoice,0.0,'Amount to invoice for ordered SO line is zero, since the invoice is validated')
self.assertEqual(sale_line_ord.amt_invoiced,40.0,'Amount invoiced for ordered SO line should 40, there is a validated invoice at this moment')
# validate third invoice
invoice_3.invoice_validate()
self.assertEqual(sale_line_deli.amt_to_invoice,0.0,'Amount to invoice for delivered SO line is now 0, since SO is cancel')
self.assertEqual(sale_line_deli.amt_invoiced,1300.0,'Amount invoiced for delivered SO line is incremented, since the 3rd invoice for this product is validated')
self.assertEqual(sale_line_ord.amt_to_invoice,0.0,'Amount to invoice for ordered SO line is zero, since the invoice is validated')
self.assertEqual(sale_line_ord.amt_invoiced,40.0,'Amount invoiced for ordered SO line should 40, there is a validated invoice at this moment')