[MOVE,IMP] Sale:

sale/test/invoice_on_ordered_qty.yml => sale/test/process/cancel_order.yml
Improve code for delete_order.yml

bzr revid: dbr@tinyerp.com-20111104102721-00ewxs3vhwfck6ox
This commit is contained in:
DBR (OpenERP)
2011-11-04 15:57:21 +05:30
parent ba2fea7899
commit dd0ebafe8a
4 changed files with 67 additions and 113 deletions
+1 -1
View File
@@ -88,7 +88,7 @@ Dashboard for Sales Manager that includes:
'test': [
'test/process/postpaid_order_policy.yml',
'test/ui/onchage_events.yml',
#'test/prepaid_order_policy.yml',
'test/process/cancel_order.yml',
#'test/picking_order_policy.yml',
#'test/advance_invoice.yml',
#'test/so_make_line_invoice.yml',
-110
View File
@@ -1,110 +0,0 @@
-
In order to test the Sale module in OpenERP,
I create a Sale Order for Slider Mobile for 500 quantity having Shipping Policy 'Shipping & Manual Invoice' and Invoice on 'Ordered quantities'
in order to create an invoice based on the ordered quantity
-
!record {model: sale.order, id: sale_order_so9}:
date_order: !eval time.strftime('%Y-%m-%d')
invoice_quantity: order
name: Test_SO006
order_line:
- name: Slider Mobile
price_unit: 200
product_uom: product.product_uom_unit
product_uom_qty: 200.0
state: draft
delay: 7.0
product_id: sale.product_product_slidermobile0
product_uos_qty: 200.0
type: make_to_order
order_policy: manual
invoice_quantity: order
partner_id: sale.res_partner_cleartrail0
partner_invoice_id: sale.res_partner_address_2
partner_order_id: sale.res_partner_address_1
partner_shipping_id: sale.res_partner_address_3
picking_policy: direct
pricelist_id: product.list0
shop_id: sale.shop
-
I confirm the Sale Order.
-
!workflow {model: sale.order, action: order_confirm, ref: sale_order_so9}
-
I verify that the picking has been generated for the sale order and I process it
-
!python {model: sale.order}: |
so = self.browse(cr, uid, ref("sale_order_so9"))
assert so.picking_ids,"Picking has not been generated for sale_order_so9"
picking, = so.picking_ids
stock_partial_picking = self.pool.get('stock.partial.picking')
partial_id = stock_partial_picking.create(cr, uid, {},
context={'active_model': 'stock.picking',
'active_ids': [picking.id]})
stock_partial_picking.do_partial(cr, uid, [partial_id])
-
I click on Create Invoice button to create the invoice.
-
!workflow {model: sale.order, action: manual_invoice, ref: sale_order_so9}
-
I verify whether the invoice has been generated for SO
-
!python {model: sale.order}: |
so = self.browse(cr, uid, ref("sale_order_so9"))
assert so.invoice_ids, "Invoices has not been generated for sale_order_so9"
-
I verify that an invoice is created on the basis of ordered quantity
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so9"))
for so_lines in so.order_line:
qty = so_lines.product_uom_qty
ids = self.search(cr, uid, [('origin','=',so.name)])
inv_brw = self.browse(cr,uid,ids)[0]
for inv_lines in inv_brw.invoice_line:
qty1 = inv_lines.quantity
assert qty1==qty, "Quantities are not same"
-
I open the Invoice for the SO.
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so9"))
import netsvc
wf_service = netsvc.LocalService("workflow")
invoice_ids = so.invoice_ids
for invoice in invoice_ids:
wf_service.trg_validate(uid, 'account.invoice',invoice.id,'invoice_open', cr)
-
Assign analytic journal into bank journal
-
!record {model: account.journal, id: sale.account_journal_bankjournal0}:
analytic_journal_id: account.cose_journal_sale
-
I pay the invoice
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so9"))
invoice_id = self.search(cr, uid, [('origin','=',so.name),('state','=','open')])
self.pay_and_reconcile(cr, uid, invoice_id,
40000.0, ref('account.cash'), ref('account.period_9'),
ref('sale.account_journal_bankjournal0'), ref('account.cash'),
ref('account.period_8'), ref('sale.account_journal_bankjournal0'),
name='test')
-
I verify the invoice are in paid state or not.
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so9"))
invoice_ids = so.invoice_ids
for invoice in invoice_ids:
assert invoice.state =='paid', "Invoice for SO is not in done state."
-
I check that Paid has been set to true.
-
!python {model: sale.order}: |
sale_id=self.browse(cr, uid, ref("sale_order_so9"))
assert sale_id.invoiced == True, "Paid has not been set to true"
+60
View File
@@ -0,0 +1,60 @@
-
In order to test the cancel sale order.
-
I try to cancel sale order.
-
!python {model: sale.order}: |
try:
self.action_cancel(cr, uid, [ref("order")])
except Exception,e:
print e
-
First I cancel picking related to this order.
-
!python {model: sale.order}: |
order = self.browse(cr, uid, ref("order"))
self.pool.get('stock.picking').action_cancel(cr, uid, [picking.id for picking in order.picking_ids])
-
I check order status in "Shipping Exception" and related picking is in cancel state.
-
!python {model: sale.order}: |
order = self.browse(cr, uid, ref("order"))
assert order.picking_ids[0].state == "cancel","order's related picking should be cancelled"
#assert order.state == "shipping_except", "order should be in Ship Exception state after cancel shipment"
-
Now I am able to cancel sale order.
-
!python {model: sale.order}: |
self.action_cancel(cr, uid, [ref("order")])
-
I check that sale order is cancelled.
-
!assert {model: sale.order, id: order}:
- state == 'cancel'
-
Now try to cancel the order which Invoice Policy is 'Pay before delivery'.
-
!python {model: sale.order}: |
self.action_cancel(cr, uid, [ref("order3")])
assert self.browse(cr, uid, ref("order3")).invoice_ids[0].state == "cancel","order's related invoice should be cancelled"
#assert order.state == "invoice_except", "order should be in Invoice Exception state after cancel Invoice"
-
Now again set cancelled order to draft.
-
!python {model: sale.order}: |
self.action_cancel_draft(cr, uid, [ref("order")])
-
Now I again cancel draft order.
-
!python {model: sale.order}: |
self.action_cancel(cr, uid, [ref("order")])
-
I check that order is cancelled.
-
!assert {model: sale.order, id: order}:
- state == 'cancel'
-
Again set cancelled order to draft.
-
!python {model: sale.order}: |
self.action_cancel_draft(cr, uid, [ref("order")])
+6 -2
View File
@@ -19,5 +19,9 @@
I delete cancelled order.
-
!python {model: sale.order}: |
self.action_cancel_draft(cr, uid, [ref("order5")])
self.unlink(cr, uid, [ref("order5")])
id = self.copy(cr, uid, ref('order5'), context)
self.action_cancel(cr, uid, [id])
try:
self.unlink(cr, uid, [id])
except Exception,e:
print e