Atik Agewan(OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-purchase-coverage-aag into 
lp:openobject-addons.

Requested reviews:
  Rucha (Open ERP) (rpa-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-purchase-coverage-aag/+merge/76209


 Hello,

  purchase,purchase_requisition,purchase_double_validation:To Test majore 
Functionality of module improve ymls.

Thanks,
 Atik
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-purchase-coverage-aag/+merge/76209
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-purchase-coverage-aag.
=== modified file 'purchase/__openerp__.py'
--- purchase/__openerp__.py	2011-07-06 12:29:28 +0000
+++ purchase/__openerp__.py	2011-09-20 13:09:35 +0000
@@ -66,7 +66,8 @@
              'purchase_unit_test.xml',
              'test/procurement_buy.yml',
              'test/purchase_report.yml',
-    ],
+             'test/purchase_order_cancel_draft.yml'
+                 ],
     'demo': ['purchase_demo.xml'],
     'installable': True,
     'active': False,

=== modified file 'purchase/test/purchase_from_order.yml'
--- purchase/test/purchase_from_order.yml	2011-01-14 00:11:01 +0000
+++ purchase/test/purchase_from_order.yml	2011-09-20 13:09:35 +0000
@@ -52,6 +52,13 @@
 -
   !workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_po0}
 -
+  I changed Expected Date to Next Day.
+-
+  !python {model: purchase.order}: |
+    import datetime
+    next_day = (datetime.date.today()+datetime.timedelta(days=1))
+    self.write(cr, uid, [ref("purchase_order_po0")], {'minimum_planned_date': next_day})
+-
   I check that the order which was initially in the draft state has transit to confirm state.
 -
   !assert {model: purchase.order, id: purchase_order_po0}:

