diff --git a/addons/purchase/__openerp__.py b/addons/purchase/__openerp__.py index faf9850d14a..f5198d57f85 100644 --- a/addons/purchase/__openerp__.py +++ b/addons/purchase/__openerp__.py @@ -66,7 +66,8 @@ Dashboard for purchase management that includes: '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, diff --git a/addons/purchase/test/purchase_from_order.yml b/addons/purchase/test/purchase_from_order.yml index 3acc68cb51b..8e46899f8a0 100644 --- a/addons/purchase/test/purchase_from_order.yml +++ b/addons/purchase/test/purchase_from_order.yml @@ -51,6 +51,13 @@ I confirm the purchase order for iPod. - !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. - diff --git a/addons/purchase/test/purchase_order_cancel_draft.yml b/addons/purchase/test/purchase_order_cancel_draft.yml new file mode 100644 index 00000000000..6a06ad164b2 --- /dev/null +++ b/addons/purchase/test/purchase_order_cancel_draft.yml @@ -0,0 +1,114 @@ +- + 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 + standard_price: 500.0 + supply_method: buy + type: product + uom_id: product.product_uom_unit + uom_po_id: product.product_uom_unit +- + 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: 500.0 + product_id: 'product_product_pendrive1' + product_qty: 10.0 + product_uom: product.product_uom_unit + 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}: | + 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}: | + 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: 500.0 + product_id: 'product_product_pendrive1' + product_qty: 10.0 + product_uom: product.product_uom_unit + 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 diff --git a/addons/purchase_double_validation/__openerp__.py b/addons/purchase_double_validation/__openerp__.py index 9645514076f..c02da2fc9d7 100644 --- a/addons/purchase_double_validation/__openerp__.py +++ b/addons/purchase_double_validation/__openerp__.py @@ -40,6 +40,7 @@ that exceeds minimum amount set by configuration wizard. 'purchase_double_validation_workflow.xml', 'purchase_double_validation_installer.xml' ], + 'test': ['test/purchase_double_validation_test.yml'], 'demo_xml': [], 'installable': True, 'active': False, diff --git a/addons/purchase_double_validation/test/purchase_double_validation_test.yml b/addons/purchase_double_validation/test/purchase_double_validation_test.yml new file mode 100755 index 00000000000..ecc8d08a493 --- /dev/null +++ b/addons/purchase_double_validation/test/purchase_double_validation_test.yml @@ -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 diff --git a/addons/purchase_requisition/__openerp__.py b/addons/purchase_requisition/__openerp__.py index cdb13e3e1aa..d1ec2b1c260 100644 --- a/addons/purchase_requisition/__openerp__.py +++ b/addons/purchase_requisition/__openerp__.py @@ -43,7 +43,9 @@ This new object will regroup and will allow you to easily keep track and order a "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", } diff --git a/addons/purchase_requisition/test/purchase_requisition_test.yml b/addons/purchase_requisition/test/purchase_requisition_test.yml new file mode 100755 index 00000000000..403eaca04fc --- /dev/null +++ b/addons/purchase_requisition/test/purchase_requisition_test.yml @@ -0,0 +1,166 @@ +- + 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 + 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' +- + In order to create a purchase order for 'Axelor', i click on the wizard 'Request a Quotation' and create record for wizard. +- + !record {model: purchase.requisition.partner, id: purchase_requisition_partner_0}: + partner_address_id: base.res_partner_address_3000 + partner_id: base.res_partner_desertic_hispafuentes +- + I click on 'Create Quotation' for creating PO. +- + !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 'Distrib PC'. +- + !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 'Distrib PC'. +- + !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_tang + 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, than check that Quotation is Approved. +- + !python {model: purchase.order}: | + purchase_id= self.search(cr, uid, [('partner_id','=',ref("base.res_partner_asus")),('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) + state=self.browse(cr,uid,purchase_id[0]).state + assert (state=='approved') + +- + I check that Quotation of Distrib PC 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'