[IMP]sale:Improve code for advance payment wizard
bzr revid: dbr@tinyerp.com-20111104133305-74pg8gt8xof94m9h
This commit is contained in:
@@ -743,6 +743,7 @@ class account_journal(osv.osv):
|
||||
"""
|
||||
# in account.journal code is actually the prefix of the sequence
|
||||
# whereas ir.sequence code is a key to lookup global sequences.
|
||||
print"--------->>>>>>>>>>>>>>>>------------",vals
|
||||
prefix = vals['code'].upper()
|
||||
|
||||
seq = {
|
||||
|
||||
@@ -86,15 +86,15 @@ Dashboard for Sales Manager that includes:
|
||||
],
|
||||
'demo_xml': ['sale_demo.xml'],
|
||||
'test': [
|
||||
'test/process/postpaid_order_policy.yml',
|
||||
'test/ui/onchage_events.yml',
|
||||
'test/process/order_policy.yml',
|
||||
'test/process/cancel_order.yml',
|
||||
'test/ui/onchage_events.yml',
|
||||
#'test/picking_order_policy.yml',
|
||||
#'test/advance_invoice.yml',
|
||||
#'test/so_make_line_invoice.yml',
|
||||
#'test/sale_procurement.yml',
|
||||
#'test/invoice_on_ordered_qty.yml',
|
||||
#'test/invoice_on_shipped_qty.yml',
|
||||
'test/ui/make_invoice_advance.yml',
|
||||
'test/ui/delete_order.yml',
|
||||
'test/ui/sale_report.yml',
|
||||
],
|
||||
|
||||
@@ -1,229 +0,0 @@
|
||||
-
|
||||
I create a Sale Order for LG Viewty Smart for qty 500 having Shipping Policy is 'Payment Before Delivery'
|
||||
-
|
||||
!record {model: sale.order, id: sale_order_so1}:
|
||||
date_order: !eval time.strftime('%Y-%m-%d')
|
||||
invoice_quantity: order
|
||||
name: Test_SO001
|
||||
order_line:
|
||||
- name: Slider Mobile
|
||||
price_unit: 200
|
||||
product_uom: product.product_uom_unit
|
||||
product_uom_qty: 500.0
|
||||
state: draft
|
||||
delay: 7.0
|
||||
product_id: sale.product_product_slidermobile0
|
||||
product_uos_qty: 500.0
|
||||
th_weight: 0.0
|
||||
type: make_to_order
|
||||
order_policy: prepaid
|
||||
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_so1}
|
||||
-
|
||||
I verify whether the invoice has been generated for SO since Shipping policy is 'Payment Before Delivery'
|
||||
-
|
||||
!python {model: sale.order}: |
|
||||
so = self.browse(cr, uid, ref("sale_order_so1"))
|
||||
assert so.invoice_ids, "Invoices has not been generated for sale_order_so1"
|
||||
-
|
||||
I verify there are no pickings attached to this sale order
|
||||
-
|
||||
!python {model: stock.picking }: |
|
||||
sale_order_obj = self.pool.get('sale.order')
|
||||
so = sale_order_obj.browse(cr, uid, ref("sale_order_so1"))
|
||||
picking_id = self.search(cr, uid, [('origin','=',so.name),('type','=','out')])
|
||||
assert not picking_id,"As the order policy is prepaid, the sale order shouldn't have already a picking."
|
||||
-
|
||||
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_so1"))
|
||||
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)
|
||||
-
|
||||
I assign an analytic journal to the 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_so1"))
|
||||
invoice_id = self.search(cr, uid, [('origin','=',so.name),('state','=','open')])
|
||||
self.pay_and_reconcile(cr, uid, invoice_id,
|
||||
85000.0, ref('account.cash'), ref('account.period_8'),
|
||||
ref('sale.account_journal_bankjournal0'), ref('account.cash'),
|
||||
ref('account.period_5'), ref('sale.account_journal_bankjournal0'),
|
||||
name='test002')
|
||||
-
|
||||
I verify the invoice is in done 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_so1"))
|
||||
invoice_id = self.search(cr, uid, [('origin','=',so.name),('state','=','paid')])
|
||||
assert invoice_id, "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_so1"))
|
||||
assert(sale_id.invoiced == True), "Paid has not been set to true"
|
||||
-
|
||||
I verify the picking associated with the sale order sale_order_so1
|
||||
-
|
||||
!python {model: sale.order}: |
|
||||
so = self.browse(cr, uid, ref("sale_order_so1"))
|
||||
assert so.picking_ids,"Picking has not been generated"
|
||||
-
|
||||
Products are delivered to the Cleartrail Customer.
|
||||
-
|
||||
!python {model: stock.picking }: |
|
||||
import time
|
||||
sale_order_obj = self.pool.get('sale.order')
|
||||
so = sale_order_obj.browse(cr, uid, ref("sale_order_so1"))
|
||||
picking_id = self.search(cr, uid, [('origin','=',so.name),('type','=','out')])
|
||||
if picking_id:
|
||||
pick=self.browse(cr,uid,picking_id[0])
|
||||
pick.force_assign(cr, uid)
|
||||
stock_partial_picking = self.pool.get('stock.partial.picking')
|
||||
partial_id = stock_partial_picking.create(cr, uid, {},
|
||||
context={'active_model': 'stock.picking',
|
||||
'active_ids': [pick.id]})
|
||||
stock_partial_picking.do_partial(cr, uid, [partial_id])
|
||||
-
|
||||
I verify that picking order is in done state.
|
||||
-
|
||||
!python {model: stock.picking }: |
|
||||
sale_order_obj = self.pool.get('sale.order')
|
||||
so = sale_order_obj.browse(cr, uid, ref("sale_order_so1"))
|
||||
picking_id = self.search(cr, uid, [('origin','=',so.name),('type','=','out')])
|
||||
pick = self.browse(cr,uid,picking_id[0])
|
||||
assert (pick.state) =='done', "Picking for SO is not in done state."
|
||||
-
|
||||
I verify that a procurement has been generated for so
|
||||
-
|
||||
!python {model: procurement.order}: |
|
||||
from tools.translate import _
|
||||
sale_order_obj = self.pool.get('sale.order')
|
||||
so = sale_order_obj.browse(cr, uid, ref("sale_order_so1"))
|
||||
proc_ids = self.search(cr, uid, [('origin','=',so.name)])
|
||||
assert proc_ids, _('No Procurements!')
|
||||
-
|
||||
Then I click on the "Run Procurement" button
|
||||
-
|
||||
!python {model: procurement.order}: |
|
||||
sale_order_obj = self.pool.get('sale.order')
|
||||
so = sale_order_obj.browse(cr, uid, ref("sale_order_so1"))
|
||||
import netsvc
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
proc_ids = self.search(cr, uid, [('origin','=',so.name)])
|
||||
for proc in proc_ids:
|
||||
wf_service.trg_validate(uid, 'procurement.order',proc,'button_check', cr)
|
||||
-
|
||||
I verify that a procurement state is "running"
|
||||
-
|
||||
!python {model: procurement.order}: |
|
||||
from tools.translate import _
|
||||
modules = self.pool.get('ir.module.module')
|
||||
mod_pur = modules.search(cr, uid, [('name','=','purchase')])
|
||||
mod_brw = modules.browse(cr,uid,mod_pur)[0]
|
||||
if(mod_brw.state == 'installed'):
|
||||
sale_order_obj = self.pool.get('sale.order')
|
||||
so = sale_order_obj.browse(cr, uid, ref("sale_order_so1"))
|
||||
proc_ids = self.search(cr, uid, [('origin','=',so.name),('state','=','running')])
|
||||
assert proc_ids, _('Procurement is not in the running state!')
|
||||
-
|
||||
I verify that a purchase order has been generated
|
||||
-
|
||||
!python {model: sale.order}: |
|
||||
from tools.translate import _
|
||||
modules = self.pool.get('ir.module.module')
|
||||
mod_pur = modules.search(cr, uid, [('name','=','purchase')])
|
||||
mod_brw = modules.browse(cr,uid,mod_pur)[0]
|
||||
if(mod_brw.state == 'installed'):
|
||||
so = self.browse(cr, uid, ref("sale_order_so1"))
|
||||
pur_obj=self.pool.get('purchase.order')
|
||||
pur_id=pur_obj.search(cr, uid, [('origin','=',so.name)])
|
||||
assert pur_id, _('Purchase order has not been generated')
|
||||
-
|
||||
I click on the "Confirm" button to confirm the purchase order
|
||||
-
|
||||
!python {model: sale.order}: |
|
||||
from tools.translate import _
|
||||
modules = self.pool.get('ir.module.module')
|
||||
mod_pur = modules.search(cr, uid, [('name','=','purchase')])
|
||||
mod_brw = modules.browse(cr,uid,mod_pur)[0]
|
||||
if(mod_brw.state == 'installed'):
|
||||
pur_obj=self.pool.get('purchase.order')
|
||||
so = self.browse(cr, uid, ref("sale_order_so1"))
|
||||
import netsvc
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
pur_ids = pur_obj.search(cr, uid, [('origin','=',so.name)])
|
||||
for pur in pur_ids:
|
||||
wf_service.trg_validate(uid, 'purchase.order',pur,'purchase_confirm', cr)
|
||||
-
|
||||
I click on the "Approved by supplier" button to approve the purchase order
|
||||
-
|
||||
!python {model: sale.order}: |
|
||||
from tools.translate import _
|
||||
modules = self.pool.get('ir.module.module')
|
||||
mod_pur = modules.search(cr, uid, [('name','=','purchase')])
|
||||
mod_brw = modules.browse(cr,uid,mod_pur)[0]
|
||||
if (mod_brw.state == 'installed'):
|
||||
pur_obj = self.pool.get('purchase.order')
|
||||
so = self.browse(cr, uid, ref("sale_order_so1"))
|
||||
import netsvc
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
pur_ids = pur_obj.search(cr, uid, [('origin','=',so.name)])
|
||||
for pur in pur_ids:
|
||||
wf_service.trg_validate(uid, 'purchase.order',pur,'purchase_approve', cr)
|
||||
-
|
||||
I verify that a picking related to purchase order has been generated and I process it
|
||||
-
|
||||
!python {model: sale.order}: |
|
||||
modules = self.pool.get('ir.module.module')
|
||||
mod_pur = modules.search(cr, uid, [('name','=','purchase')])
|
||||
mod_brw = modules.browse(cr,uid,mod_pur)[0]
|
||||
if (mod_brw.state == 'installed'):
|
||||
pur_obj = self.pool.get('purchase.order')
|
||||
so = self.browse(cr, uid, ref("sale_order_so1"))
|
||||
pur_id = pur_obj.search(cr, uid, [('origin','=',so.name)])
|
||||
po = pur_obj.browse(cr, uid, pur_id)[0]
|
||||
assert(po.picking_ids),"Picking for purchase order has not been generated"
|
||||
picking, = po.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])
|
||||
picking_obj = self.pool.get('stock.picking')
|
||||
ids = picking_obj.search(cr, uid, [('purchase_id', '=', po.id),('state', '=', 'done')])
|
||||
assert ids, 'Picking should be marked done!'
|
||||
-
|
||||
I verify that the sale order is marked as delivered
|
||||
-
|
||||
!python {model: sale.order}: |
|
||||
so = self.browse(cr, uid, ref("sale_order_so1"))
|
||||
assert (so.shipped == True), "Sale order is not marked as delivered"
|
||||
-
|
||||
I verify that a sale order is in done state
|
||||
-
|
||||
!python {model: sale.order}: |
|
||||
so = self.browse(cr, uid, ref("sale_order_so1"))
|
||||
assert (so.state == 'done'), "Sale order is not in the done state."
|
||||
+4
-3
@@ -118,7 +118,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 invoice on based of picking for order1 where Invoice Policy is "Invoice on order after delivery".
|
||||
Now, 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"))
|
||||
@@ -128,9 +128,10 @@
|
||||
if data == True:
|
||||
partial_id = self.create(cr, uid, {},context={'active_model': 'stock.picking','active_ids': [pick_ids[0].id]})
|
||||
self.do_partial(cr, uid, [partial_id])
|
||||
assert order.shipped == True, "Sale order is not marked as delivered"
|
||||
assert order.invoice_ids, "Invoice not created after picking for sale order1"
|
||||
-
|
||||
Now I create an invoice for order2 where Invoice Policy is "Invoice based on deliveries".
|
||||
Now I create draft invoice for order2 where Invoice Policy is "Invoice based on deliveries".
|
||||
-
|
||||
!python {model: stock.picking}: |
|
||||
order = self.pool.get('sale.order').browse(cr, uid, ref("order2"))
|
||||
@@ -138,4 +139,4 @@
|
||||
data = self.force_assign(cr, uid, [pick_ids[0]])
|
||||
if data == True:
|
||||
self.action_invoice_create(cr, uid, pick_ids, ref('account.expenses_journal'))
|
||||
assert order.invoice_ids, "Invoice not created after picking for sale order1"
|
||||
assert order.invoice_ids, "Invoice not created after picking for sale order2"
|
||||
@@ -0,0 +1,78 @@
|
||||
-
|
||||
test_sale.advance.payment.inv
|
||||
-
|
||||
In order to test the 'Make Invoices' wizard of sale module in the Open-ERP,
|
||||
I take a Sale order and create invoice.
|
||||
-
|
||||
I confirm the Sale Order.
|
||||
-
|
||||
!workflow {model: sale.order, action: order_confirm, ref: order3}
|
||||
-
|
||||
I confirm another Sale Order.
|
||||
-
|
||||
!workflow {model: sale.order, action: order_confirm, ref: order5}
|
||||
-
|
||||
Then I click on the "Make Invoices" button
|
||||
-
|
||||
!record {model: sale.make.invoice, id: sale_make_invoice_1}:
|
||||
grouped: 1
|
||||
invoice_date: !eval time.strftime('%Y-%m-%d')
|
||||
-
|
||||
Then I click on the "Create Invoices" button of wizard
|
||||
-
|
||||
!python {model: sale.make.invoice}: |
|
||||
context = {"lang": 'en_US', "search_default_user_id":1, "tz": False, "active_model": 'sale.order', "active_ids": [ref("order3"),ref("order5")], "active_id":ref("order3")}
|
||||
self.make_invoices(cr, uid, [ref("sale_make_invoice_1")], context)
|
||||
-
|
||||
I verify that an invoice has been created
|
||||
-
|
||||
!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"
|
||||
-
|
||||
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('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"
|
||||
for line in inv1:
|
||||
assert line.invoice_line, "Account invoice line has not been created for order5"
|
||||
-
|
||||
I open the Invoice for the SO.
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
import netsvc
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
inv = self.search(cr, uid, [('origin','=','SO003|SO005|')])
|
||||
print"..........account.cose_journal_sale................",inv,ref('account.cose_journal_sale')
|
||||
for id in inv:
|
||||
wf_service.trg_validate(uid, 'account.invoice',id,'invoice_open', cr)
|
||||
-
|
||||
I assign an analytic journal to the bank journal
|
||||
-
|
||||
!record {model: account.journal, id: sale.account_journal_bankjournal0}:
|
||||
analytic_journal_id: account.cose_journal_sale
|
||||
code: SAL
|
||||
name: sales Journal
|
||||
view_id: account.account_journal_view
|
||||
type: 'general'
|
||||
-
|
||||
I pay the invoice.
|
||||
-
|
||||
!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)])
|
||||
print invoice_id, ref('account.cash'), ref('account.period_5'),ref('sale.account_journal_bankjournal0'), ref('account.cash'),ref('account.period_8'), ref('sale.account_journal_bankjournal0')
|
||||
self.pay_and_reconcile(cr, uid, so.invoice_ids[0].id,40000.0, ref('account.cash'), ref('account.period_5'),ref('sale.account_journal_bankjournal0'), ref('account.cash'),ref('account.period_8'), ref('sale.account_journal_bankjournal0'),name='tst')
|
||||
-
|
||||
I verify the invoice is in Paid state
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice_id = self.search(cr, uid, [('origin','=','SO003|SO005|'),('state','=','paid')])
|
||||
assert invoice_id, "Invoice for SO is not in done state."
|
||||
@@ -43,6 +43,7 @@ class sale_make_invoice(osv.osv_memory):
|
||||
return False
|
||||
|
||||
def make_invoices(self, cr, uid, ids, context=None):
|
||||
print"yes in..............",ids
|
||||
order_obj = self.pool.get('sale.order')
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
newinv = []
|
||||
|
||||
Reference in New Issue
Block a user