summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnand Kansagra <aka@openerp.com>2015-08-06 12:07:57 +0530
committerMartin Trigaux <mat@odoo.com>2015-12-16 10:29:09 +0100
commit2e4fce618e9036e113c7d412be71b8a5a1c67faf (patch)
tree4809f9e5442d26f14e660eaa388310993092907b
parent1ca86e70dec275e24503c5441ce452a8e4763927 (diff)
[MIG] sale_margin: Converted test case from yml to python.
-rw-r--r--addons/sale_margin/__openerp__.py1
-rw-r--r--addons/sale_margin/test/sale_margin.yml31
-rw-r--r--addons/sale_margin/tests/__init__.py4
-rw-r--r--addons/sale_margin/tests/test_sale_margin.py41
4 files changed, 45 insertions, 32 deletions
diff --git a/addons/sale_margin/__openerp__.py b/addons/sale_margin/__openerp__.py
index 706c55aa002..f8289c67545 100644
--- a/addons/sale_margin/__openerp__.py
+++ b/addons/sale_margin/__openerp__.py
@@ -14,6 +14,5 @@ Price and Cost Price.
""",
'depends':['sale'],
'demo':['data/sale_margin_demo.xml'],
- 'test': ['test/sale_margin.yml'],
'data':['security/ir.model.access.csv','views/sale_margin_view.xml'],
}
diff --git a/addons/sale_margin/test/sale_margin.yml b/addons/sale_margin/test/sale_margin.yml
deleted file mode 100644
index 38b987d30f5..00000000000
--- a/addons/sale_margin/test/sale_margin.yml
+++ /dev/null
@@ -1,31 +0,0 @@
--
- 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: !eval time.strftime('%Y-%m-%d')
- name: Test_SO011
- order_line:
- - name: '[CARD] Graphics Card'
- price_unit: 7.0
- product_uom: product.product_uom_unit
- product_uom_qty: 100.0
- state: draft
- product_id: product.product_product_24
- partner_id: base.res_partner_4
- partner_invoice_id: base.res_partner_address_7
- partner_shipping_id: base.res_partner_address_7
- pricelist_id: product.list0
--
- I confirm the sale order
--
- !python {model: sale.order}: |
- self.action_confirm(cr, uid, [ref("sale_order_so11")], context=context)
--
- 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 !"
diff --git a/addons/sale_margin/tests/__init__.py b/addons/sale_margin/tests/__init__.py
new file mode 100644
index 00000000000..4a3d8eb45c4
--- /dev/null
+++ b/addons/sale_margin/tests/__init__.py
@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from . import test_sale_margin
diff --git a/addons/sale_margin/tests/test_sale_margin.py b/addons/sale_margin/tests/test_sale_margin.py
new file mode 100644
index 00000000000..c2481690a2d
--- /dev/null
+++ b/addons/sale_margin/tests/test_sale_margin.py
@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo.tests import common
+from datetime import datetime
+
+
+class TestSaleMargin(common.TransactionCase):
+
+ def setUp(self):
+ super(TestSaleMargin, self).setUp()
+ self.SaleOrder = self.env['sale.order']
+
+ self.product_uom_id = self.ref('product.product_uom_unit')
+ self.product_id = self.ref('product.product_product_24')
+ self.partner_id = self.ref('base.res_partner_4')
+ self.partner_invoice_address_id = self.ref('base.res_partner_address_7')
+ self.pricelist_id = self.ref('product.list0')
+
+ def test_sale_margin(self):
+ """ Test the sale_margin module in Odoo. """
+ # Create a sale order for product Graphics Card.
+ sale_order_so11 = self.SaleOrder.create({
+ 'date_order': datetime.today(),
+ 'name': 'Test_SO011',
+ 'order_line': [(0, 0, {
+ 'name': '[CARD] Graphics Card',
+ 'purchase_price': 700.0,
+ 'price_unit': 1000.0,
+ 'product_uom': self.product_uom_id,
+ 'product_uom_qty': 10.0,
+ 'state': 'draft',
+ 'product_id': self.product_id})],
+ 'partner_id': self.partner_id,
+ 'partner_invoice_id': self.partner_invoice_address_id,
+ 'partner_shipping_id': self.partner_invoice_address_id,
+ 'pricelist_id': self.pricelist_id})
+ # Confirm the sale order.
+ sale_order_so11.action_confirm()
+ # Verify that margin field gets bind with the value.
+ self.assertEqual(sale_order_so11.margin, 3000.00, "Sale order margin should be 3000.00")