diff --git a/addons/purchase/__openerp__.py b/addons/purchase/__openerp__.py index 909b785fe72..553d0342f7a 100644 --- a/addons/purchase/__openerp__.py +++ b/addons/purchase/__openerp__.py @@ -52,6 +52,11 @@ 'report/purchase_report_view.xml', ], 'demo_xml': ['purchase_demo.xml'], + 'test': [ + 'test/purchase_from_order.yml', + 'test/purchase_from_manual.yml', +# 'test/purchase_from_picking.yml', + ], 'installable': True, 'active': False, 'certificate': '0057234283549', diff --git a/addons/purchase/test/purchase_from_manual.yml b/addons/purchase/test/purchase_from_manual.yml new file mode 100644 index 00000000000..e0b1a8b806c --- /dev/null +++ b/addons/purchase/test/purchase_from_manual.yml @@ -0,0 +1,148 @@ +- + In order to test the purchase flow,I start by creating a new product 'iPod' +- + !record {model: product.product, id: product_product_ipod0}: + categ_id: 'product.product_category_3' + cost_method: standard + mes_type: fixed + name: iPod + 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: 100.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 flow,I create a new record where "invoice_method" is From Manual +- + Creating an purchase.order record +- + !record {model: purchase.order, id: purchase_order_po1}: + company_id: base.main_company + date_order: '2010-05-11' + invoice_method: order + location_id: stock.stock_location_stock + name: PO00010 + order_line: + - date_planned: '2010-05-13' + name: iPod + price_unit: 100.0 + product_id: 'product_product_ipod0' + 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_po1}: + - state == 'draft' +- + Then an order is confirmed by clicking on the "Confirm Purchase Order" button +- + !python {model: purchase.order}: | + self.wkf_confirm_order(cr, uid, [ref("purchase_order_po1")]) +- + Performing a workflow action purchase_confirm on module purchase.order +- + !workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_po1} +- + I check that the order which was initially in the draft state has transit to confirm state. +- + !assert {model: purchase.order, id: purchase_order_po1}: + - state == 'confirmed' +- + I check that an entry gets created in the "Lines to Invoice" of Invoice Control on the basis of purchase order line +- + !python {model: purchase.order}: | + from tools.translate import _ + pur_order_obj=self.browse(cr, uid, ref("purchase_order_po1")) + pur_line=self.pool.get( 'purchase.order.line') + search_ids=pur_line.search(cr, uid, [('order_id', '=', pur_order_obj.name) ]) + assert search_ids, _('Purchase order line is not created!') +- + To check that wizard "Create Invoices" gets opened +- + Creating a purchase.order.line_invoice record +- + !record {model: purchase.order.line_invoice, id: purchase_order_line_invoice_0}: + {} +- + Performing an osv_memory action makeInvoices on module purchase.order.line_invoice +- + !python {model: purchase.order.line_invoice}: | + pur_obj=self.pool.get('purchase.order') + ids = [] + pur_id1=pur_obj.browse(cr, uid, ref("purchase_order_po1")) + for line in pur_id1.order_line: + ids.append(line.id) + self.makeInvoices(cr, uid, [1], context={'active_ids': ids}) +- + I check that invoice gets created +- + !python {model: purchase.order}: | + from tools.translate import _ + pur_order_obj=self.browse(cr, uid, ref("purchase_order_po1")) + pur_line=self.pool.get( 'purchase.order.line') + search_ids=pur_line.search(cr, uid, [('order_id', '=', pur_order_obj.name),('invoiced', '=', '1') ]) + assert search_ids, _('Invoice is not created!') +- + I check that a record gets created in the Pending Invoices +- + !python {model: purchase.order}: | + from tools.translate import _ + pur_id1=self.browse(cr, uid, ref("purchase_order_po1")) + account_obj = self.pool.get('account.invoice') + ids = account_obj.search(cr, uid, [('origin', '=', pur_id1.name)]) + assert ids, _('Pending Invoice is not created!') +- + Then an order is approved by clicking on the "Approved by Supplier" button +- + !python {model: purchase.order}: | + self.wkf_approve_order(cr, uid, [ref("purchase_order_po1")]) +- + Performing a workflow action purchase_approve on module purchase.order +- + !workflow {model: purchase.order, action: purchase_approve, ref: purchase_order_po1} +- + I check that the order which was initially in the confirmed state has transit to approved state. +- + !assert {model: purchase.order, id: purchase_order_po1}: + - state == 'approved' +- + I check that date_approve field of Delivery&Invoices gets bind with the date on which it has been approved +- + !python {model: purchase.order}: | + pur_id=self.browse(cr, uid, ref("purchase_order_po1")) + assert(pur_id.date_approve) +- + I check that an entry gets created in the stock.picking +- + !python {model: purchase.order}: | + pur_id=self.browse(cr, uid, ref("purchase_order_po1")) + assert(pur_id.picking_ids) +- + I check that an entry gets created in the stock.move +- + !python {model: purchase.order}: | + from tools.translate import _ + pur_id1=self.browse(cr, uid, ref("purchase_order_po1")) + picking_obj = self.pool.get('stock.picking') + ids = picking_obj.search(cr, uid, [('origin', '=', pur_id1.name)]) + pick_id = picking_obj.browse(cr, uid, ids)[0] + move_obj = self.pool.get('stock.move') + search_id = move_obj.search(cr, uid, [('picking_id', '=', pick_id.name)]) + assert search_id, _('No Incoming Product!') +- + I check that Traceability moves are created diff --git a/addons/purchase/test/purchase_from_order.yml b/addons/purchase/test/purchase_from_order.yml new file mode 100644 index 00000000000..3e83fc7dfda --- /dev/null +++ b/addons/purchase/test/purchase_from_order.yml @@ -0,0 +1,154 @@ +- + In order to test the purchase flow,I start by creating a new product 'iPod' +- + !record {model: product.product, id: product_product_ipod0}: + categ_id: 'product.product_category_3' + cost_method: standard + mes_type: fixed + name: iPod + 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: 100.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 flow,I create a new record where "invoice_method" is From Order +- + Creating a purchase.order record +- + !record {model: purchase.order, id: purchase_order_po0}: + company_id: base.main_company + date_order: '2010-05-11' + invoice_method: order + location_id: stock.stock_location_stock + name: PO00003 + order_line: + - date_planned: '2010-05-13' + name: iPod + price_unit: 100.0 + product_id: 'product_product_ipod0' + 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_po0}: + - state == 'draft' +- + Then an order is confirmed by clicking on the "Confirm Purchase Order" button +- + !python {model: purchase.order}: | + self.wkf_confirm_order(cr, uid, [ref("purchase_order_po0")]) +- + Performing a workflow action purchase_confirm on module purchase.order +- + !workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_po0} +- + 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}: + - state == 'confirmed' +- + I check that an entry gets created in the "Lines to Invoice" of Invoice Control on the basis of purchase order line +- + !python {model: purchase.order}: | + from tools.translate import _ + pur_order_obj=self.browse(cr, uid, ref("purchase_order_po0")) + pur_line=self.pool.get( 'purchase.order.line') + search_ids=pur_line.search(cr, uid, [('order_id', '=', pur_order_obj.name) ]) + assert search_ids, _('Purchase order line is not created!') +- + To check that wizard "Create Invoices" gets called +- + Creating a purchase.order.line_invoice record +- + !record {model: purchase.order.line_invoice, id: purchase_order_line_invoice_0}: + {} +- + Performing an osv_memory action makeInvoices on module purchase.order.line_invoice +- + !python {model: purchase.order.line_invoice}: | + pur_obj=self.pool.get('purchase.order') + ids = [] + pur_id1=pur_obj.browse(cr, uid, ref("purchase_order_po0")) + for line in pur_id1.order_line: + ids.append(line.id) + self.makeInvoices(cr, uid, [1], context={'active_ids': ids}) +- + I check that invoice gets created +- + !python {model: purchase.order}: | + from tools.translate import _ + pur_order_obj=self.browse(cr, uid, ref("purchase_order_po0")) + pur_line=self.pool.get( 'purchase.order.line') + search_ids=pur_line.search(cr, uid, [('order_id', '=', pur_order_obj.name),('invoiced', '=', '1') ]) + assert search_ids, _('Invoice is not created!') +- + I check that a record gets created in the Pending Invoices +- + !python {model: purchase.order}: | + from tools.translate import _ + pur_id1=self.browse(cr, uid, ref("purchase_order_po0")) + account_obj = self.pool.get('account.invoice') + ids = account_obj.search(cr, uid, [('origin', '=', pur_id1.name)]) + assert ids, _('Pending Invoice is not created!') +- + Then an order is approved by clicking on the "Approved by Supplier" button +- + !python {model: purchase.order}: | + self.wkf_approve_order(cr, uid, [ref("purchase_order_po0")]) +- + Performing a workflow action purchase_approve on module purchase.order +- + !workflow {model: purchase.order, action: purchase_approve, ref: purchase_order_po0} +- + I check that the order which was initially in the confirmed state has transit to approved state. +- + !assert {model: purchase.order, id: purchase_order_po0}: + - state == 'approved' +- + I check that date_approve field of Delivery&Invoices gets bind with the date on which it has been approved +- + !python {model: purchase.order}: | + pur_id=self.browse(cr, uid, ref("purchase_order_po0")) + assert(pur_id.date_approve) +- + I check that an entry gets created in the stock.picking +- + !python {model: purchase.order}: | + pur_id=self.browse(cr, uid, ref("purchase_order_po0")) + assert(pur_id.picking_ids) +- + I check that an entry gets created in the stock.move +- + !python {model: purchase.order}: | + from tools.translate import _ + pur_id1=self.browse(cr, uid, ref("purchase_order_po0")) + picking_obj = self.pool.get('stock.picking') + ids = picking_obj.search(cr, uid, [('origin', '=', pur_id1.name)]) + pick_id = picking_obj.browse(cr, uid, ids)[0] + move_obj = self.pool.get('stock.move') + search_id = move_obj.search(cr, uid, [('picking_id', '=', pick_id.name)]) + assert search_id, _('No Incoming Product!') +- + I check that Traceability moves are created +- + I check that an invoice_id field of Delivery&Invoices gets bind with the value +- + !python {model: purchase.order}: | + pur_id2=self.browse(cr, uid, ref("purchase_order_po0")) + assert(pur_id2.invoice_id) diff --git a/addons/purchase/test/purchase_from_picking.yml b/addons/purchase/test/purchase_from_picking.yml new file mode 100644 index 00000000000..f4e9628985d --- /dev/null +++ b/addons/purchase/test/purchase_from_picking.yml @@ -0,0 +1,174 @@ +- + In order to test the purchase flow,I start by creating a new product 'iPod' +- + !record {model: product.product, id: product_product_ipod0}: + categ_id: 'product.product_category_3' + cost_method: standard + mes_type: fixed + name: iPod + 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: 100.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 flow,I create a new record where "invoice_method" is From Picking +- + Creating an purchase.order record +- + !record {model: purchase.order, id: purchase_order_po2}: + company_id: base.main_company + date_order: '2010-05-11' + invoice_method: picking + location_id: stock.stock_location_stock + name: PO00008 + order_line: + - date_planned: '2010-05-13' + name: iPod + price_unit: 100.0 + product_id: 'product_product_ipod0' + 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_po2}: + - state == 'draft' +- + Then an order is confirmed by clicking on the "Confirm Purchase Order" button +- + !python {model: purchase.order}: | + self.wkf_confirm_order(cr, uid, [ref("purchase_order_po2")]) +- + Performing a workflow action purchase_confirm on module purchase.order +- + !workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_po2} +- + I check that the order which was initially in the draft state has transit to confirm state. +- + !assert {model: purchase.order, id: purchase_order_po2}: + - state == 'confirmed' +- + I check that an entry gets created in the "Lines to Invoice" of Invoice Control on the basis of purchase order line +- + !python {model: purchase.order}: | + from tools.translate import _ + pur_order_obj=self.browse(cr, uid, ref("purchase_order_po2")) + pur_line=self.pool.get( 'purchase.order.line') + search_ids=pur_line.search(cr, uid, [('order_id', '=', pur_order_obj.name) ]) + assert search_ids, _('Purchase order line is not created!') +- + To check that wizard "Create Invoices" gets opened +- + Creating a purchase.order.line_invoice record +- + !record {model: purchase.order.line_invoice, id: purchase_order_line_invoice_0}: + {} +- + Performing an osv_memory action makeInvoices on module purchase.order.line_invoice +- + !python {model: purchase.order.line_invoice}: | + pur_obj=self.pool.get('purchase.order') + ids = [] + pur_id1=pur_obj.browse(cr, uid, ref("purchase_order_po2")) + for line in pur_id1.order_line: + ids.append(line.id) + self.makeInvoices(cr, uid, [1], context={'active_ids': ids}) +- + I check that invoice gets created +- + !python {model: purchase.order}: | + from tools.translate import _ + pur_order_obj=self.browse(cr, uid, ref("purchase_order_po2")) + pur_line=self.pool.get( 'purchase.order.line') + search_ids=pur_line.search(cr, uid, [('order_id', '=', pur_order_obj.name),('invoiced', '=', '1') ]) + assert search_ids, _('Invoice is not created!') +- + I check that a record gets created in the Pending Invoices +- + !python {model: purchase.order}: | + from tools.translate import _ + pur_id1=self.browse(cr, uid, ref("purchase_order_po2")) + account_obj = self.pool.get('account.invoice') + ids = account_obj.search(cr, uid, [('origin', '=', pur_id1.name)]) + assert ids, _('Pending Invoice is not created!') +- + Then an order is approved by clicking on the "Approved by Supplier" button +- + !python {model: purchase.order}: | + self.wkf_approve_order(cr, uid, [ref("purchase_order_po2")]) +- + Performing a workflow action purchase_approve on module purchase.order +- + !workflow {model: purchase.order, action: purchase_approve, ref: purchase_order_po2} +- + I check that the order which was initially in the confirmed state has transit to approved state. +- + !assert {model: purchase.order, id: purchase_order_po2}: + - state == 'approved' +- + I check that date_approve field of Delivery&Invoices gets bind with the date on which it has been approved +- + !python {model: purchase.order}: | + pur_id=self.browse(cr, uid, ref("purchase_order_po2")) + assert(pur_id.date_approve) +- + I check that an entry gets created in the stock.picking +- + !python {model: purchase.order}: | + pur_id=self.browse(cr, uid, ref("purchase_order_po2")) + assert(pur_id.picking_ids) +- + I check that an entry gets created in the stock.move +- + !python {model: purchase.order}: | + from tools.translate import _ + pur_id1=self.browse(cr, uid, ref("purchase_order_po2")) + picking_obj = self.pool.get('stock.picking') + ids = picking_obj.search(cr, uid, [('origin', '=', pur_id1.name)]) + pick_id = picking_obj.browse(cr, uid, ids)[0] + move_obj = self.pool.get('stock.move') + search_id = move_obj.search(cr, uid, [('picking_id', '=', pick_id.name)]) + assert search_id, _('No Incoming Product!') +- + I check that Traceability moves are created +- + Then I create an invoice from picking by clicking on "Create Invoice" wizard +- + Creating a stock.invoice.onshipping record +- + !record {model: stock.invoice.onshipping, id: stock_invoice_onshipping_0}: + invoice_date: '2010-05-11' + journal_id: account.bank_journal + type: in_invoice +- + Performing an osv_memory action create_invoice on module stock.invoice.onshipping +- + !python {model: stock.invoice.onshipping}: | + pur_obj=self.pool.get('purchase.order') + pur_id1=pur_obj.browse(cr, uid, ref("purchase_order_po2")) + picking_obj = self.pool.get('stock.picking') + ids = picking_obj.search(cr, uid, [('origin', '=', pur_id1.name)]) + self.create_invoice(cr, uid, [ref("stock_invoice_onshipping_0")], {"lang": "en_US", + "tz": False, "search_default_approved": 1, "active_model": "stock.picking", + "active_ids": ids, "active_id": ids[0], }) +- + I check that an invoice_id field of Delivery&Invoices gets bind with the value +- + !python {model: purchase.order}: | + pur_id2=self.browse(cr, uid, ref("purchase_order_po2")) + assert(pur_id2.invoice_id)