From 20099f3fd19db14901b60c48cf9cdc046423aa50 Mon Sep 17 00:00:00 2001 From: mtr Date: Wed, 28 Jul 2010 13:51:02 +0530 Subject: [PATCH] [ADD] sale:-added two new yamls for invoice based on shipped qty and ordered qty bzr revid: mtr@mtr-20100728082102-mqcos80ueufpqjwq --- addons/sale/__openerp__.py | 2 + addons/sale/test/invoice_on_ordered_qty.yml | 151 +++++++++++++++++++ addons/sale/test/invoice_on_shipped_qty.yml | 154 ++++++++++++++++++++ 3 files changed, 307 insertions(+) create mode 100644 addons/sale/test/invoice_on_ordered_qty.yml create mode 100644 addons/sale/test/invoice_on_shipped_qty.yml diff --git a/addons/sale/__openerp__.py b/addons/sale/__openerp__.py index dc74ca9f24e..a2cbd894096 100644 --- a/addons/sale/__openerp__.py +++ b/addons/sale/__openerp__.py @@ -78,6 +78,8 @@ 'test/so_make_line_invoice.yml', 'test/so_make_invoice.yml', 'test/sale_procurement.yml', + 'test/invoice_on_ordered_qty.yml', + 'test/invoice_on_shipped_qty.yml', ], 'installable': True, 'active': False, diff --git a/addons/sale/test/invoice_on_ordered_qty.yml b/addons/sale/test/invoice_on_ordered_qty.yml new file mode 100644 index 00000000000..9056e4cbb83 --- /dev/null +++ b/addons/sale/test/invoice_on_ordered_qty.yml @@ -0,0 +1,151 @@ +- + 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_so8}: + 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. +- + !workflow {model: sale.order, action: order_confirm, ref: sale_order_so8} +- + I verify that the picking has been generated for the sale order +- + !python {model: sale.order}: | + so = self.browse(cr, uid, ref("sale_order_so8")) + assert so.picking_ids,"Picking has not been generated for sale_order_so8" +- + 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') + so = sale_order_obj.browse(cr, uid, ref("sale_order_so8")) + 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. +- + !workflow {model: sale.order, action: manual_invoice, ref: sale_order_so8} +- + I verify whether the invoice has been generated for SO +- + !python {model: sale.order}: | + so = self.browse(cr, uid, ref("sale_order_so8")) + assert so.invoice_ids, "Invoices has not been generated for sale_order_so8" +- + 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_so8")) + 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 + invoice_id = self.search(cr, uid, [('qty1','=', 'qty') and ('origin', '=', so.name)]) + assert invoice_id, "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_so8")) + 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) +- + Creating a account invoice pay entry. +- + !record {model: account.invoice.pay, id: account_invoice_pay_tst1}: + amount: 40000.0 + date: '2010-07-17' + journal_id: sale.account_journal_bankjournal0 + name: tst + period_id: account.period_5 +- + I pay the invoice. +- + !python {model: account.invoice.pay}: | + sale_order_obj = self.pool.get('sale.order') + so = sale_order_obj.browse(cr, uid, ref("sale_order_so8")) + self.wo_check(cr, uid, [ref("account_invoice_pay_tst1")], {"lang": "en_US", "tz": + False, "active_model": 'account.invoice', "active_ids": [so.invoice_ids[0].id], "type": + "out_invoice", "active_id": so.invoice_ids[0].id, }) +- + Creating an account invoice pay writeoff entry. +- + !record {model: account.invoice.pay.writeoff, id: account_invoice_pay_writeoff_0}: + analytic_id: account.analytic_customers + comment: Write-Off + writeoff_acc_id: account.a_sale + writeoff_journal_id: sale.account_journal_bankjournal0 +- + Pay and Reconcile the Invoice. +- + !python {model: account.invoice.pay.writeoff}: | + sale_order_obj = self.pool.get('sale.order') + so = sale_order_obj.browse(cr, uid, ref("sale_order_so8")) + self.pay_and_reconcile_writeoff(cr, uid, [ref("account_invoice_pay_writeoff_0")], + {"lang": 'en_US', "tz": False, "active_model": 'account.invoice', "active_ids": + [so.invoice_ids[0].id], "type": "out_invoice", "active_id": so.invoice_ids[0].id }) +- + 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_so8")) + 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_so8")) + assert(sale_id.invoiced == True), "Paid has not been set to true" \ No newline at end of file diff --git a/addons/sale/test/invoice_on_shipped_qty.yml b/addons/sale/test/invoice_on_shipped_qty.yml new file mode 100644 index 00000000000..5a608aff9b8 --- /dev/null +++ b/addons/sale/test/invoice_on_shipped_qty.yml @@ -0,0 +1,154 @@ +- + 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 'Shipped quantities' + in order to create an invoice based on the shipping quantity +- + !record {model: sale.order, id: sale_order_so6}: + 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: procurement + 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_so6} +- + I verify that the picking has been generated for the sale order +- + !python {model: sale.order}: | + so = self.browse(cr, uid, ref("sale_order_so6")) + assert so.picking_ids,"Picking has not been generated for sale_order_so6" +- + 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') + so = sale_order_obj.browse(cr, uid, ref("sale_order_so6")) + 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. +- + !workflow {model: sale.order, action: manual_invoice, ref: sale_order_so6} +- + I verify whether the invoice has been generated for SO +- + !python {model: sale.order}: | + so = self.browse(cr, uid, ref("sale_order_so6")) + assert so.invoice_ids, "Invoices has not been generated for sale_order_so6" +- + I verify that an invoice is created on the basis of shipped quantity +- + !python {model: account.invoice}: | + sale_order_obj = self.pool.get('sale.order') + so = sale_order_obj.browse(cr, uid, ref("sale_order_so6")) + picking_obj = self.pool.get('stock.picking') + ids = picking_obj.search(cr, uid, [('origin', '=', so.name)]) + pick_brw = picking_obj.browse(cr,uid, ids)[0] + for lines in pick_brw.move_lines: + qty=lines.product_qty + inv_id = self.search(cr, uid, [('origin', '=', so.name)]) + inv_brw = self.browse(cr,uid,inv_id)[0] + for inv_lines in inv_brw.invoice_line: + qty1=inv_lines.quantity + invoice_id = self.search(cr, uid, [('qty1','=', 'qty') and ('origin', '=', so.name)]) + assert invoice_id, "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_so6")) + 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) +- + Creating a account invoice pay entry. +- + !record {model: account.invoice.pay, id: account_invoice_pay_tst1}: + amount: 20000.0 + date: '2010-07-17' + journal_id: sale.account_journal_bankjournal0 + name: tst + period_id: account.period_5 +- + I pay the invoice. +- + !python {model: account.invoice.pay}: | + sale_order_obj = self.pool.get('sale.order') + so = sale_order_obj.browse(cr, uid, ref("sale_order_so6")) + self.wo_check(cr, uid, [ref("account_invoice_pay_tst1")], {"lang": "en_US", "tz": + False, "active_model": 'account.invoice', "active_ids": [so.invoice_ids[0].id], "type": + "out_invoice", "active_id": so.invoice_ids[0].id, }) +- + Creating an account invoice pay writeoff entry. +- + !record {model: account.invoice.pay.writeoff, id: account_invoice_pay_writeoff_0}: + analytic_id: account.analytic_customers + comment: Write-Off + writeoff_acc_id: account.a_sale + writeoff_journal_id: sale.account_journal_bankjournal0 +- + Pay and Reconcile the Invoice. +- + !python {model: account.invoice.pay.writeoff}: | + sale_order_obj = self.pool.get('sale.order') + so = sale_order_obj.browse(cr, uid, ref("sale_order_so6")) + self.pay_and_reconcile_writeoff(cr, uid, [ref("account_invoice_pay_writeoff_0")], + {"lang": 'en_US', "tz": False, "active_model": 'account.invoice', "active_ids": + [so.invoice_ids[0].id], "type": "out_invoice", "active_id": so.invoice_ids[0].id }) +- + 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_so6")) + 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_so6")) + assert(sale_id.invoiced == True), "Paid has not been set to true"