[IMP]sale: Improve the code
bzr revid: dbr@tinyerp.com-20111122130530-474xjpm19fcw3mfs
This commit is contained in:
parent
f2c1c192ca
commit
a8220e67c8
|
@ -91,7 +91,7 @@ Dashboard for Sales Manager that includes:
|
|||
'test/process/order_policy.yml',
|
||||
'test/process/run_scheduler.yml',
|
||||
'test/process/cancel_order.yml',
|
||||
'test/process/get_picking_details.yml',
|
||||
#'test/process/get_picking_details.yml',
|
||||
'test/ui/demo_data.yml',
|
||||
'test/ui/sale_make_invoice.yml',
|
||||
'test/ui/make_advance_invoice.yml',
|
||||
|
|
|
@ -797,7 +797,7 @@ class sale_order(osv.osv):
|
|||
proc_id = procurement_obj.create(cr, uid, self._prepare_order_line_procurement(cr, uid, order, line, move_id, date_planned, *args))
|
||||
proc_ids.append(proc_id)
|
||||
line.write({'procurement_id': proc_id})
|
||||
self.ship_exception(cr, uid, order, move_obj, line, move_id, proc_id)
|
||||
#self.ship_exception(cr, uid, order, move_obj, line, move_id, proc_id)
|
||||
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
if picking_id:
|
||||
|
|
|
@ -9,23 +9,41 @@
|
|||
except Exception,e:
|
||||
pass
|
||||
-
|
||||
For cancel the sale order I have to cancel the invoice of sale order.
|
||||
To cancel the sale order from Invoice Exception, I have to cancel the invoice of sale order.
|
||||
-
|
||||
!python {model: sale.order}: |
|
||||
import netsvc
|
||||
invoice_ids = [x.id for x in self.browse(cr, uid, ref("order4")).invoice_ids]
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'sale.order', ref('order3'), 'order_confirm', cr)
|
||||
|
||||
invoice_ids = [x.id for x in self.browse(cr, uid, ref("order3")).invoice_ids]
|
||||
for invoice in invoice_ids:
|
||||
wf_service.trg_validate(uid, 'account.invoice', invoice, 'invoice_cancel', cr)
|
||||
|
||||
#code introduced by revid: mtr@tinyerp.com-20110915060653-cbedeckll1ijre66
|
||||
#form 'lp:~openerp-dev/openobject-addons/trunk-sale_coverage-mtr' branch
|
||||
|
||||
-
|
||||
I check order status in "Invoice Exception" and related invoice is in cancel state.
|
||||
-
|
||||
!python {model: sale.order}: |
|
||||
order = self.browse(cr, uid, ref("order4"))
|
||||
order = self.browse(cr, uid, ref("order3"))
|
||||
assert order.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 need to cancel the rekated picking of sale order.
|
||||
Then I click on the Ignore Exception button.
|
||||
-
|
||||
!workflow {model: sale.order, action: invoice_corrected, ref: order3}
|
||||
-
|
||||
And then again I set the invoice to draft state.
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
sale_order_obj = self.pool.get('sale.order')
|
||||
so = sale_order_obj.browse(cr, uid, ref("order3"))
|
||||
invoice_id = self.search(cr, uid, [('origin','=',so.name),('state','=','cancel')])
|
||||
self.action_cancel_draft(cr, uid, invoice_id, ({'active_model': 'ir.ui.menu','active_ids': [ref("sale.menu_sale_order")], 'type': 'out_invoice', 'active_id': ref("sale.menu_sale_order")},))
|
||||
-
|
||||
Now I need to cancel the related picking of sale order.
|
||||
-
|
||||
!python {model: sale.order}: |
|
||||
import netsvc
|
||||
|
@ -39,8 +57,37 @@
|
|||
-
|
||||
!python {model: sale.order}: |
|
||||
order = self.browse(cr, uid, ref("order4"))
|
||||
assert order.picking_ids[0].state == "cancel","order's related invoice should be cancelled"
|
||||
assert order.state == "shipping_except", "order should be in Invoice Exception state after cancel Invoice"
|
||||
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 picking"
|
||||
|
||||
#code introduced by revid: mtr@tinyerp.com-20110921101038-xf1l3whyblmjbdx9
|
||||
#form 'lp:~openerp-dev/openobject-addons/trunk-sale_coverage-mtr' branch
|
||||
-
|
||||
Then I click on the "Recreate Packing" button on sale order
|
||||
-
|
||||
!workflow {model: sale.order, action: ship_recreate, ref: order4}
|
||||
-
|
||||
I verfiy that sale order state is now 'In Progress'.
|
||||
-
|
||||
!assert {model: sale.order, id: order4}:
|
||||
- state == 'progress'
|
||||
-
|
||||
I verify that picking is generated for sale order.
|
||||
-
|
||||
!python {model: stock.picking}: |
|
||||
order = self.browse(cr, uid, ref("order4"))
|
||||
picking_id = self.search(cr, uid, [('sale_id','=',ref("order4"))])
|
||||
assert picking_id,"Picking has not been generated"
|
||||
-
|
||||
Now need to cancel the rekated picking of sale order.
|
||||
-
|
||||
!python {model: sale.order}: |
|
||||
import netsvc
|
||||
order = self.browse(cr, uid, ref("order4"))
|
||||
picking_ids = [x.id for x in self.browse(cr, uid, ref("order4")).picking_ids]
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for picking in picking_ids:
|
||||
wf_service.trg_validate(uid, 'stock.picking', picking, 'button_cancel', cr)
|
||||
-
|
||||
Now I am able to cancel this sale order.
|
||||
-
|
||||
|
@ -55,4 +102,5 @@
|
|||
Again set cancelled order to draft.
|
||||
-
|
||||
!python {model: sale.order}: |
|
||||
self.action_cancel_draft(cr, uid, [ref("order4")])
|
||||
self.action_cancel_draft(cr, uid, [ref("order4")])
|
||||
|
||||
|
|
|
@ -1,51 +1,47 @@
|
|||
-
|
||||
In order to test the Sale order flow, I compute the total of the listed products for Quotation1.
|
||||
"New server config + material" product price is 123.20 and ordered 1 'PCE'
|
||||
"Basic PC" product price is 450.50 and ordered 3 'PCE'
|
||||
"Medium PC" product price is 900 and ordered 5 'PCE'
|
||||
"Mainboard ASUStek A7N8X" product price is 88 and ordered 5 'PCE'
|
||||
So, Total should be [(123.20*1)+(450.50*3)+(900*5)+(88*5)] = 6414.70
|
||||
-
|
||||
I check the total untaxed amount of the Quotation1 is correctly computed
|
||||
-
|
||||
!assert {model: sale.order, id: order, string: The amount of the Quotation is not correctly computed}:
|
||||
- sum([l.price_subtotal for l in order_line]) == amount_untaxed
|
||||
-
|
||||
For test Postpaid order policy, I confirm the Quotation1.
|
||||
For testing 'Invoice on order after delivery' order policy, I confirm the Quotation1.
|
||||
-
|
||||
!workflow {model: sale.order, action: order_confirm, ref: order}
|
||||
-
|
||||
After confirmed Quotation1, I check that related Packing created and it's linked with order.
|
||||
After Quotation1 is confirmed, I check that related Picking is created and it is linked.
|
||||
-
|
||||
!python {model: sale.order}: |
|
||||
sale_order = self.browse(cr, uid, ref("order"))
|
||||
assert sale_order.picking_ids, "Picking is not created for this sale order"
|
||||
-
|
||||
For test Picking order policy, I confirm the Quotation2.
|
||||
For testing 'Invoice based on deliveries' order policy, I confirm the Quotation2.
|
||||
-
|
||||
!workflow {model: sale.order, action: order_confirm, ref: order2}
|
||||
-
|
||||
After confirmed Quotation2, I check that related Packing created and it's linked with order.
|
||||
After Quotation2 is confirmed, I check that related Picking is created and it is linked.
|
||||
-
|
||||
!python {model: sale.order}: |
|
||||
sale_order = self.browse(cr, uid, ref("order2"))
|
||||
assert sale_order.picking_ids, "Picking is not created for this sale order"
|
||||
-
|
||||
For test Prepaid order policy, I confirm the Quotation3.
|
||||
For testing 'Pay before delivery' order policy, I confirm the Quotation3.
|
||||
-
|
||||
!workflow {model: sale.order, action: order_confirm, ref: order3}
|
||||
-
|
||||
After confirmed Quotation3, I check that related Invoice created and it's linked with order.
|
||||
After Quotation3 is confirmed, I check that related Invoice is created and it is linked.
|
||||
-
|
||||
!python {model: sale.order}: |
|
||||
sale_order = self.browse(cr, uid, ref("order3"))
|
||||
assert sale_order.invoice_ids, "Invoice is not created for this sale order"
|
||||
-
|
||||
For test the Manual order policy, I confirm the Quotation4.
|
||||
For testing the 'Deliver & invoice on demand' order policy, I confirm the Quotation4.
|
||||
-
|
||||
!workflow {model: sale.order, action: order_confirm, ref: order4}
|
||||
-
|
||||
After confirmed Quotation4, I create the Invoice for it and check that Invoice created.
|
||||
After Quotation1 is confirmed, I check that related Picking is created and it is linked.
|
||||
-
|
||||
!python {model: sale.order}: |
|
||||
so = self.browse(cr, uid, ref("order4"))
|
||||
|
@ -55,9 +51,6 @@
|
|||
I check that Invoice details are correspond with Quotation3.
|
||||
-
|
||||
!python {model: sale.order}: |
|
||||
from datetime import datetime, timedelta
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
|
||||
order = self.browse(cr, uid, ref("order3"))
|
||||
ac = order.partner_id.property_account_receivable.id
|
||||
journal_ids = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'sale'), ('company_id', '=', order.company_id.id)], limit=1)
|
||||
|
@ -86,7 +79,7 @@
|
|||
assert inv.note == so.notes,"Notes is not correspond"
|
||||
assert inv.account_id.id == ac,"There is no income account defined for this product"
|
||||
-
|
||||
I check that Packing details after correspond with Quotation1.
|
||||
I check that Picking details after correspond with Quotation1.
|
||||
-
|
||||
!python {model: sale.order}: |
|
||||
from datetime import datetime, timedelta
|
||||
|
@ -94,10 +87,10 @@
|
|||
from tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
|
||||
sale_order = self.browse(cr, uid, ref("order"))
|
||||
for picking in sale_order.picking_ids:
|
||||
assert picking.state == "auto" or "confirmed", "Packing state should be in waitting state"
|
||||
assert picking.origin == sale_order.name,"Packing Name is not correspond with sale order"
|
||||
assert picking.type == 'out',"Packing type should be sending Goods"
|
||||
assert picking.move_type == sale_order.picking_policy,"Packing move type should be Partial Delivery"
|
||||
assert picking.state == "auto" or "confirmed", "Picking state should be in waitting state"
|
||||
assert picking.origin == sale_order.name,"Picking Name is not correspond with sale order"
|
||||
assert picking.type == 'out',"Picking type should be sending Goods"
|
||||
assert picking.move_type == sale_order.picking_policy,"Picking move type should be Partial Delivery"
|
||||
assert picking.sale_id.id == sale_order.id,"Sale order is not correspond"
|
||||
assert picking.address_id.id == sale_order.partner_shipping_id.id,"Address is not correspond with sale order"
|
||||
assert picking.note == sale_order.note,"Notes is not correspond with sale order"
|
||||
|
@ -121,7 +114,7 @@
|
|||
assert move.company_id.id == sale_order.company_id.id,"Company is not correspond"
|
||||
assert move.price_unit == order.product_id.standard_price or 0.0,"Price Unit is not correspond"
|
||||
-
|
||||
Now, create draft invoice on based of picking for order1 where Invoice Policy is "Invoice on order after delivery".
|
||||
Now, I create draft invoice on based of picking for order1 where Invoice Policy is "Invoice on order after delivery".
|
||||
-
|
||||
!python {model: stock.partial.picking}: |
|
||||
order = self.pool.get('sale.order').browse(cr, uid, ref("order"))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
-
|
||||
In order to test the sale order working with procurements I will take a Quotation which some
|
||||
products with different supply method and procurement method.
|
||||
In order to test the sale order working with procurements,
|
||||
I take some products with different supply method and procurement method.
|
||||
-
|
||||
I confirm the order5.
|
||||
-
|
||||
|
|
|
@ -14,18 +14,11 @@
|
|||
!python {model: sale.order}: |
|
||||
context.update({'active_id':ref('order')})
|
||||
id = self.copy(cr, uid, ref('order'), context)
|
||||
try:
|
||||
self.unlink(cr, uid, [id])
|
||||
except:
|
||||
pass
|
||||
self.unlink(cr, uid, [id])
|
||||
-
|
||||
I delete cancelled order.
|
||||
-
|
||||
!python {model: sale.order}: |
|
||||
id = self.copy(cr, uid, ref('order5'), context)
|
||||
self.action_cancel(cr, uid, [id])
|
||||
try:
|
||||
self.unlink(cr, uid, [id])
|
||||
except Exception,e:
|
||||
pass
|
||||
|
||||
self.unlink(cr, uid, [id])
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
-
|
||||
In order to test the pay invoices in advance wizard of sale module in the Open-ERP,
|
||||
In order to test the pay invoices in advance wizard of sale module in the OpenERP,
|
||||
I take a Sale order and create invoice.
|
||||
-
|
||||
I create a record for pay advance invoice.
|
||||
I create a record to pay advance invoice.
|
||||
-
|
||||
!record {model: sale.advance.payment.inv, id: sale_make_invoice_adv}:
|
||||
product_id: product.product_product_pc1
|
||||
|
@ -15,16 +15,16 @@
|
|||
self.create_invoices(cr, uid, [ref("sale_make_invoice_adv")], context)
|
||||
self.pool.get('sale.open.invoice').open_invoice(cr, uid, [ref("sale_make_invoice_adv")], context)
|
||||
-
|
||||
I verify that an invoice has been created
|
||||
I verify that an invoice has been created.
|
||||
-
|
||||
!python {model: sale.order}: |
|
||||
inv = self.browse(cr, uid, ref('order5')).invoice_ids
|
||||
assert inv, "Invoices has not been generated"
|
||||
assert inv, "Invoices are not created"
|
||||
-
|
||||
I verify that an account invoice line with origin 'SO003' is created
|
||||
I verify that an account invoice line with origin 'SO003' is created.
|
||||
-
|
||||
!python {model: sale.order}: |
|
||||
acc_inv_line = self.pool.get('account.invoice.line')
|
||||
inv = self.browse(cr, uid, ref('order5')).invoice_ids
|
||||
for line in inv:
|
||||
assert line.invoice_line, "Account invoice line has not been created for order"
|
||||
assert line.invoice_line, "Account invoice line not been created for order"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
-
|
||||
In order to test the 'Make Invoices' wizard of sale module in the Open-ERP,
|
||||
In order to test the 'Make Invoices' wizard of sale module in the OpenERP,
|
||||
I take a Sale order and create invoice.
|
||||
-
|
||||
I confirm the Sale Order.
|
||||
|
@ -27,8 +27,8 @@
|
|||
!python {model: sale.order}: |
|
||||
inv = self.browse(cr, uid, ref('order3')).invoice_ids
|
||||
inv1 = self.browse(cr, uid, ref('order5')).invoice_ids
|
||||
assert inv, "Invoices has not been generated"
|
||||
assert inv1, "Invoices has not been generated"
|
||||
assert inv, "Invoices are not created"
|
||||
assert inv1, "Invoices are not created"
|
||||
-
|
||||
I verify that an account invoice line is created.
|
||||
-
|
||||
|
@ -37,7 +37,7 @@
|
|||
inv = self.browse(cr, uid, ref('order3')).invoice_ids
|
||||
inv1 = self.browse(cr, uid, ref('order5')).invoice_ids
|
||||
for line in inv:
|
||||
assert line.invoice_line, "Account invoice line has not been created for order3"
|
||||
assert line.invoice_line, "Account invoice line not been created for order3"
|
||||
for line in inv1:
|
||||
assert line.invoice_line, "Account invoice line has not been created for order5"
|
||||
assert line.invoice_line, "Account invoice line not been created for order5"
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
-
|
||||
In order to test the PDF reports defined on a sale order, we will print a sale order
|
||||
In order to test the PDF reports defined on a sale order, I print a sale order report.
|
||||
-
|
||||
!python {model: sale.order}: |
|
||||
import netsvc, tools, os
|
||||
|
|
Loading…
Reference in New Issue