=== added file 'purchase/test/purchase_order_cancel_draft.yml'
--- purchase/test/purchase_order_cancel_draft.yml	1970-01-01 00:00:00 +0000
+++ purchase/test/purchase_order_cancel_draft.yml	2011-09-20 13:09:35 +0000
@@ -0,0 +1,146 @@
+-
+  In order to test to Cancel purchase order from Approved State,I start by creating a new product 'Pen Drive1'
+-
+ !record {model: product.product, id: product_product_pendrive1}:
+    categ_id: 'product.product_category_3'
+    cost_method: standard
+    mes_type: fixed
+    name: Pen Drive
+    price_margin: 1.0
+    procure_method: make_to_order
+    property_stock_inventory: stock.location_inventory
+    property_stock_procurement: stock.location_procurement
+    property_stock_production: stock.location_production
+    seller_delay: '1'
+    standard_price: 500.0
+    supply_method: buy
+    type: product
+    uom_id: product.product_uom_unit
+    uom_po_id: product.product_uom_unit
+    volume: 0.0
+    warranty: 0.0
+    weight: 0.0
+    weight_net: 0.0
+-
+  Create second  new product 'Pen Drive2'
+-
+ !record {model: product.product, id: product_product_pendrive2}:
+    categ_id: 'product.product_category_3'
+    cost_method: standard
+    mes_type: fixed
+    name: Pen Drive 2
+    price_margin: 1.0
+    procure_method: make_to_order
+    property_stock_inventory: stock.location_inventory
+    property_stock_procurement: stock.location_procurement
+    property_stock_production: stock.location_production
+    seller_delay: '1'
+    standard_price: 500.0
+    supply_method: buy
+    type: product
+    uom_id: product.product_uom_unit
+    uom_po_id: product.product_uom_unit
+    volume: 0.0
+    warranty: 0.0
+    weight: 0.0
+    weight_net: 0.0
+-
+  I create first purchase order for Pen Drive1 where "invoice_method" is From Order.
+-
+  !record {model: purchase.order, id: purchase_order_pendrive1}:
+    company_id: base.main_company
+    date_order: !eval time.strftime('%Y-%m-%d')
+    invoice_method: order
+    location_id: stock.stock_location_stock
+    order_line:
+      - date_planned: !eval time.strftime('%Y-%m-%d')
+        name: Pen Drive
+        price_unit: 100.0
+        product_id: 'product_product_pendrive1'
+        product_qty: 10.0
+        product_uom: product.product_uom_unit
+        state: draft
+    partner_address_id: base.res_partner_address_7
+    partner_id: base.res_partner_4
+    pricelist_id: purchase.list0
+-
+  Initially  purchase order is in the draft state.
+-
+  !assert {model: purchase.order, id: purchase_order_pendrive1}:
+    - state == 'draft'
+-
+  I confirm the purchase order for Pen Drive1.
+-
+  !workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_pendrive1}
+-
+  I check that the order which was initially in the draft state has transmit to confirm state.
+-
+  !assert {model: purchase.order, id: purchase_order_pendrive1}:
+    - state == 'approved'
+-
+  I have to first cancel Picking of Approved Purchase order .
+-
+  !python {model: stock.picking}: |
+    from tools.translate import _
+    search_ids=self.search(cr, uid, [('purchase_id', '=', ref("purchase_order_pendrive1"))])
+    self.action_cancel(cr, uid, search_ids)
+-
+  Now I have to cancel confirm  purchase order for Pen Drive1.
+-
+  !python {model: purchase.order}: |
+    self.action_cancel(cr, uid, [ref("purchase_order_pendrive1")])
+-
+  I check that the order which was in approved state has transmit to cancel state.
+-
+  !assert {model: purchase.order, id: purchase_order_pendrive1}:
+    - state == 'cancel'
+-
+  Now again set purchase order for Pen Drive1 to draft state.
+-
+  !python {model: purchase.order}: |
+    self.action_cancel_draft(cr, uid, [ref("purchase_order_pendrive1")])   
+-
+  I check that the First purchase order is in draft state.
+-
+  !assert {model: purchase.order, id: purchase_order_pendrive1}:
+    - state == 'draft'
+-
+  I test for Copy and Delete Perchase order in Draft state.
+-
+  !python {model: purchase.order}: |
+    from tools.translate import _
+    copy_id = self.copy(cr, uid, ref("purchase_order_pendrive1"))   
+    self.unlink(cr, uid, [copy_id])   
+-
+  I create Second purchase order for Pen Drive1 where "invoice_method" is From Order.
+-
+  !record {model: purchase.order, id: purchase_order_pendrive2}:
+    company_id: base.main_company
+    date_order: !eval time.strftime('%Y-%m-%d')
+    invoice_method: order
+    location_id: stock.stock_location_stock
+    order_line:
+      - date_planned: !eval time.strftime('%Y-%m-%d')
+        name: Pen Drive
+        price_unit: 100.0
+        product_id: 'product_product_pendrive1'
+        product_qty: 10.0
+        product_uom: product.product_uom_unit
+        state: draft
+    partner_address_id: base.res_partner_address_7
+    partner_id: base.res_partner_4
+    pricelist_id: purchase.list0
+-
+  Initially  Second purchase order is in the draft state.
+-
+  !assert {model: purchase.order, id: purchase_order_pendrive2}:
+    - state == 'draft'
+-
+  I have merged first and second purchase order which are in draft state, belong to the same supplier,have same stock location, same pricelist.
+-
+  !python {model: purchase.order.group}: |
+    ids = [ref("purchase_order_pendrive1"),ref("purchase_order_pendrive2")]
+    self.fields_view_get(cr, uid, context={'active_ids': ids})	
+    self.merge_orders(cr, uid, [1], context={'active_ids': ids})
+
+ 
\ No newline at end of file

=== modified file 'purchase_double_validation/__openerp__.py'
--- purchase_double_validation/__openerp__.py	2011-07-06 12:29:28 +0000
+++ purchase_double_validation/__openerp__.py	2011-09-20 13:09:35 +0000
@@ -40,6 +40,7 @@
 	   'purchase_double_validation_workflow.xml',
 	   'purchase_double_validation_installer.xml'
 	    ],
+    'test': ['test/purchase_double_validation_test.yml'],
     'demo_xml': [],
     'installable': True,
     'active': False,

