[FIX] sale: Warning when Create invoice from SO

Used case:
Create a SO with invoicing policy based on delivery. Don't deliver
anything and Create invoice for all invoiceable lines.
Result:
There was no invoice created and no warning message.
After the fix:
A warning message is raised when after clicking "Create
invoice",for any reason it doesn't create an invoice.

opw:678567
This commit is contained in:
Goffin Simon
2016-05-30 15:33:02 +02:00
parent 89c35b8c9c
commit d5e478d4f0
3 changed files with 9 additions and 2 deletions
+3
View File
@@ -324,6 +324,9 @@ class SaleOrder(models.Model):
elif line.qty_to_invoice < 0 and final:
line.invoice_line_create(invoices[group_key].id, line.qty_to_invoice)
if not invoices:
raise UserError(_('There is no invoicable line.'))
for invoice in invoices.values():
if not invoice.invoice_line_ids:
raise UserError(_('There is no invoicable line.'))
+3 -1
View File
@@ -2,6 +2,7 @@
from openerp.tests import common
from datetime import datetime
from openerp.exceptions import UserError
class TestSaleMrpFlow(common.TransactionCase):
@@ -356,7 +357,8 @@ class TestSaleMrpFlow(common.TransactionCase):
self.assertTrue(self.so.picking_ids, 'Sale MRP: no picking created for "invoice on delivery" stockable products')
# invoice in on delivery, nothing should be invoiced
self.so.action_invoice_create()
with self.assertRaises(UserError):
self.so.action_invoice_create()
self.assertEqual(self.so.invoice_status, 'no', 'Sale MRP: so invoice_status should be "nothing to invoice" after invoicing')
# deliver partially (1 of each instead of 5), check the so's invoice_status and delivered quantities
+3 -1
View File
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from openerp.addons.sale.tests.test_sale_common import TestSale
from openerp.exceptions import UserError
class TestSaleStock(TestSale):
@@ -102,7 +103,8 @@ class TestSaleStock(TestSale):
del_qties_truth = [2.0 if sol.product_id.type in ['product', 'consu'] else 0.0 for sol in self.so.order_line]
self.assertEqual(del_qties, del_qties_truth, 'Sale Stock: delivered quantities are wrong after partial delivery')
# invoice on delivery: nothing to invoice
self.assertFalse(self.so.action_invoice_create(), 'Sale Stock: there should be nothing to invoice')
with self.assertRaises(UserError):
self.so.action_invoice_create()
def test_02_sale_stock_return(self):
"""