From ded002e061c19c675a28b4c4cee255296b19dd02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 22 Jul 2013 14:27:49 +0200 Subject: [PATCH] Add test for COGS computation with negative quantity issue3287 review976002 --- tests/scenario_account_stock_anglo_saxon.rst | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/scenario_account_stock_anglo_saxon.rst b/tests/scenario_account_stock_anglo_saxon.rst index 7c65b80b15..3a09bd72bb 100644 --- a/tests/scenario_account_stock_anglo_saxon.rst +++ b/tests/scenario_account_stock_anglo_saxon.rst @@ -379,3 +379,23 @@ Now create a supplier invoice with an accountant:: ... 'invoice_date': today, ... }, config.context) >>> Invoice.validate_invoice([i.id for i in purchase.invoices], config.context) + +Create customer invoice with negative quantity:: + + >>> invoice = Invoice() + >>> invoice.party = customer + >>> invoice.payment_term = payment_term + >>> invoice_line = invoice.lines.new() + >>> invoice_line.product = product + >>> invoice_line.quantity = -1 + >>> invoice.save() + >>> Invoice.post([invoice.id], config.context) + >>> invoice.state + u'posted' + >>> move = invoice.move + >>> line_cogs, = (l for l in move.lines if l.account == cogs) + >>> line_cogs.credit == Decimal('5') + True + >>> line_stock, = (l for l in move.lines if l.account == stock_customer) + >>> line_stock.debit == Decimal('5') + True