[IMP] purchase: test case improvement
* rfq2order2done - test case of process RFQ->confirm RFQ->Done RFQ. * generate_invoice_from_reception - test case of process to generate invoice on delivery of product. * run_scheduler - test case of process to run scheduler to generete RFQ from procurement. * merge_order - test case to merge orders * cancel_order - test case to cancel confirmed order, draft order * print_report - test case to generate report of RFQ and purchase order. * onchange_events - test case to test onchange_events like onchange_partner, onchange_warehouse, onchange_address * duplicate_order - test case to test duplicate order. * delete_order - test case to test delete confirmed order, draft order and canceled order. bzr revid: hmo@tinyerp.com-20111020072225-jq2r5x70z12a15o8
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
-
|
||||
In order to test to cancel confirmed purchase order.
|
||||
-
|
||||
First I cancel receptions related to this order if order shipped.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
order = self.browse(cr, uid, ref("order_purchase1"))
|
||||
self.pool.get('stock.picking').action_cancel(cr, uid, [picking.id for picking in order.picking_ids])
|
||||
|
||||
-
|
||||
I check order status in "Shipping Exception".
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
order = self.browse(cr, uid, ref("order_purchase1"))
|
||||
assert order.state == "except_picking", "order should be in Ship Exception state after cancel shipment"
|
||||
|
||||
-
|
||||
Now I cancel invoice related to this order if order invoiced.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
order = self.browse(cr, uid, ref("order_purchase1"))
|
||||
self.pool.get('account.invoice').action_cancel(cr, uid, [invoice.id for invoice in order.invoice_ids])
|
||||
|
||||
-
|
||||
I check order status in "Invoice Exception".
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
order = self.browse(cr, uid, ref("order_purchase1"))
|
||||
assert order.state == "except_invoice", "order should be in Invoice Exception state after cancel invoice"
|
||||
-
|
||||
Now I am able to cancel purchase order.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
self.action_cancel(cr, uid, [ref("order_purchase1")])
|
||||
|
||||
-
|
||||
I check that order is cancelled.
|
||||
-
|
||||
!assert {model: purchase.order, id: order_purchase1}:
|
||||
- state == 'cancel'
|
||||
-
|
||||
Now again set cancelled order to draft.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
self.action_cancel_draft(cr, uid, [ref("order_purchase1")])
|
||||
|
||||
-
|
||||
Now I again to cancel draft order.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
self.action_cancel(cr, uid, [ref("order_purchase1")])
|
||||
|
||||
-
|
||||
I check that order is cancelled.
|
||||
-
|
||||
!assert {model: purchase.order, id: order_purchase1}:
|
||||
- state == 'cancel'
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
-
|
||||
I confirm another order where invoice control is 'Based on receptions'.
|
||||
-
|
||||
!workflow {model: purchase.order, action: purchase_confirm, ref: order_purchase2}
|
||||
-
|
||||
I check that the invoice of order.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
purchase_order = self.browse(cr, uid, ref("order_purchase2"))
|
||||
assert len(purchase_order.invoice_ids) == 0, "Invoice should not be generated on order confirmation."
|
||||
-
|
||||
Now I create an invoice for order on reception.
|
||||
-
|
||||
!python {model: stock.picking}: |
|
||||
pick_ids = self.search(cr, uid, [('purchase_id','=',ref('order_purchase2'))])
|
||||
self.action_invoice_create(cr, uid, pick_ids, ref('account.expenses_journal'))
|
||||
-
|
||||
I check that the invoice of order.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
purchase_order = self.browse(cr, uid, ref("order_purchase2"))
|
||||
assert len(purchase_order.invoice_ids) == 1, "Invoice should be generated."
|
||||
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
-
|
||||
I create reception for order where invoice control is 'Based on receptions'.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
self.action_picking_create(cr, uid, [ref("order_purchase2")])
|
||||
-
|
||||
I create reception for order where invoice control is 'Based on receptions'.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
self.action_invoice_create(cr, uid, [ref("order_purchase2")])
|
||||
-
|
||||
Reception is ready for process so now done the process.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
pick_ids = [x.id for x in self.browse(cr, uid, ref("order_purchase2")).picking_ids]
|
||||
self.pool.get('stock.picking').validate_picking(cr, uid, pick_ids)
|
||||
-
|
||||
I create an invoice for order by clicking on "Create Invoice" wizard
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
|
||||
stock = self.pool.get('stock.picking')
|
||||
pick_ids = [x.id for x in self.browse(cr, uid, ref("order_purchase2")).picking_ids]
|
||||
stock.action_invoice_create(cr, uid,pick_ids, ref('account.expenses_journal'))
|
||||
-
|
||||
Now,put all Purchase Order invoice in open state.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
import netsvc
|
||||
purchase = self.pool.get('purchase.order')
|
||||
invoice_ids = [x.id for x in purchase.browse(cr, uid, ref("order_purchase2")).invoice_ids]
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for invoice in invoice_ids:
|
||||
wf_service.trg_validate(uid, 'account.invoice', invoice, 'invoice_open', cr)
|
||||
-
|
||||
I check that purchase order is invoiced & paid or it's shipped.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
assert self.browse(cr, uid, ref("order_purchase2")).shipped == True,"Reception is not delivered"
|
||||
@@ -0,0 +1,34 @@
|
||||
-
|
||||
In order to merge RFQ, I merge two RFQ which has same supplier and check new merged order.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
new_id = self.do_merge(cr, uid, [ref('order_purchase3'), ref('order_purchase7')])
|
||||
order3 = self.browse(cr, uid, ref('order_purchase3'))
|
||||
order7 = self.browse(cr, uid, ref('order_purchase7'))
|
||||
assert order3.state == 'cancel', "Merged order should be canceled"
|
||||
assert order7.state == 'cancel', "Merged order should be canceled"
|
||||
|
||||
def merge(lines, product_id):
|
||||
res = {}
|
||||
for line in lines:
|
||||
if product_id == line.product_id.id:
|
||||
res[product_id] += line.qty
|
||||
return res
|
||||
for order in self.browse(cr, uid, new_id.keys()):
|
||||
assert order.partner_id and order3.partner_id and order7.partner_id, "Supplier are not corresponded"
|
||||
total_lines = 0
|
||||
for line in order.lines:
|
||||
qty3 = merge(order3.lines, line.product_id.id)
|
||||
qty7 = merge(order7.lines, line.product_id.id)
|
||||
qty = 0
|
||||
if line.product_id.id in qty3:
|
||||
qty += qty3[line.product_id.id]
|
||||
elif line.product_id.id in qty7:
|
||||
qty += qty7[line.product_id.id]
|
||||
else:
|
||||
raise AssertionError('product line does not corresponding')
|
||||
assert line.qty == qty, 'merged quantity is not proper'
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
-
|
||||
In order to merge purchase orders, I have to check some condition.
|
||||
Like PO must in Draft state.
|
||||
PO belong to same suppliers.
|
||||
PO have same stock location and same price list.
|
||||
-
|
||||
Initially purchase order is in the draft state for merging those orders.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
assert self.browse(cr, uid, ref("order_purchase3")).state == 'draft',"Purchase order should be in draft state"
|
||||
-
|
||||
I have to merge the purchase order so for that I create one duplicate order.
|
||||
-
|
||||
!python {model: purchase.order.group}: |
|
||||
purchase = self.pool.get('purchase.order')
|
||||
purchase_id = purchase.copy(cr, uid, ref("order_purchase3"))
|
||||
assert purchase.browse(cr, uid, purchase_id).state == 'draft',"Purchase order(copy) should be draft"
|
||||
self.merge_orders(cr, uid, [1], {'active_ids':[ref('order_purchase3'),purchase_id],'active_model': 'purchase.order','active_id':ref('order_purchase3')})
|
||||
assert purchase.browse(cr, uid, ref("order_purchase3")).state == 'cancel',"Purchase order should be cancelled"
|
||||
assert purchase.browse(cr, uid, purchase_id).state == 'cancel',"After merge purchase order(copy) should be cancelled"
|
||||
@@ -1,104 +0,0 @@
|
||||
-
|
||||
In order to test the procurement with product type buy in OpenERP, I will check product with 'buy' type
|
||||
and then I will create procurement for this product.
|
||||
-
|
||||
I modify the product and add the details of seller.
|
||||
-
|
||||
!record {model: product.product, id: product.product_product_woodlintelm0}:
|
||||
seller_delay: '1'
|
||||
seller_ids:
|
||||
- delay: 1
|
||||
name: base.res_partner_asus
|
||||
min_qty: 2.0
|
||||
qty: 5.0
|
||||
-
|
||||
I check that the product 'Wood Lintel' with 'buy' supply type or not
|
||||
-
|
||||
!assert {model: product.product, id: product.product_product_woodlintelm0}:
|
||||
- supply_method == 'buy'
|
||||
-
|
||||
I create procurement order.
|
||||
-
|
||||
!record {model: procurement.order, id: procurement_order_testcase0}:
|
||||
company_id: base.main_company
|
||||
date_planned: !eval time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
location_id: stock.stock_location_stock
|
||||
name: Test Case
|
||||
priority: '1'
|
||||
procure_method: make_to_order
|
||||
product_id: product.product_product_woodlintelm0
|
||||
product_qty: 5.0
|
||||
product_uom: product.product_uom_unit
|
||||
product_uos: product.product_uom_unit
|
||||
product_uos_qty: 0.0
|
||||
state: draft
|
||||
-
|
||||
I confirm on procurement order.
|
||||
-
|
||||
!workflow {model: procurement.order, action: button_confirm, ref: procurement_order_testcase0}
|
||||
-
|
||||
I run the scheduler.
|
||||
-
|
||||
!function {model: procurement.order, name: run_scheduler}:
|
||||
- model: procurement.order
|
||||
search: "[]"
|
||||
|
||||
-
|
||||
I check that purchase order is generated.
|
||||
-
|
||||
!python {model: procurement.order}: |
|
||||
from tools.translate import _
|
||||
proc_ids = self.browse(cr, uid, [ref('procurement_order_testcase0')])[0]
|
||||
assert(proc_ids.purchase_id), _('Purchase Order is not Created!')
|
||||
-
|
||||
I check the state is running.
|
||||
-
|
||||
!python {model: procurement.order}: |
|
||||
from tools.translate import _
|
||||
proc_ids = self.browse(cr, uid, [ref('procurement_order_testcase0')])[0]
|
||||
assert(proc_ids.state == 'running'), _('Exception')
|
||||
-
|
||||
I confirm and Approve the purchase order.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
procurement_obj = self.pool.get('procurement.order')
|
||||
proc_ids = procurement_obj.browse(cr, uid, [ref('procurement_order_testcase0')])[0]
|
||||
import netsvc
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'purchase.order',proc_ids.purchase_id.id,'purchase_confirm', cr)
|
||||
-
|
||||
I receive the order of the supplier ASUStek from the Incoming Shipments menu.
|
||||
-
|
||||
!python {model: stock.picking }: |
|
||||
import time
|
||||
procurement_obj = self.pool.get('procurement.order')
|
||||
proc_ids = procurement_obj.browse(cr, uid, [ref('procurement_order_testcase0')])[0]
|
||||
picking_ids = self.search(cr, uid, [('purchase_id', '=', proc_ids.purchase_id.id),('type','=','in')])
|
||||
pickings = self.browse(cr, uid, picking_ids)
|
||||
for picking in pickings:
|
||||
move = picking.move_lines[0]
|
||||
partial_datas = {
|
||||
'partner_id': picking.address_id.partner_id.id,
|
||||
'address_id': picking.address_id.id,
|
||||
'delivery_date' : time.strftime('%Y-%m-%d')
|
||||
}
|
||||
partial_datas['move%s'%(move.id)]= {
|
||||
'product_id': move.product_id,
|
||||
'product_qty': move.product_qty,
|
||||
'product_uom': move.product_uom.id,
|
||||
}
|
||||
self.do_partial(cr, uid, [picking.id], partial_datas)
|
||||
-
|
||||
I confirm the Reservation.
|
||||
-
|
||||
!python {model: stock.move }: |
|
||||
procurement_obj = self.pool.get('procurement.order')
|
||||
proc_ids = procurement_obj.browse(cr, uid, [ref('procurement_order_testcase0')])[0]
|
||||
self.action_done(cr,uid,[proc_ids.move_id.id])
|
||||
-
|
||||
I check the state is Done.
|
||||
-
|
||||
!python {model: procurement.order}: |
|
||||
from tools.translate import _
|
||||
proc_ids = self.browse(cr, uid, [ref('procurement_order_testcase0')])[0]
|
||||
assert(proc_ids.state == 'done'), _('Order is not in done state')
|
||||
@@ -1,68 +0,0 @@
|
||||
-
|
||||
In order to test to cancel purchase order from Different State,I start cancel the draft order.
|
||||
-
|
||||
Initially purchase order is in the draft state.
|
||||
-
|
||||
!assert {model: purchase.order, id: order_purchase5}:
|
||||
- state == 'draft'
|
||||
-
|
||||
I want to cancel order form draft state.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
try:
|
||||
self.action_cancel(cr, uid, [ref("order_purchase5")])
|
||||
except Exception, e:
|
||||
pass
|
||||
-
|
||||
I check that order is in the cancel state.
|
||||
-
|
||||
!assert {model: purchase.order, id: order_purchase5}:
|
||||
- state == 'cancel'
|
||||
-
|
||||
Now again set purchase order to draft state.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
try:
|
||||
self.action_cancel_draft(cr, uid, [ref("order_purchase5")])
|
||||
except Exception, e:
|
||||
pass
|
||||
-
|
||||
Now I confirm the this order.
|
||||
-
|
||||
!workflow {model: purchase.order, action: purchase_confirm, ref: order_purchase5}
|
||||
-
|
||||
I check that order is in the confirm state.
|
||||
-
|
||||
!assert {model: purchase.order, id: order_purchase5}:
|
||||
- state == 'approved'
|
||||
-
|
||||
I want to cancel order form confirm state.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
try:
|
||||
self.action_cancel(cr, uid, [ref("order_purchase5")])
|
||||
except Exception, e:
|
||||
pass
|
||||
-
|
||||
I have to must first cancel all receptions related to this purchase order.
|
||||
-
|
||||
!python {model: stock.picking}: |
|
||||
search_ids=self.search(cr, uid, [('purchase_id', '=', ref("order_purchase5"))])
|
||||
try:
|
||||
self.action_cancel(cr, uid, search_ids)
|
||||
except Exception, e:
|
||||
pass
|
||||
-
|
||||
Now I am able to cancel purchase order because related picking was cancel.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
try:
|
||||
self.action_cancel(cr, uid, [ref("order_purchase5")])
|
||||
except Exception, e:
|
||||
pass
|
||||
-
|
||||
I check that order is in the cancel state.
|
||||
-
|
||||
!assert {model: purchase.order, id: order_purchase5}:
|
||||
- state == 'cancel'
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
-
|
||||
In order to test to delete purchase order from Different State,I start delete the draft order.
|
||||
-
|
||||
I have to first delete draft purchase order.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
copy_id = self.copy(cr, uid, ref("order_purchase3"))
|
||||
assert self.browse(cr, uid,[order_purchase4]).state == "draft", "Purchase order should be draft"
|
||||
try:
|
||||
self.unlink(cr, uid, [copy_id])
|
||||
except Exception, e:
|
||||
pass
|
||||
-
|
||||
I want to delete confirm purchase order.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
assert self.browse(cr, uid,[order_purchase4]).state == "approve", "Purchase order should be Confirm"
|
||||
try:
|
||||
self.unlink(cr, uid, [ref("order_purchase4")])
|
||||
except Exception, e:
|
||||
pass
|
||||
-
|
||||
I want to delete cancelled purchase order.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
copy_id = self.copy(cr, uid, ref("order_purchase5"))
|
||||
self.action_cancel(cr, uid, [copy_id])
|
||||
assert self.browse(cr, uid,[copy_id]).state == "cancel", "Purchase order should be cancelled"
|
||||
try:
|
||||
self.unlink(cr, uid, [copy_id])
|
||||
except Exception, e:
|
||||
pass
|
||||
-
|
||||
I want to delete done purchase order.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
assert self.browse(cr, uid,[ref("test_purchase_1")]).state == "done", "Purchase order should be done"
|
||||
try:
|
||||
self.unlink(cr, uid, [ref("test_purchase_1")])
|
||||
except Exception, e:
|
||||
pass
|
||||
@@ -0,0 +1,103 @@
|
||||
-
|
||||
In order to test the purchase order flow, I compute the total of the listed products.
|
||||
"Basic PC" product price is 450.20 and ordered 2 'PCE'
|
||||
"New server config + material" product price is 150.50 and ordered 5 'PCE'
|
||||
So, Total should be [(450.20*2)+(150.50*5)] = 1652.90
|
||||
-
|
||||
I check the total untaxed amount of the RFQ is correctly computed
|
||||
-
|
||||
!assert {model: purchase.order, id: order_purchase1, string: The amount of Test purchase is correctly computed}:
|
||||
- sum([l.price_subtotal for l in order_line]) == amount_untaxed
|
||||
-
|
||||
I confirm the RFQ.
|
||||
-
|
||||
!workflow {model: purchase.order, action: purchase_confirm, ref: order_purchase1}
|
||||
-
|
||||
I check the "Approved" status after confirmed RFQ.
|
||||
-
|
||||
!assert {model: purchase.order, id: order_purchase1}:
|
||||
- state == 'approved'
|
||||
-
|
||||
I check that the invoice details which is generated after confirmed RFQ.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
purchase_order = self.browse(cr, uid, ref("order_purchase1"))
|
||||
assert len(purchase_order.invoice_ids) == 1, "Invoice is not generated more or less than one"
|
||||
for invoice in purchase_order.invoice_ids:
|
||||
assert invoice.state == "draft", "Invoice state should be draft"
|
||||
assert invoice.partner_id == purchase_order.partner_id, "Supplier is not correspond with purchase order"
|
||||
assert invoice.reference == purchase_order.partner_ref or purchase_order.name,"Invoice reference is not correspond with purchase order"
|
||||
assert invoice.account_id == purchase_order.partner_id.property_account_payable ,"Invoice account is not correspond with purchase order"
|
||||
assert invoice.type == 'in_invoice',"Invoice type is not correspond with purchase order"
|
||||
assert invoice.currency_id == purchase_order.pricelist_id.currency_id ,"Invoice currency is not correspond with purchase order"
|
||||
assert invoice.address_invoice_id == purchase_order.partner_address_id ,"Invoice address is not correspond with purchase order"
|
||||
assert invoice.address_contact_id == purchase_order.partner_address_id ,"Invoice contact details are not correspond with purchase order"
|
||||
assert invoice.origin == purchase_order.name,"Invoice origin is not correspond with purchase order"
|
||||
assert invoice.company_id == purchase_order.company_id ,"Invoice company is not correspond with purchase order"
|
||||
assert invoice.name == purchase_order.name, "Invoice name is not correspond with purchase order"
|
||||
assert invoice.amount_untaxed == purchase_order.amount_untaxed, "Invoice untaxed amount is not correspond with purchase order"
|
||||
assert invoice.amount_tax == purchase_order.amount_tax, "Invoice tax amount is not correspond with purchase order"
|
||||
assert invoice.amount_total == purchase_order.amount_total, "Invoice total amount is not correspond with purchase order"
|
||||
assert len(invoice.invoice_line) == len(purchase_order.order_line), "Lines of Invoice and Purchase Order are not correspond"
|
||||
for index in range(0,len(invoice.invoice_line)):
|
||||
assert invoice.invoice_line[index].product_id == purchase_order.order_line[index].product_id or False,"Product is not correspond"
|
||||
assert invoice.invoice_line[index].name == purchase_order.order_line[index].name, "Product description is not correspond"
|
||||
assert invoice.invoice_line[index].price_unit == purchase_order.order_line[index].price_unit or 0.0, "Unit price is not correspond"
|
||||
assert invoice.invoice_line[index].quantity == purchase_order.order_line[index].product_qty,"Quantity is not correspond"
|
||||
assert invoice.invoice_line[index].uos_id == purchase_order.order_line[index].product_uom or False,"UOM is not correspond"
|
||||
assert len(invoice.invoice_line[index].invoice_line_tax_id) == len(purchase_order.order_line[index].taxes_id), "Taxes are not correspond"
|
||||
for tax in range(0,len(invoice.invoice_line[index].invoice_line_tax_id)):
|
||||
assert invoice.invoice_line[index].invoice_line_tax_id[tax] == purchase_order.order_line[index].taxes_id[tax], "Tax is not correspond"
|
||||
|
||||
-
|
||||
I check that Reception details after confirmed RFQ.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
purchase_order = self.browse(cr, uid, ref("order_purchase1"))
|
||||
assert len(purchase_order.picking_ids) == 1, "Reception should be one"
|
||||
for picking in purchase_order.picking_ids:
|
||||
assert picking.state == "assigned", "Reception state should be in assigned state"
|
||||
assert picking.address_id == purchase_order.dest_address_id or purchase_order.partner_address_id ,"Delivery Address of Reception is not correspond"
|
||||
if purchase_order.invoice_method == 'picking':
|
||||
assert picking.invoice_state == '2binvoiced',"Invoice state should be 'To be Invoiced' on Reception."
|
||||
elif purchase_order.invoice_method == 'picking':
|
||||
assert picking.invoice_state == 'invoiced',"Invoice state should be 'Invoiced' on Reception."
|
||||
else:
|
||||
assert picking.invoice_state == 'none',"Invoice state should Not be applicable on Reception."
|
||||
assert picking.company_id == purchase_order.company_id ,"Company is not correspond with purchase order"
|
||||
for index in range(0,len(picking.move_lines)):
|
||||
assert picking.move_lines[index].product_id == purchase_order.order_line[index].product_id, "Product is not correspond"
|
||||
assert picking.move_lines[index].location_dest_id == purchase_order.location_id, "Destination Location is not correspond"
|
||||
assert picking.move_lines[index].product_uom == purchase_order.order_line[index].product_uom, "UOM is not correspond"
|
||||
assert picking.move_lines[index].product_qty == purchase_order.order_line[index].product_qty, "Quantity is not correspond"
|
||||
assert picking.move_lines[index].product_uos_qty == purchase_order.order_line[index].product_qty,"UOS Quantity is not correspond"
|
||||
assert picking.move_lines[index].product_uos == purchase_order.order_line[index].product_uom ,"UOS is not correspond"
|
||||
assert picking.move_lines[index].price_unit == purchase_order.order_line[index].price_unit ,"Price unit is not correspond"
|
||||
|
||||
-
|
||||
Reception is ready for process so now done the reception.
|
||||
-
|
||||
!python {model: stock.picking}: |
|
||||
pick_ids = self.search(cr, uid, [('purchase_id','=',ref('order_purchase1'))])
|
||||
self.validate_picking(cr, uid, pick_ids)
|
||||
-
|
||||
I check that purchase order is shipped.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
assert self.browse(cr, uid, ref("order_purchase1")).shipped == True,"Purchase order should be delivered"
|
||||
|
||||
-
|
||||
I Validate Invoice of Purchase Order.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
import netsvc
|
||||
invoice_ids = [x.id for x in self.browse(cr, uid, ref("order_purchase1")).invoice_ids]
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for invoice in invoice_ids:
|
||||
wf_service.trg_validate(uid, 'account.invoice', invoice, 'invoice_open', cr)
|
||||
-
|
||||
I check that purchase order is invoiced.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
assert self.browse(cr, uid, ref("order_purchase1")).invoiced == True,"Purchase Order should be invoiced"
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
-
|
||||
In order to test the purchase flow, I compute the total of the listed products.
|
||||
"Basic PC" product price is 450.20 and ordered 2 'PCE'
|
||||
"New server config + material" product price is 150.50 and ordered 5 'PCE'
|
||||
So, Total should be [(450.20*2)+(150.50*5)] = 1652.90
|
||||
-
|
||||
I check the amount of the RFQ is correctly computed
|
||||
-
|
||||
!assert {model: purchase.order, id: order_purchase1, string: The amount of Test purchase is correctly computed}:
|
||||
- sum([l.price_subtotal for l in order_line]) == amount_untaxed
|
||||
-
|
||||
I confirm the RFQ.
|
||||
-
|
||||
!workflow {model: purchase.order, action: purchase_confirm, ref: order_purchase1}
|
||||
-
|
||||
I check the created Purchase order.
|
||||
-
|
||||
!assert {model: purchase.order, id: order_purchase1}:
|
||||
- state == 'approved'
|
||||
-
|
||||
I check that the purchase order has now a corresponding invoice details
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
purchase_order = self.browse(cr, uid, ref("order_purchase1"))
|
||||
assert len(purchase_order.invoice_ids) == 1,"Invoice line is not more or less than one"
|
||||
for invoice in purchase_order.invoice_ids:
|
||||
if purchase_order.invoiced == True:
|
||||
assert invoice.state == "open", "Invoice state should be Open"
|
||||
else:
|
||||
assert invoice.state == "draft", "Invoice state should be draft"
|
||||
assert invoice.reference == purchase_order.partner_ref or purchase_order.name,"Invoice reference is not correspond with purchase order"
|
||||
assert invoice.account_id == purchase_order.partner_id.property_account_payable ,"Invoice account_id is not correspond with purchase order"
|
||||
assert invoice.type == 'in_invoice',"Invoice type is not correspond with purchase order"
|
||||
assert invoice.currency_id == purchase_order.pricelist_id.currency_id ,"Invoice currency_id is not correspond with purchase order"
|
||||
assert invoice.address_invoice_id == purchase_order.partner_address_id ,"Invoice address_invoice is not correspond with purchase order"
|
||||
assert invoice.address_contact_id == purchase_order.partner_address_id ,"Invoice address_contact is not correspond with purchase order"
|
||||
assert invoice.origin == purchase_order.name,"Invoice origin is not correspond with purchase order"
|
||||
assert invoice.company_id == purchase_order.company_id ,"Invoice company is not correspond with purchase order"
|
||||
assert invoice.name == purchase_order.name, "Invoice name is not correspond with purchase order"
|
||||
assert invoice.amount_untaxed == purchase_order.amount_untaxed, "Invoice untaxed amount is not correspond with purchase order"
|
||||
assert invoice.amount_tax == purchase_order.amount_tax, "Invoice tax amount is not correspond with purchase order"
|
||||
assert invoice.amount_total == purchase_order.amount_total, "Invoice total amount is not correspond with purchase order"
|
||||
assert invoice.partner_id == purchase_order.partner_id, "Invoice supplier is not correspond with purchase order"
|
||||
assert len(invoice.invoice_line) == len(purchase_order.order_line), "Invoice line is not correspond with puchase order line"
|
||||
for index in range(0,len(invoice.invoice_line)):
|
||||
assert invoice.invoice_line[index].price_unit == purchase_order.order_line[index].price_unit, "Invoice unit price is not correspond with purchase order"
|
||||
assert invoice.invoice_line[index].name == purchase_order.order_line[index].name,"Invoice product is not correspond with purchase order"
|
||||
assert invoice.invoice_line[index].price_unit == purchase_order.order_line[index].price_unit or 0.0,"Invoice product is not correspond with purchase order"
|
||||
assert invoice.invoice_line[index].quantity == purchase_order.order_line[index].product_qty,"Invoice product is not correspond with purchase order"
|
||||
assert invoice.invoice_line[index].product_id == purchase_order.order_line[index].product_id or False,"Invoice product is not correspond with purchase order"
|
||||
assert invoice.invoice_line[index].uos_id == purchase_order.order_line[index].product_uom or False,"Invoice product is not correspond with purchase order"
|
||||
assert len(invoice.invoice_line[index].invoice_line_tax_id) == len(purchase_order.order_line[index].taxes_id), "Included Taxes line for products is not correspond with puchase order line"
|
||||
for tax in range(0,len(invoice.invoice_line[index].invoice_line_tax_id)):
|
||||
assert invoice.invoice_line[index].invoice_line_tax_id[tax].name == purchase_order.order_line[index].taxes_id[tax].name,"Invoice Taxes of products are not correspond with purchase order Taxes products"
|
||||
|
||||
-
|
||||
I check that the purchase order has now a corresponding Reception.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
purchase_order = self.browse(cr, uid, ref("order_purchase1"))
|
||||
assert len(purchase_order.picking_ids) == 1, "Reception line should be one"
|
||||
for picking in purchase_order.picking_ids:
|
||||
assert picking.state == "assigned", "Reception state should be in assigned state"
|
||||
assert picking.address_id == purchase_order.dest_address_id or purchase_order.partner_address_id ,"Reception product is not correspond with purchase order"
|
||||
if purchase_order.invoice_method == 'picking':
|
||||
assert picking.invoice_state == '2binvoiced',"Reception Invoice state should be 2binvoiced if it's Based on receptions "
|
||||
elif purchase_order.invoice_method == 'picking':
|
||||
assert picking.invoice_state == 'invoiced',"Reception Invoice state should be invoiced."
|
||||
else:
|
||||
assert picking.invoice_state == 'none',"Reception Invoice state should be Not applicable if it's invoice method is 'Draft invoices pre-generated'"
|
||||
assert picking.company_id == purchase_order.company_id ,"Reception company is not correspond with purchase order"
|
||||
for index in range(0,len(picking.move_lines)):
|
||||
assert picking.move_lines[index].product_id == purchase_order.order_line[index].product_id, "Reception product is not correspond with purchase order"
|
||||
assert picking.move_lines[index].location_dest_id == purchase_order.location_id, "Reception location is not correspond with purchase order"
|
||||
assert picking.move_lines[index].product_uom == purchase_order.order_line[index].product_uom, "Reception uom is not correspond with purchase order"
|
||||
assert picking.move_lines[index].product_qty == purchase_order.order_line[index].product_qty, "Reception qty is not correspond with purchase order"
|
||||
assert picking.move_lines[index].product_id == purchase_order.order_line[index].product_id ,"Reception products is not correspond with purchase order"
|
||||
assert picking.move_lines[index].product_uos_qty == purchase_order.order_line[index].product_qty,"Reception product uos qty is not correspond with purchase order"
|
||||
assert picking.move_lines[index].product_uom == purchase_order.order_line[index].product_uom ,"Reception product UOM is not correspond with purchase order"
|
||||
assert picking.move_lines[index].product_uos == purchase_order.order_line[index].product_uom ,"Reception product UOS is not correspond with purchase order"
|
||||
assert picking.move_lines[index].location_dest_id == purchase_order.location_id,"Reception Destination Location is not correspond with purchase order"
|
||||
assert picking.move_lines[index].company_id == purchase_order.company_id ,"Reception Company is not correspond with purchase order"
|
||||
assert picking.move_lines[index].price_unit == purchase_order.order_line[index].price_unit ,"Reception Price unit is not correspond with purchase order"
|
||||
@@ -0,0 +1,31 @@
|
||||
-
|
||||
In order to test the scheduler to generate RFQ.
|
||||
-
|
||||
I create procurement order.
|
||||
-
|
||||
!record {model: procurement.order, id: procurement_order_testcase0}:
|
||||
company_id: base.main_company
|
||||
date_planned: !eval time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
location_id: stock.stock_location_stock
|
||||
name: Test scheduler for RFQ
|
||||
procure_method: make_to_order
|
||||
product_id: product.product_product_woodlintelm0
|
||||
product_qty: 15.0
|
||||
product_uom: product.product_uom_unit
|
||||
-
|
||||
I confirm on procurement order.
|
||||
-
|
||||
!workflow {model: procurement.order, action: button_confirm, ref: procurement_order_testcase0}
|
||||
-
|
||||
I run the scheduler.
|
||||
-
|
||||
!python {model: procurement.order}: |
|
||||
self.run_scheduler(cr, uid)
|
||||
|
||||
-
|
||||
I check Generated RFQ.
|
||||
-
|
||||
!python {model: procurement.order}: |
|
||||
procurement = self.browse(cr, uid, ref('procurement_order_testcase0'))
|
||||
assert procurement.purchase_id, 'RFQ should be generated!'
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
-
|
||||
In order to test to delete process on purchase order.
|
||||
-
|
||||
I try to delete confirmed order and check Error Message.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
try:
|
||||
self.unlink(cr, uid, [ref("order_purchase1")])
|
||||
except Exception,e:
|
||||
print e
|
||||
-
|
||||
I delete draft order.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
self.unlink(cr, uid, [ref("order_purchase5")])
|
||||
-
|
||||
I delete cancelled order.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
self.unlink(cr, uid, [ref("order_purchase7")])
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
-
|
||||
In order to test the duplicate order and check duplicate details.
|
||||
-
|
||||
I duplicate order.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
self.copy(cr, uid, ref('order_purchase1'))
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
-
|
||||
In order to test the onchange events of order.
|
||||
-
|
||||
I call onchange event to change the warehouse of order.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
self.onchange_warehouse_id(cr, uid, [ref('order_purchase1')], ref('stock.stock_warehouse_shop1'))
|
||||
-
|
||||
I call onchange event to change the supplier of order.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
self.onchange_partner_id(cr, uid, ref('order_purchase1'), ref('base.res_partner_3'))
|
||||
-
|
||||
I call onchange event to change the supplier address of order.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
self.onchange_dest_address_id(cr, uid, [ref('order_purchase1')], ref('base.res_partner_address_8'))
|
||||
|
||||
-
|
||||
I call onchange event to change the product of order line.
|
||||
-
|
||||
!python {model: purchase.order.line}: |
|
||||
self.product_id_change(cr, uid, [ref('line1_purchase')], ref('purchase.list0'), ref('product.product_product_pc3'), 400, ref('product.product_uom_unit'), ref('base.res_partner_3'))
|
||||
|
||||
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
-
|
||||
In order to test the private methods of PO, I will call each private methods with propar details.
|
||||
-
|
||||
I want to buy 'Metal Cleats' product for a supplier but the purchase is not confirmed yet.
|
||||
-
|
||||
!record {model: purchase.order, id: purchase_order_0}:
|
||||
company_id: base.main_company
|
||||
date_order: !eval time.strftime('%Y-%m-%d')
|
||||
invoice_method: order
|
||||
location_id: stock.stock_location_suppliers
|
||||
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
|
||||
-
|
||||
I cahnge the warehouse for PO.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
self.onchange_warehouse_id(cr, uid, [ref('purchase_order_0')],1)
|
||||
-
|
||||
I test for Copy and unlink Purchase order in Draft state.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
copy_id = self.copy(cr, uid, ref("purchase_order_0"))
|
||||
context.update({'active_ids': copy_id})
|
||||
self.unlink(cr, uid, [copy_id], context)
|
||||
-
|
||||
I cahnge the partner for PO.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
part = ref('base.res_partner_3')
|
||||
self.onchange_partner_id(cr, uid, ref('purchase_order_0'), part)
|
||||
-
|
||||
I click on botton Dummy for compute the total amount.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
self.button_dummy(cr, uid, [ref('purchase_order_0')], context=None)
|
||||
-
|
||||
I cahnge the partner address for PO.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
address_id = ref('base.res_partner_address_8')
|
||||
self.onchange_dest_address_id(cr, uid, [ref('purchase_order_0')], address_id)
|
||||
-
|
||||
I Warn the buyer regarding the "Purchase amount".
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
self.wkf_warn_buyer(cr, uid, [ref('purchase_order_0')])
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
-
|
||||
In order to test the PDF reports defined on a Purchase Order, we will print a Request Quotation report
|
||||
In order to test the PDF reports defined on a Purchase Order, I print a Request Quotation report
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
import netsvc, tools, os
|
||||
@@ -7,7 +7,7 @@
|
||||
if tools.config['test_report_directory']:
|
||||
file(os.path.join(tools.config['test_report_directory'], 'purchase-request_quotation'+format), 'wb+').write(data)
|
||||
-
|
||||
In order to test the PDF reports defined on a Purchase Order, we will print Purchase Order report
|
||||
I print Purchase Order report
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
import netsvc, tools, os
|
||||
Reference in New Issue
Block a user