diff --git a/addons/purchase/__openerp__.py b/addons/purchase/__openerp__.py index f5198d57f85..667130a9378 100644 --- a/addons/purchase/__openerp__.py +++ b/addons/purchase/__openerp__.py @@ -60,8 +60,8 @@ Dashboard for purchase management that includes: 'board_purchase_view.xml', ], 'test': [ - 'test/purchase_from_order.yml', - 'test/purchase_from_manual.yml', + 'test/process/requests_quotation.yml', + 'test/process/create_invoice.yml', 'test/purchase_from_picking.yml', 'purchase_unit_test.xml', 'test/procurement_buy.yml', diff --git a/addons/purchase/test/process/create_invoice.yml b/addons/purchase/test/process/create_invoice.yml new file mode 100644 index 00000000000..f7eda79e37f --- /dev/null +++ b/addons/purchase/test/process/create_invoice.yml @@ -0,0 +1,43 @@ +- + 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!') +- + I check that an invoice_ids field of Delivery&Invoices gets bind with the value.#UI +- + !python {model: purchase.order}: | + pur_id2=self.browse(cr, uid, ref("purchase_order_po0")) + assert(pur_id2.invoice_ids) +- + I create invoice for products in the purchase order. +- + !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!') diff --git a/addons/purchase/test/process/requests_quotation.yml b/addons/purchase/test/process/requests_quotation.yml new file mode 100644 index 00000000000..bdc3cf3de3d --- /dev/null +++ b/addons/purchase/test/process/requests_quotation.yml @@ -0,0 +1,37 @@ +- + In order to test the purchase flow, I start it from the Quotation. +- + First of all I create a request for quotation. +- + I want to buy 'Metal Cleats' product for a supplier but the purchase is not confirmed yet. +- + !record {model: purchase.order, id: purchase_order_po0}: + 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: Metal Cleats + price_unit: 100.0 + product_id: product.product_product_metalcleats0 + 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' +- + I confirm the purchase order for Metal Cleats. +- + !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 == 'approved' diff --git a/addons/purchase/test/purchase_from_manual.yml b/addons/purchase/test/purchase_from_manual.yml deleted file mode 100644 index e46473bd927..00000000000 --- a/addons/purchase/test/purchase_from_manual.yml +++ /dev/null @@ -1,133 +0,0 @@ -- - 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 -- - I create purchase order for iPod. -- - !record {model: purchase.order, id: purchase_order_po1}: - company_id: base.main_company - date_order: !eval time.strftime('%Y-%m-%d') - invoice_method: manual - location_id: stock.stock_location_stock - order_line: - - date_planned: !eval time.strftime('%Y-%m-%d') - 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' -- - I confirm the 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 == 'approved' -- - 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 -- - I create purchase order line invoice entry. -- - !record {model: purchase.order.line_invoice, id: purchase_order_line_invoice_0}: - {} -- - I create invoice for products in the purchase order. -- - !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!') -- - 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 pickings. -- - !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 moves. -- - !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 deleted file mode 100644 index 8e46899f8a0..00000000000 --- a/addons/purchase/test/purchase_from_order.yml +++ /dev/null @@ -1,146 +0,0 @@ -- - 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. -- - I create purchase order for iPod. -- - !record {model: purchase.order, id: purchase_order_po0}: - 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: 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' -- - 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. -- - !assert {model: purchase.order, id: purchase_order_po0}: - - state == 'approved' -- - 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. -- - I create purchase order line invoice entry. -- - !record {model: purchase.order.line_invoice, id: purchase_order_line_invoice_0}: - {} -- - I create invoice for products in the purchase order. -- - !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!') -- - 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 pickings. -- - !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 moves. -- - !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_ids 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_ids)