=== added directory 'purchase_double_validation/test'
=== added file 'purchase_double_validation/test/purchase_double_validation_test.yml'
--- purchase_double_validation/test/purchase_double_validation_test.yml	1970-01-01 00:00:00 +0000
+++ purchase_double_validation/test/purchase_double_validation_test.yml	2011-09-20 13:09:35 +0000
@@ -0,0 +1,117 @@
+-
+  I Create new limit amount from  Configure Limit Amount for Purchase wizard.
+- 
+  !record {model: purchase.double.validation.installer, id: purchase_double_validation_installer_1}:
+    limit_amount: 3000
+- 
+  Then I set the Limit Amount
+- 
+  !python {model: purchase.double.validation.installer}: |
+    self.execute(cr, uid, [ref("purchase_double_validation_installer_1")])
+-
+  In order to test the purchase double validation flow,I start by creating a new product 'MOB1'
+-
+ !record {model: product.product, id: product_product_mob1}:
+    categ_id: 'product.product_category_3'
+    cost_method: standard
+    mes_type: fixed
+    name: MOB1
+    price_margin: 2.0
+    procure_method: make_to_stock
+    property_stock_inventory: stock.location_inventory
+    property_stock_procurement: stock.location_procurement
+    property_stock_production: stock.location_production
+    seller_delay: '1'
+    standard_price: 2000.0
+    supply_method: buy
+    type: product
+    uom_id: product.product_uom_unit
+    uom_po_id: product.product_uom_unit
+    volume: 0.0
+    warranty: 0.0
+    weight: 0.0
+    weight_net: 0.0
+-
+  In order to test the purchase double validation flow,I create a new record where "invoice_method" is From Order.
+-
+  Test for purchase double validation in which Total > = Limit Amount.
+- 
+  I create purchase order for MOB1 for 3 quantity.
+- 
+  !record {model: purchase.order, id: purchase_order_po11}:
+    company_id: base.main_company
+    date_order: '2011-01-1'
+    invoice_method: order
+    location_id: stock.stock_location_stock
+    order_line:
+      - date_planned: '2011-01-11'
+        name: MOB1
+        price_unit: 2000.0
+        product_id: 'product_product_mob1'
+        product_qty: 3.0
+        product_uom: product.product_uom_unit
+        state: draft
+    partner_address_id: base.res_partner_address_7
+    partner_id: base.res_partner_4
+    pricelist_id: purchase.list0
+- 
+  Initially purchase order is in the draft state.
+-
+  !assert {model: purchase.order, id: purchase_order_po11}:
+    - state == 'draft'  
+-
+  I confirm the purchase order for MOB1.
+-
+  !workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_po11}
+-  
+  I check that the order which was initially in the draft state has transmit to confirm state for double validation.
+-
+  !assert {model: purchase.order, id: purchase_order_po11}:
+    - state == 'confirmed'
+-
+  I Approved purchase order by Supplier for MOB1.
+-
+  !workflow {model: purchase.order, action: purchase_approve, ref: purchase_order_po11}
+-  
+  I check that the order which was initially in the confirmed state has transmit to approved state.
+-
+  !assert {model: purchase.order, id: purchase_order_po11}:
+    - state == 'approved' 
+-
+  Test for purchase double validation in which Total < Limit Amount.
+- 
+  I create purchase order for MOB1 for 1 quantity.
+- 
+  !record {model: purchase.order, id: purchase_order_po12}:
+    company_id: base.main_company
+    date_order: '2011-01-02'
+    invoice_method: order
+    location_id: stock.stock_location_stock
+    order_line:
+      - date_planned: '2011-01-12'
+        name: MOB1
+        price_unit: 2000.0
+        product_id: 'product_product_mob1'
+        product_qty: 1.0
+        product_uom: product.product_uom_unit
+        state: draft
+    partner_address_id: base.res_partner_address_7
+    partner_id: base.res_partner_4
+    pricelist_id: purchase.list0
+- 
+  Initially purchase order is in the draft state.
+-
+  !assert {model: purchase.order, id: purchase_order_po12}:
+    - state == 'draft'  
+-
+  I confirm the purchase order for MOB1.
+-
+  !workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_po12}
+-  
+  I check that the order which was initially in the draft state has transmit to approved state.
+-
+  !assert {model: purchase.order, id: purchase_order_po12}:
+    - state == 'approved'
+
+
+   
\ No newline at end of file

=== modified file 'purchase_requisition/__openerp__.py'
--- purchase_requisition/__openerp__.py	2011-07-06 12:29:28 +0000
+++ purchase_requisition/__openerp__.py	2011-09-20 13:09:35 +0000
@@ -43,7 +43,9 @@
                     "security/ir.model.access.csv","purchase_requisition_sequence.xml"
     ],
     "active": False,
