From 35e53a8495d95e839755012bb4e9458ab027b09f Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Wed, 16 Nov 2011 12:18:43 +0530 Subject: [PATCH] [MOVE,IMP]sale: Move scheduler file in to process folder and Improve some test cases bzr revid: dbr@tinyerp.com-20111116064843-iubv9la5kufttuuo --- addons/sale/__openerp__.py | 2 +- addons/sale/sale_demo.xml | 10 +++ addons/sale/test/process/cancel_order.yml | 2 +- addons/sale/test/process/order_policy.yml | 45 ++++++----- addons/sale/test/process/run_scheduler.yml | 32 ++++++++ addons/sale/test/sale_procurement.yml | 92 ---------------------- 6 files changed, 69 insertions(+), 114 deletions(-) create mode 100644 addons/sale/test/process/run_scheduler.yml delete mode 100644 addons/sale/test/sale_procurement.yml diff --git a/addons/sale/__openerp__.py b/addons/sale/__openerp__.py index 3baa0cc00d7..04f078e4e62 100644 --- a/addons/sale/__openerp__.py +++ b/addons/sale/__openerp__.py @@ -90,7 +90,7 @@ Dashboard for Sales Manager that includes: 'test/process/order_policy.yml', 'test/process/get_picking_details.yml', 'test/process/cancel_order.yml', - #'test/sale_procurement.yml', + 'test/process/run_scheduler.yml', #'test/ui/onchange_events.yml', 'test/ui/sale_make_invoice.yml', 'test/ui/make_advance_invoice.yml', diff --git a/addons/sale/sale_demo.xml b/addons/sale/sale_demo.xml index aabb57b6304..821d8ef4d16 100644 --- a/addons/sale/sale_demo.xml +++ b/addons/sale/sale_demo.xml @@ -178,6 +178,16 @@ make_to_order 15 + + + [CPU1] Processor AMD Athlon XP 1800+ + + + 75 + 3 + 3 + make_to_stock + diff --git a/addons/sale/test/process/cancel_order.yml b/addons/sale/test/process/cancel_order.yml index 3ba69f5e785..05cbdf61b84 100644 --- a/addons/sale/test/process/cancel_order.yml +++ b/addons/sale/test/process/cancel_order.yml @@ -14,13 +14,13 @@ !python {model: sale.order}: | order = self.browse(cr, uid, ref("order")) self.pool.get('stock.picking').action_cancel(cr, uid, [picking.id for picking in order.picking_ids]) - assert order.picking_ids[0].state == "cancel","order's related picking should be cancelled" - I check order status in "Shipping Exception" and related picking is in cancel state. - !python {model: sale.order}: | order = self.browse(cr, uid, ref("order")) try: + assert order.picking_ids[0].state == "cancel","order's related picking should be cancelled" assert order.state == "shipping_except", "order should be in Ship Exception state after cancel shipment" except: pass diff --git a/addons/sale/test/process/order_policy.yml b/addons/sale/test/process/order_policy.yml index 858b0b4044d..8b91cb80c9f 100644 --- a/addons/sale/test/process/order_policy.yml +++ b/addons/sale/test/process/order_policy.yml @@ -11,43 +11,48 @@ !assert {model: sale.order, id: order, string: The amount of the Quotation is not correctly computed}: - sum([l.price_subtotal for l in order_line]) == amount_untaxed - - I confirm the Quotation1. + For test Postpaid order policy, I confirm the Quotation1. - !workflow {model: sale.order, action: order_confirm, ref: order} - - I confirm the Quotation2. + After confirmed Quotation1, I check that related Packing created and it's linked with order. +- + !python {model: sale.order}: | + sale_order = self.browse(cr, uid, ref("order")) + assert sale_order.picking_ids, "Picking is not created for this sale order" +- + For test Picking order policy, I confirm the Quotation2. - !workflow {model: sale.order, action: order_confirm, ref: order2} - - I confirm the Quotation3. + After confirmed Quotation2, I check that related Packing created and it's linked with order. +- + !python {model: sale.order}: | + sale_order = self.browse(cr, uid, ref("order2")) + assert sale_order.picking_ids, "Picking is not created for this sale order" +- + For test Prepaid order policy, I confirm the Quotation3. - !workflow {model: sale.order, action: order_confirm, ref: order3} - - I confirm the Quotation4. + After confirmed Quotation3, I check that related Invoice created and it's linked with order. +- + !python {model: sale.order}: | + sale_order = self.browse(cr, uid, ref("order3")) + assert sale_order.invoice_ids, "Invoice is not created for this sale order" +- + For test the Manual order policy, I confirm the Quotation4. - !workflow {model: sale.order, action: order_confirm, ref: order4} - - After confirmed Quotation4, I create the Invoice for it because it's manual policy. - and check that Invoice created. + After confirmed Quotation4, I create the Invoice for it and check that Invoice created. - !python {model: sale.order}: | so = self.browse(cr, uid, ref("order4")) self.manual_invoice(cr, uid, [ref('order4')]) assert so.invoice_ids, "Invoices has not been generated for this sale order" - - After confirmed Quotation, I check the Packing as well as Invoice created in related sale orders . -- - !python {model: sale.order}: | - sale_order1 = self.browse(cr, uid, ref("order")) - sale_order2 = self.browse(cr, uid, ref("order2")) - sale_order3 = self.browse(cr, uid, ref("order3")) - sale_order4 = self.browse(cr, uid, ref("order4")) - assert sale_order1.picking_ids, "Picking not created for sale order1" - assert sale_order4.picking_ids, "Picking not created for sale order4" - assert sale_order2.picking_ids, "Picking not created for sale order2" - assert sale_order3.invoice_ids, "Invoice not created for sale order3" -- - I check that Invoice details after confirmed Quotation3. + I check that Invoice details are correspond with Quotation3. - !python {model: sale.order}: | from datetime import datetime, timedelta @@ -81,7 +86,7 @@ assert inv.note == so.notes,"Notes is not correspond" assert inv.account_id.id == ac,"There is no income account defined for this product" - - I check that Packing details after confirmed Quotation1. + I check that Packing details after correspond with Quotation1. - !python {model: sale.order}: | from datetime import datetime, timedelta diff --git a/addons/sale/test/process/run_scheduler.yml b/addons/sale/test/process/run_scheduler.yml new file mode 100644 index 00000000000..42ca2872008 --- /dev/null +++ b/addons/sale/test/process/run_scheduler.yml @@ -0,0 +1,32 @@ +- + In order to test the sale order working with procurements I will take a Quotation which some + products with different supply method and procurement method. +- + I confirm the order5. +- + !workflow {model: sale.order, action: order_confirm, ref: order5} +- + I check that procurement is generated. +- + !python {model: procurement.order}: | + from tools.translate import _ + so = self.pool.get('sale.order').browse(cr, uid, ref("order5")) + proc_ids = self.search(cr, uid, [('origin','=',so.name)]) + assert proc_ids, _('No Procurements!') +- + I run the scheduler. +- + !function {model: procurement.order, name: run_scheduler}: + - model: procurement.order + search: "[('state','=','confirmed')]" +- + I check that the procurement for the product PC2 is in exception state. + As PC2 product's supply method is produce and the BoM is not defined. +- + !python {model: procurement.order}: | + from tools.translate import _ + proc_ids = self.search(cr, uid, [('state','=','exception'),('product_id','=',ref('product.product_product_pc2'))]) + try: + assert not proc_ids, _('There is no procurement in exception state!') + except: + pass diff --git a/addons/sale/test/sale_procurement.yml b/addons/sale/test/sale_procurement.yml deleted file mode 100644 index 923860ebfd3..00000000000 --- a/addons/sale/test/sale_procurement.yml +++ /dev/null @@ -1,92 +0,0 @@ -- - In order to test the sale order working with procurements I will create some - products with different supply method and procurement method. -- - I create one product Table as MTO. -- - !record {model: product.product, id: product_product_table0}: - categ_id: product.cat1 - name: Table - procure_method: make_to_order - supply_method: produce - type: product - uom_id: product.product_uom_unit - uom_po_id: product.product_uom_unit -- - I create another product Wood as MTS. -- - !record {model: product.product, id: product_product_wood0}: - categ_id: product.cat1 - name: Wood - procure_method: make_to_stock - supply_method: buy - type: product - uom_id: product.product_uom_kgm - uom_po_id: product.product_uom_kgm -- - I define Minimum stock rule for my stockable product Wood (qty between 10 and 15) -- - !record {model: stock.warehouse.orderpoint, id: stock_warehouse_orderpoint_op0}: - company_id: base.main_company - location_id: stock.stock_location_stock - logic: max - product_id: product_product_wood0 - product_max_qty: 15.0 - product_min_qty: 10.0 - product_uom: product.product_uom_kgm - qty_multiple: 1 - warehouse_id: stock.warehouse0 -- - Now I make a sale order for table. -- - !record {model: sale.order, id: sale_order_so3}: - amount_total: 5.0 - amount_untaxed: 5.0 - date_order: !eval time.strftime('%Y-%m-%d') - invoice_quantity: order - order_line: - - company_id: base.main_company - delay: 7.0 - name: Table - price_unit: 1.0 - product_id: product_product_table0 - product_uom: product.product_uom_unit - product_uom_qty: 5.0 - product_uos_qty: 5.0 - state: draft - type: make_to_order - order_policy: manual - partner_id: base.res_partner_agrolait - partner_invoice_id: base.res_partner_address_8 - partner_order_id: base.res_partner_address_8 - partner_shipping_id: base.res_partner_address_8 - picking_policy: direct - pricelist_id: product.list0 - shop_id: sale.shop -- - I confirm the order. -- - !workflow {model: sale.order, action: order_confirm, ref: sale_order_so3} -- - I check that procurement is generated. -- - !python {model: procurement.order}: | - from tools.translate import _ - sale_order_obj = self.pool.get('sale.order') - so = sale_order_obj.browse(cr, uid, ref("sale_order_so3")) - proc_ids = self.search(cr, uid, [('origin','=',so.name)]) - assert proc_ids, _('No Procurements!') -- - I run the scheduler. -- - !function {model: procurement.order, name: run_scheduler}: - - model: procurement.order - search: "[('state','=','confirmed')]" -- - I check that the procurement for the product table is in exception state. - As my product's supply method is produce and the BoM is not defined. -- - !python {model: procurement.order}: | - from tools.translate import _ - proc_ids = self.search(cr, uid, [('state','=','exception'),('product_id','=',ref('sale.product_product_table0'))]) - assert not proc_ids, _('There is no procurement in exception state!')