From b5ff541e5226904a904de8e5712a238bad2e50c2 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Sun, 13 Sep 2015 18:38:53 +0200 Subject: [PATCH] [IMP] Invoice from SO semantic (manually select with or without refunds) --- addons/sale/sale.py | 2 +- addons/sale/wizard/sale_make_invoice_advance.py | 4 ++-- addons/sale/wizard/sale_make_invoice_advance.xml | 6 ------ addons/sale_stock/tests/test_sale_stock.py | 2 +- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 35a85611c59..8ddad4aa6c5 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -261,7 +261,7 @@ class SaleOrder(models.Model): invoices[group_key] = invoice if line.qty_to_invoice > 0: line.invoice_line_create(invoices[group_key].id, line.qty_to_invoice) - elif line.qty_to_invoice < 0 and (final or invoices[group_key].amount_untaxed > abs(line.qty_to_invoice * line.price_unit)): + elif line.qty_to_invoice < 0 and final: line.invoice_line_create(invoices[group_key].id, line.qty_to_invoice) for invoice in invoices.values(): diff --git a/addons/sale/wizard/sale_make_invoice_advance.py b/addons/sale/wizard/sale_make_invoice_advance.py index 54b110574c9..d2b58d72c12 100644 --- a/addons/sale/wizard/sale_make_invoice_advance.py +++ b/addons/sale/wizard/sale_make_invoice_advance.py @@ -32,8 +32,8 @@ class SaleAdvancePaymentInv(models.TransientModel): return False advance_payment_method = fields.Selection([ - ('all', 'Invoiceable lines'), - ('delivered', 'Invoiceable lines (without refunds)'), + ('all', 'Invoiceable lines (deduce deposits)'), + ('delivered', 'Invoiceable lines'), ('percentage', 'Deposit (percentage)'), ('fixed', 'Deposit (fixed amount)') ], string='What do you want to invoice?', default=_get_advance_payment_method, required=True) diff --git a/addons/sale/wizard/sale_make_invoice_advance.xml b/addons/sale/wizard/sale_make_invoice_advance.xml index c1c2c19f8d5..c8eb0f66906 100644 --- a/addons/sale/wizard/sale_make_invoice_advance.xml +++ b/addons/sale/wizard/sale_make_invoice_advance.xml @@ -27,17 +27,11 @@ attrs="{'invisible': [('advance_payment_method', '!=', 'percentage')]}" class="oe_inline"/> -
- - Note that if you select 'Invoiceable lines (without refunds)', you won't be able to create an invoice with a negative total amount. - -
diff --git a/addons/sale_stock/tests/test_sale_stock.py b/addons/sale_stock/tests/test_sale_stock.py index 87dd85c6df3..46f4162e474 100644 --- a/addons/sale_stock/tests/test_sale_stock.py +++ b/addons/sale_stock/tests/test_sale_stock.py @@ -89,7 +89,7 @@ class TestSaleStock(TestSale): self.assertEqual(inv.amount_untaxed, self.so.amount_untaxed * 5.0 / 100.0, 'Sale Stock: deposit invoice is wrong') self.assertEqual(self.so.invoice_status, 'to invoice', 'Sale Stock: so should be to invoice after invoicing deposit') # invoice on order: everything should be invoiced - self.so.action_invoice_create() + self.so.action_invoice_create(final=True) self.assertEqual(self.so.invoice_status, 'invoiced', 'Sale Stock: so should be fully invoiced after second invoice') # deliver, check the delivered quantities