[IMP]: Improve cancel sale order yml

bzr revid: atp@tinyerp.com-20120920120238-0eemylf96xxrqoso
This commit is contained in:
Atul Patel (OpenERP) 2012-09-20 17:32:38 +05:30
parent bc1dc41c34
commit 78a96ae65a
1 changed files with 44 additions and 13 deletions

View File

@ -1,42 +1,73 @@
-
In order to test the cancel sale order.
I confirm order.
I confirm order (with at least 2 lines)
-
!workflow {model: sale.order, action: order_confirm, ref: sale_order_8}
-
-
I check state of order in 'Sale Order'.
-
!assert {model: sale.order, id: sale_order_8, string: Sale order should be In Progress state}:
- state == 'manual'
-
- state == 'manual'
-
I check that Invoice should not be created.
-
!python {model: sale.order}: |
sale_order = self.browse(cr, uid, ref("sale_order_8"))
assert len(sale_order.invoice_ids) == False, "Invoice should not be created."
-
I create advance invoice.
I create an invoice for the first line
-
!python {model: sale.advance.payment.inv}: |
!python {model: sale.advance.payment.inv}: |
ctx = context.copy()
ctx.update({"active_model": 'sale.order', "active_ids": [ref("sale_order_8")], "active_id":ref("sale.sale_order_8")})
ctx.update({"active_model": 'sale.order', "active_ids": [ref("sale_order_8")], "active_id":ref("sale_order_8")})
order_line = self.pool.get('sale.order.line').browse(cr, uid, ref("sale_order_line_20"), context=context)
pay_id = self.create(cr, uid, {'advance_payment_method': 'lines', 'product_id': order_line.product_id.id, 'amount': order_line.price_subtotal, 'qtty': order_line.product_uom_qty})
self.create_invoices(cr, uid, [pay_id], context=ctx)
-
I create an invoice for a fixed price (a percentage of the amount of the second line)
-
!python {model: sale.advance.payment.inv}: |
ctx = context.copy()
ctx.update({"active_model": 'sale.order', "active_ids": [ref("sale_order_8")], "active_id":ref("sale_order_8")})
order_line = self.pool.get('sale.order.line').browse(cr, uid, ref("sale_order_line_21"), context=context)
pay_id = self.create(cr, uid, {'advance_payment_method': 'fixed', 'product_id': order_line.product_id.id, 'amount': order_line.price_subtotal, 'qtty': order_line.product_uom_qty})
self.create_invoices(cr, uid, [pay_id], context=ctx)
-
To cancel the sale order from Invoice Exception, I have to cancel the invoice of sale order.
I create an invoice for the remaining and check the amount (should be the remaining amount of second line)
-
!python {model: sale.advance.payment.inv}: |
ctx = context.copy()
ctx.update({"active_model": 'sale.order', "active_ids": [ref("sale_order_8")], "active_id":ref("sale_order_8")})
pay_id = self.create(cr, uid, {'advance_payment_method': 'all'})
self.create_invoices(cr, uid, [pay_id], context=ctx)
-
I cancel all the invoices.
-
!python {model: sale.order}: |
import netsvc
invoice_ids = self.browse(cr, uid, ref("sale_order_8")).invoice_ids
wf_service = netsvc.LocalService("workflow")
first_invoice_id = invoice_ids[0]
wf_service.trg_validate(uid, 'account.invoice', first_invoice_id.id, 'invoice_cancel', cr)
for invoice in invoice_ids:
wf_service.trg_validate(uid, 'account.invoice', invoice.id, 'invoice_cancel', cr)
-
I check order status in "Sale to Invoice" and related invoice is in cancel state.
I check order status in "Invoice Exception" and related invoice is in cancel state.
-
!assert {model: sale.order, id: sale_order_8, string: Sale order should be in Invoice Exception state}:
- state == "manual", "Order should be in progress state after cancel Invoice"
- state == "invoice_except", "Order should be in Invoice Exception state after cancel Invoice"
-
I click recreate invoice.
-
!workflow {model: sale.order, action: invoice_recreate, ref: sale_order_8}
-
I check that the invoice is correctly created with all lines.
-
!python {model: sale.order}: |
sale_order = self.browse(cr, uid, ref("sale_order_8"))
total_order_line = []
assert len(sale_order.invoice_ids), "Invoice should be created."
for order_line in sale_order.invoice_ids:
total_order_line = order_line.invoice_line
assert len(total_order_line) == 2, "invoice lines are not same"