From eafd95a1d5126bdfae31a4fc70c2e017035f4073 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Thu, 20 Sep 2012 17:20:43 +0200 Subject: [PATCH] [FIX] sale: fixed yaml tests bzr revid: qdp-launchpad@openerp.com-20120920152043-u0euspbyr04vjqwn --- addons/sale/test/cancel_order.yml | 32 +++++++++++++++++------------ addons/sale/test/edi_sale_order.yml | 2 -- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/addons/sale/test/cancel_order.yml b/addons/sale/test/cancel_order.yml index 6d8478845fc..6145964224a 100644 --- a/addons/sale/test/cancel_order.yml +++ b/addons/sale/test/cancel_order.yml @@ -18,21 +18,22 @@ - I create an invoice for the first line - - !python {model: sale.advance.payment.inv}: | + !python {model: sale.order.line.make.invoice}: | + ctx = context.copy() - ctx.update({"active_model": 'sale.order', "active_ids": [ref("sale_order_8")], "active_id":ref("sale_order_8")}) - order_line = self.pool.get('sale.order.line').browse(cr, uid, ref("sale_order_line_20"), context=context) - pay_id = self.create(cr, uid, {'advance_payment_method': 'lines', 'product_id': order_line.product_id.id, 'amount': order_line.price_subtotal, 'qtty': order_line.product_uom_qty}) - self.create_invoices(cr, uid, [pay_id], context=ctx) + ctx.update({"active_model": 'sale.order.line', "active_ids": [ref("sale_order_line_20")], "active_id":ref("sale_order_line_20")}) + pay_id = self.create(cr, uid, {}) + self.make_invoices(cr, uid, [pay_id], context=ctx) + invoice_ids = self.pool.get('sale.order').browse(cr, uid, ref("sale_order_8")).invoice_ids - - I create an invoice for a fixed price (a percentage of the amount of the second line) + I create an invoice for a fixed price (25% of the second line, thus 5) - !python {model: sale.advance.payment.inv}: | ctx = context.copy() ctx.update({"active_model": 'sale.order', "active_ids": [ref("sale_order_8")], "active_id":ref("sale_order_8")}) - order_line = self.pool.get('sale.order.line').browse(cr, uid, ref("sale_order_line_21"), context=context) - pay_id = self.create(cr, uid, {'advance_payment_method': 'fixed', 'product_id': order_line.product_id.id, 'amount': order_line.price_subtotal, 'qtty': order_line.product_uom_qty}) + pay_id = self.create(cr, uid, {'advance_payment_method': 'fixed', 'amount': 5}) self.create_invoices(cr, uid, [pay_id], context=ctx) + invoice_ids = self.pool.get('sale.order').browse(cr, uid, ref("sale_order_8")).invoice_ids - I create an invoice for the remaining and check the amount (should be the remaining amount of second line) @@ -42,8 +43,12 @@ ctx.update({"active_model": 'sale.order', "active_ids": [ref("sale_order_8")], "active_id":ref("sale_order_8")}) pay_id = self.create(cr, uid, {'advance_payment_method': 'all'}) self.create_invoices(cr, uid, [pay_id], context=ctx) + invoice_ids = self.pool.get('sale.order').browse(cr, uid, ref("sale_order_8")).invoice_ids + assert len(invoice_ids) == 3, "All invoices are not created" + for invoice in invoice_ids: + assert invoice.amount_total in (7290,5,20), "Invoice total is not correct" - - I cancel all the invoices. + I cancel all the invoices. - !python {model: sale.order}: | import netsvc @@ -65,9 +70,10 @@ - !python {model: sale.order}: | sale_order = self.browse(cr, uid, ref("sale_order_8")) - total_order_line = [] + total_order_line = 0 assert len(sale_order.invoice_ids), "Invoice should be created." - for order_line in sale_order.invoice_ids: - total_order_line = order_line.invoice_line - assert len(total_order_line) == 2, "invoice lines are not same" + for invoice in sale_order.invoice_ids: + if invoice.state != 'cancel': + total_order_line += len(invoice.invoice_line) + assert total_order_line == 2, "wrong number of invoice lines" diff --git a/addons/sale/test/edi_sale_order.yml b/addons/sale/test/edi_sale_order.yml index 875095b9ab2..967aaa1337c 100644 --- a/addons/sale/test/edi_sale_order.yml +++ b/addons/sale/test/edi_sale_order.yml @@ -73,7 +73,6 @@ "__import_module": "sale", "__import_model": "sale.order.line", "name": "PC Assemble SC234", - "date_planned": "2011-09-30", "price_unit": 150.0, "product_id": ["product:5af1272e-dd26-11e0-b65e-701a04e25543.product_product_3", "[PCSC234] PC Assemble SC234"], "product_qty": 1.0, @@ -86,7 +85,6 @@ "__import_module": "sale", "__import_model": "sale.order.line", "name": "PC on Demand", - "date_planned": "2011-09-15", "price_unit": 100.0, "product_id": ["product:5af1272e-dd26-11e0-b65e-701a04e25543.product_product_5", "[PC-DEM] PC on Demand"], "product_qty": 2.0,