2010-07-28 08:21:02 +00:00
|
|
|
-
|
|
|
|
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
|
|
|
|
-
|
2010-08-16 12:09:58 +00:00
|
|
|
!record {model: sale.order, id: sale_order_so9}:
|
2010-07-28 08:21:02 +00:00
|
|
|
date_order: '2010-07-17'
|
|
|
|
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.
|
|
|
|
-
|
2010-08-16 12:09:58 +00:00
|
|
|
!workflow {model: sale.order, action: order_confirm, ref: sale_order_so9}
|
2010-07-28 08:21:02 +00:00
|
|
|
-
|
|
|
|
I verify that the picking has been generated for the sale order
|
|
|
|
-
|
|
|
|
!python {model: sale.order}: |
|
2010-08-16 12:09:58 +00:00
|
|
|
so = self.browse(cr, uid, ref("sale_order_so9"))
|
|
|
|
assert so.picking_ids,"Picking has not been generated for sale_order_so9"
|
2010-07-28 08:21:02 +00:00
|
|
|
-
|
|
|
|
Then I click on the "Products Received" button of Incoming Shipments
|
|
|
|
-
|
|
|
|
!record {model: stock.partial.picking, id: stock_partial_picking_0}:
|
|
|
|
date: '2010-07-17 17:52:09'
|
|
|
|
-
|
|
|
|
Then I done the picking
|
|
|
|
-
|
|
|
|
!python {model: stock.picking }: |
|
|
|
|
import time
|
|
|
|
sale_order_obj = self.pool.get('sale.order')
|
2010-08-16 12:09:58 +00:00
|
|
|
so = sale_order_obj.browse(cr, uid, ref("sale_order_so9"))
|
2010-07-28 08:21:02 +00:00
|
|
|
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)
|
|
|
|
partial_datas = {
|
|
|
|
'partner_id':pick.address_id.partner_id.id,
|
|
|
|
'address_id': pick.address_id.id,
|
|
|
|
'delivery_date' : time.strftime('%Y-%m-%d'),
|
|
|
|
}
|
|
|
|
move = pick.move_lines[0]
|
|
|
|
partial_datas['move%s'%(move.id)]= {
|
|
|
|
'product_id': move.product_id.id,
|
|
|
|
'product_qty': '100',
|
|
|
|
'product_uom': move.product_uom.id,
|
|
|
|
}
|
|
|
|
self.do_partial(cr, uid, [pick.id],partial_datas)
|
|
|
|
-
|
|
|
|
I click on Create Invoice button to create the invoice.
|
|
|
|
-
|
2010-08-16 12:09:58 +00:00
|
|
|
!workflow {model: sale.order, action: manual_invoice, ref: sale_order_so9}
|
2010-07-28 08:21:02 +00:00
|
|
|
-
|
|
|
|
I verify whether the invoice has been generated for SO
|
|
|
|
-
|
|
|
|
!python {model: sale.order}: |
|
2010-08-16 12:09:58 +00:00
|
|
|
so = self.browse(cr, uid, ref("sale_order_so9"))
|
|
|
|
assert so.invoice_ids, "Invoices has not been generated for sale_order_so9"
|
2010-07-28 08:21:02 +00:00
|
|
|
-
|
|
|
|
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')
|
2010-08-16 12:09:58 +00:00
|
|
|
so = sale_order_obj.browse(cr, uid, ref("sale_order_so9"))
|
2010-07-28 08:21:02 +00:00
|
|
|
for so_lines in so.order_line:
|
2010-08-16 12:09:58 +00:00
|
|
|
qty = so_lines.product_uom_qty
|
|
|
|
ids = self.search(cr, uid, [('origin','=',so.name)])
|
2010-07-28 08:21:02 +00:00
|
|
|
inv_brw = self.browse(cr,uid,ids)[0]
|
|
|
|
for inv_lines in inv_brw.invoice_line:
|
2010-08-16 12:09:58 +00:00
|
|
|
qty1 = inv_lines.quantity
|
|
|
|
assert ('qty1','=','qty'), "Quantities are not same"
|
2010-07-28 08:21:02 +00:00
|
|
|
-
|
|
|
|
I open the Invoice for the SO.
|
|
|
|
-
|
|
|
|
!python {model: account.invoice}: |
|
|
|
|
sale_order_obj = self.pool.get('sale.order')
|
2010-08-16 12:09:58 +00:00
|
|
|
so = sale_order_obj.browse(cr, uid, ref("sale_order_so9"))
|
2010-07-28 08:21:02 +00:00
|
|
|
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)
|
|
|
|
-
|
2010-09-01 20:29:38 +00:00
|
|
|
Assign analytic jounal into bank journal
|
2010-09-01 16:08:45 +00:00
|
|
|
-
|
|
|
|
!record {model: account.journal, id: sale.account_journal_bankjournal0}:
|
|
|
|
analytic_journal_id: account.cose_journal_sale
|
2010-07-28 08:21:02 +00:00
|
|
|
-
|
2010-09-01 20:29:38 +00:00
|
|
|
I pay the invoice
|
2010-07-28 08:21:02 +00:00
|
|
|
-
|
2010-09-01 20:29:38 +00:00
|
|
|
!python {model: account.invoice}: |
|
2010-07-28 08:21:02 +00:00
|
|
|
sale_order_obj = self.pool.get('sale.order')
|
2010-08-16 12:09:58 +00:00
|
|
|
so = sale_order_obj.browse(cr, uid, ref("sale_order_so9"))
|
2010-09-01 20:29:38 +00:00
|
|
|
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')
|
2010-07-28 08:21:02 +00:00
|
|
|
-
|
|
|
|
I verify the invoice are in paid state or not.
|
|
|
|
-
|
|
|
|
!python {model: account.invoice}: |
|
|
|
|
sale_order_obj = self.pool.get('sale.order')
|
2010-08-16 12:09:58 +00:00
|
|
|
so = sale_order_obj.browse(cr, uid, ref("sale_order_so9"))
|
2010-07-28 08:21:02 +00:00
|
|
|
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}: |
|
2010-08-16 12:09:58 +00:00
|
|
|
sale_id=self.browse(cr, uid, ref("sale_order_so9"))
|
2010-09-01 16:08:45 +00:00
|
|
|
assert(sale_id.invoiced == True), "Paid has not been set to true"
|