-    "test":['test/purchase_requisition_report.yml'],
+    "test":['test/purchase_requisition_report.yml',
+            'test/purchase_requisition_test.yml',
+            ],
     "installable": True,
     "certificate" : "001023264099823179629",
 }

=== added file 'purchase_requisition/test/purchase_requisition_test.yml'
--- purchase_requisition/test/purchase_requisition_test.yml	1970-01-01 00:00:00 +0000
+++ purchase_requisition/test/purchase_requisition_test.yml	2011-09-20 13:09:35 +0000
@@ -0,0 +1,173 @@
+-
+  In order to test the purchase requisition flow,I start by creating a new product 'MOB1'
+- 
+  !record {model: product.product, id: product_product_mob1}:
+    name: MOB1
+    categ_id: product.product_category_3
+    cost_method: standard
+    mes_type: fixed
+    price_margin: 2.0
+    procure_method: make_to_stock
+    property_stock_inventory: stock.location_inventory
+    property_stock_procurement: stock.location_procurement
+    property_stock_production: stock.location_production
+    seller_delay: '1'
+    standard_price: 2000.0
+    supply_method: buy
+    type: product
+    uom_id: product.product_uom_unit
+    uom_po_id: product.product_uom_unit
+    volume: 0.0
+    warranty: 0.0
+    weight: 0.0
+    weight_net: 0.0
+- 
+  I create purchase requisition for MOB1 for 1 quantity.
+- 
+  !record {model: purchase.requisition, id: purchase_requisition_te0}:
+    company_id: base.main_company
+    exclusive: multiple
+    line_ids:
+      - company_id: base.main_company
+        product_id: product_product_mob1
+        product_qty: 10.0
+        product_uom_id: product.product_uom_unit
+    name: TE00009
+- 
+  Initially purchase requisition is in draft state.
+-
+  !assert {model: purchase.requisition, id: purchase_requisition_te0}:
+    - state == 'draft'  
+- 
+  Copy purchase requisition which is in draft state than confirm and Done it.
+-
+  !python {model: purchase.requisition}: |
+    copy_id = self.copy(cr, uid, ref("purchase_requisition_te0"))   
+    self.tender_cancel(cr, uid, [copy_id], context=None)
+    self.tender_reset(cr, uid, [copy_id], context=None)
+    self.tender_in_progress(cr, uid, [copy_id], context=None)
+    self.tender_done(cr, uid, [copy_id], context=None)
+- 
+  I confirm the purchase requisition for MOB1.
+- 
+  !python {model: purchase.requisition}: |
+    self.tender_in_progress(cr, uid, [ref("purchase_requisition_te0")])
+-
+  I check that the purchase requisition which was initially in the draft state has transmit to In Progress after confirm it.
+-
+  !assert {model: purchase.requisition, id: purchase_requisition_te0}:
+    - state == 'in_progress'
+- 
+   I Create a Purchase Order for the supplier 'Axelor'.
+- 
+  !record {model: purchase.requisition.partner, id: purchase_requisition_partner_0}:
+    partner_address_id: base.res_partner_address_7
+    partner_id: base.res_partner_desertic_hispafuentes
+- 
+  I create Quotations For supplier 'Axelor'.
+- 
+  !python {model: purchase.requisition.partner}: |
+    self.create_order(cr, uid, [ref("purchase_requisition_partner_0")], {"active_model": "purchase.requisition",
+      "active_ids": [ref("purchase_requisition_te0")],"active_id": ref("purchase_requisition_te0"), })
+-
+  I confirm the purchase order of Axelor.
+-
+  !python {model: purchase.order}: |
+    purchase_id= self.search(cr, uid, [('requisition_id','=',ref("purchase_requisition_te0"))])
+    import netsvc
+    wf_service = netsvc.LocalService("workflow")   
+    if purchase_id:
+      wf_service.trg_validate(uid, 'purchase.order',purchase_id[0],'purchase_confirm', cr)
+      wf_service.trg_validate(uid, 'purchase.order',purchase_id[0],'purchase_approve', cr)
+-
+  I check that Quotation of Axelor is Approved.
+-        
+  !python {model: purchase.order}: |
+   purchase_id= self.search(cr, uid, [('requisition_id','=',ref("purchase_requisition_te0"))])[0]
+   state=self.browse(cr,uid,purchase_id).state
+   assert (state=='approved')
+- 
+  I click on Done button
+- 
+  !python {model: purchase.requisition}: |
+    self.tender_done(cr, uid, [ref("purchase_requisition_te0")],)
+-
+  I check that after click on Done button state is in done.
+-
+  !assert {model: purchase.requisition, id: purchase_requisition_te0}:
+    - state == 'done'
+-
+  In order to test the purchase requisition flow for Requisition Type is exclusive 
+- 
+  I create purchase requisition for Requisition Type is exclusive 
+- 
+  !record {model: purchase.requisition, id: purchase_requisition_ex1}:
+    company_id: base.main_company
+    exclusive: exclusive
+    line_ids:
+      - company_id: base.main_company
+        product_id: product_product_mob1
+        product_qty: 10.0
+        product_uom_id: product.product_uom_unit
+    name: TE000010
+- 
+   I Create a First Purchase Order for the supplier 'DistriPC'.
+- 
+  !record {model: purchase.requisition.partner, id: purchase_requisition_partner_1}:
+    partner_address_id: base.res_partner_address_7
+    partner_id: base.res_partner_4
+- 
+  I create Quotations For supplier 'DistriPC'.
+- 
+  !python {model: purchase.requisition.partner}: |
+    self.create_order(cr, uid, [ref("purchase_requisition_partner_1")], {"active_model": "purchase.requisition",
+      "active_ids": [ref("purchase_requisition_ex1")],"active_id": ref("purchase_requisition_ex1"), })    
+- 
+   I Create a Second Purchase Order for the supplier ASUStek.
+- 
+  !record {model: purchase.requisition.partner, id: purchase_requisition_partner_2}:
+    partner_address_id: base.res_partner_address_7
+    partner_id: base.res_partner_asus
+- 
+  I create Quotations For supplier 'ASUStek'.
+- 
+  !python {model: purchase.requisition.partner}: |
+    self.create_order(cr, uid, [ref("purchase_requisition_partner_2")], {"active_model": "purchase.requisition",
+      "active_ids": [ref("purchase_requisition_ex1")],"active_id": ref("purchase_requisition_ex1"), })
+- 
+  I check that Initially purchase requisition is draft state.
+-
+  !assert {model: purchase.requisition, id: purchase_requisition_ex1}:
+    - state == 'draft'  
+-
+  I confirm the Second purchase order of ASUStek.
+-
+  !python {model: purchase.order}: |
+    partner_id=self.pool.get('res.partner').search(cr,uid,[('name','=','ASUStek')])[0]
+    purchase_id= self.search(cr, uid, [('partner_id','=',partner_id),('requisition_id','=',ref("purchase_requisition_ex1"))])
+    import netsvc
+    wf_service = netsvc.LocalService("workflow")   
+    if purchase_id:
+      wf_service.trg_validate(uid, 'purchase.order',purchase_id[0],'purchase_confirm', cr)
+      wf_service.trg_validate(uid, 'purchase.order',purchase_id[0],'purchase_approve', cr)
+-
+  I check that Quotation of ASUStek is Approved.
+-        
+  !python {model: purchase.order}: |
+   partner_id=self.pool.get('res.partner').search(cr,uid,[('name','=','ASUStek')])[0]
+   purchase_id= self.search(cr, uid, [('partner_id','=',partner_id),('requisition_id','=',ref("purchase_requisition_ex1"))])[0]
+   state=self.browse(cr,uid,purchase_id).state
+   assert (state=='approved')
+-
+  I check that Quotation of DistriPC is cancelled.
+-        
+  !python {model: purchase.order}: |
+   partner_id=self.pool.get('res.partner').search(cr,uid,[('name','=','Distrib PC')])[0]
+   purchase_id= self.search(cr, uid, [('partner_id','=',partner_id),('requisition_id','=',ref("purchase_requisition_ex1"))])[0]
+   state=self.browse(cr,uid,purchase_id).state
+   assert (state=='cancel')
+-
+  I check that Purchase Requisition is Done.
+-
+  !assert {model: purchase.requisition, id: purchase_requisition_ex1}:
+    - state == 'done'
\ No newline at end of file

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to