From 10cd234bd27165c78ef5edf7faf312353f1aeb86 Mon Sep 17 00:00:00 2001 From: "MTR(OpenERP)" <> Date: Fri, 6 Aug 2010 10:51:01 +0530 Subject: [PATCH] [ADD] Sale_margin: YAML bzr revid: mra@mra-laptop-20100806052101-lf4m6fay3gfpf6x9 --- addons/sale_margin/__openerp__.py | 1 + addons/sale_margin/test/sale_margin.yml | 66 +++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 addons/sale_margin/test/sale_margin.yml diff --git a/addons/sale_margin/__openerp__.py b/addons/sale_margin/__openerp__.py index 3a59a69f105..1f10066de91 100644 --- a/addons/sale_margin/__openerp__.py +++ b/addons/sale_margin/__openerp__.py @@ -29,6 +29,7 @@ "author":"OpenERP SA", "depends":["sale"], "demo_xml":[], + 'test': ['test/sale_margin.yml'], "update_xml":["security/ir.model.access.csv","sale_margin_view.xml","report/report_margin_view.xml"], "active": False, "installable": True, diff --git a/addons/sale_margin/test/sale_margin.yml b/addons/sale_margin/test/sale_margin.yml new file mode 100644 index 00000000000..19a4f4ac9ee --- /dev/null +++ b/addons/sale_margin/test/sale_margin.yml @@ -0,0 +1,66 @@ +- + In order to test the sale_margin module in OpenERP, + I create a sale order and verify its margin +- + I place a sale order for product keyboard, quantity 50 +- + !record {model: sale.order, id: sale_order_so11}: + date_order: '2010-08-04' + invoice_quantity: order + name: Test_SO011 + order_line: + - name: '[KEYA] Keyboard - AZERTY' + price_unit: 7.0 + product_uom: product.product_uom_unit + product_uom_qty: 100.0 + state: draft + delay: 7.0 + product_id: product.product_product_24 + product_uos_qty: 100.0 + th_weight: 0.0 + type: make_to_stock + order_policy: manual + partner_id: base.res_partner_4 + partner_invoice_id: base.res_partner_address_7 + partner_order_id: base.res_partner_address_7 + partner_shipping_id: base.res_partner_address_7 + 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_so11} +- + I verify that margin field gets bind with the value +- + !python {model: sale.order}: | + so = self.browse(cr, uid, ref("sale_order_so11")) + assert so.margin, "No margin !" +- + I verify that the picking has been generated for the sale order +- + !python {model: sale.order}: | + so = self.browse(cr, uid, ref("sale_order_so11")) + assert so.picking_ids,"Picking has not been generated" +- + Then I click on the 'Create Invoice' button of 'Outgoing Orders' +- + !python {model: stock.picking}: | + sale_order_obj = self.pool.get('sale.order') + so = sale_order_obj.browse(cr, uid, ref("sale_order_so11")) + ids = self.search(cr, uid, [('origin', '=', so.name),('type', '=', 'out')]) + self.create_invoice(cr, uid, ids, {"lang": "en_US", "search_default_available": + 1, "tz": False, "active_model": "ir.ui.menu", "contact_display": "partner", + "active_ids": [ref("stock.menu_action_picking_tree")], "active_id": ref("stock.menu_action_picking_tree"), + }) +- + I verify that an invoice has been generated from picking +- + !python {model: stock.picking}: | + sale_order_obj = self.pool.get('sale.order') + so = sale_order_obj.browse(cr, uid, ref("sale_order_so11")) + pick_ids = self.search(cr, uid, [('origin', '=', so.name)]) + pick_brw = self.browse(cr, uid, pick_ids[0]) + assert pick_brw.invoice_ids,"Invoice has not been created" + \ No newline at end of file