[MOVE,IMP]sale:
authorDBR (OpenERP) <dbr@tinyerp.com>
Wed, 16 Nov 2011 06:48:43 +0000 (12:18 +0530)
committerDBR (OpenERP) <dbr@tinyerp.com>
Wed, 16 Nov 2011 06:48:43 +0000 (12:18 +0530)
Move scheduler file in to process folder and Improve some test cases

bzr revid: dbr@tinyerp.com-20111116064843-iubv9la5kufttuuo

addons/sale/__openerp__.py
addons/sale/sale_demo.xml
addons/sale/test/process/cancel_order.yml
addons/sale/test/process/order_policy.yml
addons/sale/test/process/run_scheduler.yml [new file with mode: 0644]
addons/sale/test/sale_procurement.yml [deleted file]

index 3baa0cc..04f078e 100644 (file)
@@ -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',
index aabb57b..821d8ef 100644 (file)
             <field name="type">make_to_order</field>
             <field name="delay">15</field>
         </record>
+        <record id="line52" model="sale.order.line">
+            <field name="order_id" ref="order5"/>
+            <field name="name">[CPU1] Processor AMD Athlon XP 1800+</field>
+            <field name="product_id" ref="product.product_product_cpu1"/>
+            <field name="product_uom" ref="product.product_uom_unit"/>
+            <field name="price_unit">75</field>
+            <field name="product_uom_qty">3</field>
+            <field name="product_uos_qty">3</field>
+            <field name="type">make_to_stock</field>
+        </record>
         <workflow action="order_confirm" model="sale.order" ref="order5"/>
 
         <!--Resource: sale.order-->
index 3ba69f5..05cbdf6 100644 (file)
   !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
index 858b0b4..8b91cb8 100644 (file)
   !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 (file)
index 0000000..42ca287
--- /dev/null
@@ -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 (file)
index 923860e..0000000
+++ /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!')