diff --git a/analytic_contract_value/tests/test_analytic_contract_value.py b/analytic_contract_value/tests/test_analytic_contract_value.py index 663c909df..981b87e31 100644 --- a/analytic_contract_value/tests/test_analytic_contract_value.py +++ b/analytic_contract_value/tests/test_analytic_contract_value.py @@ -8,8 +8,10 @@ class TestAnalyticSchedule(common.SavepointCase): - def setUp(cls): - super(TestAnalyticSchedule, cls).setUp() + + @classmethod + def setUpClass(cls): + super(TestAnalyticSchedule, cls).setUpClass() cls.project_project = cls.env["project.project"] cls.project = cls.project_project.create( {"name": "Test project", "code": "ACV0001"} @@ -49,5 +51,6 @@ def setUp(cls): } ) - def test_contarct_value(cls): - cls.assertEquals(cls.account_id.contract_value, 100000.0, "Bad value") + def test_contarct_value(self): + self.assertEquals(self.account_id.contract_value, 100000.0, + "Bad value") diff --git a/analytic_cost_revenue/tests/test_analytic_cost_revenue.py b/analytic_cost_revenue/tests/test_analytic_cost_revenue.py index 563eba4ea..5e1d56417 100644 --- a/analytic_cost_revenue/tests/test_analytic_cost_revenue.py +++ b/analytic_cost_revenue/tests/test_analytic_cost_revenue.py @@ -5,8 +5,10 @@ class TestAnalyticCostRevenue(common.SavepointCase): - def setUp(cls): - super(TestAnalyticCostRevenue, cls).setUp() + + @classmethod + def setUpClass(cls): + super(TestAnalyticCostRevenue, cls).setUpClass() cls.project_project = cls.env["project.project"] cls.project = cls.project_project.create( {"name": "Test project", "code": "ACV0001"} @@ -78,8 +80,8 @@ def setUp(cls): } ) - def test_cost_revenue(cls): - cls.assertEqual(cls.account_id.material_cost, 100.0) - cls.assertEqual(cls.account_id.labor_cost, 0.0) - cls.assertEqual(cls.account_id.revenue, 200.0) - cls.assertEqual(cls.account_id.gross_profit, 100.0) + def test_cost_revenue(self): + self.assertEqual(self.account_id.material_cost, 100.0) + self.assertEqual(self.account_id.labor_cost, 0.0) + self.assertEqual(self.account_id.revenue, 200.0) + self.assertEqual(self.account_id.gross_profit, 100.0) diff --git a/analytic_plan_cost_revenue/tests/test_analytic_plan_cost_revenue.py b/analytic_plan_cost_revenue/tests/test_analytic_plan_cost_revenue.py index 371a190bb..10cd1dd28 100644 --- a/analytic_plan_cost_revenue/tests/test_analytic_plan_cost_revenue.py +++ b/analytic_plan_cost_revenue/tests/test_analytic_plan_cost_revenue.py @@ -6,8 +6,10 @@ class TestAnalyticCostRevenue(common.SavepointCase): - def setUp(cls): - super(TestAnalyticCostRevenue, cls).setUp() + + @classmethod + def setUpClass(cls): + super(TestAnalyticCostRevenue, cls).setUpClass() cls.project_project = cls.env["project.project"] cls.project = cls.project_project.create( {"name": "Test project", "code": "ACV0001"} @@ -99,8 +101,8 @@ def setUp(cls): } ) - def test_cost_revenue(cls): - cls.assertEqual(cls.account_id.material_cost_plan, -100.0) - cls.assertEqual(cls.account_id.labor_cost_plan, -0.0) - cls.assertEqual(cls.account_id.revenue_plan, 200.0) - cls.assertEqual(cls.account_id.gross_profit_plan, 100.0) + def test_cost_revenue(self): + self.assertEqual(self.account_id.material_cost_plan, -100.0) + self.assertEqual(self.account_id.labor_cost_plan, -0.0) + self.assertEqual(self.account_id.revenue_plan, 200.0) + self.assertEqual(self.account_id.gross_profit_plan, 100.0) diff --git a/analytic_resource_plan/tests/test_analytic_resource_plan.py b/analytic_resource_plan/tests/test_analytic_resource_plan.py index d45072806..58888cd21 100644 --- a/analytic_resource_plan/tests/test_analytic_resource_plan.py +++ b/analytic_resource_plan/tests/test_analytic_resource_plan.py @@ -10,8 +10,9 @@ class TestAnalyticResourcePlan(common.SavepointCase): - def setUp(cls): - super(TestAnalyticResourcePlan, cls).setUp() + @classmethod + def setUpClass(cls): + super(TestAnalyticResourcePlan, cls).setUpClass() cls.project = cls.env['project.project'].create( {'name': 'Test project', 'code': 'X0001'}) @@ -60,14 +61,14 @@ def _create_account(self, acc_type, name, code, company): }) return account - def test_plan(cls): - cls.resource_plan_line.action_button_confirm() - cls.assertEqual(cls.resource_plan_line.state, 'confirm') - plan_line = cls.env['account.analytic.line.plan'].search( - [('resource_plan_id', '=', cls.resource_plan_line.id)]) - cls.assertEqual(len(plan_line), 1, 'Wrong plan lines number') - cls.resource_plan_line.action_button_draft() - cls.assertEqual(cls.resource_plan_line.state, 'draft') - plan_line = cls.env['account.analytic.line.plan'].search( - [('resource_plan_id', '=', cls.resource_plan_line.id)]) - cls.assertEqual(len(plan_line), 0, 'Plan line not deleted') + def test_plan(self): + self.resource_plan_line.action_button_confirm() + self.assertEqual(self.resource_plan_line.state, 'confirm') + plan_line = self.env['account.analytic.line.plan'].search( + [('resource_plan_id', '=', self.resource_plan_line.id)]) + self.assertEqual(len(plan_line), 1, 'Wrong plan lines number') + self.resource_plan_line.action_button_draft() + self.assertEqual(self.resource_plan_line.state, 'draft') + plan_line = self.env['account.analytic.line.plan'].search( + [('resource_plan_id', '=', self.resource_plan_line.id)]) + self.assertEqual(len(plan_line), 0, 'Plan line not deleted') diff --git a/analytic_resource_plan_mrp/tests/test_analytic_resource_plan_mrp.py b/analytic_resource_plan_mrp/tests/test_analytic_resource_plan_mrp.py index 03c46c8bc..253df54d0 100644 --- a/analytic_resource_plan_mrp/tests/test_analytic_resource_plan_mrp.py +++ b/analytic_resource_plan_mrp/tests/test_analytic_resource_plan_mrp.py @@ -9,8 +9,10 @@ class TestAnalyticResourcePlanMrp( test_analytic_resource_plan_stock.TestAnalyticResourcePlanStock ): - def setUp(cls): - super(TestAnalyticResourcePlanMrp, cls).setUp() + + @classmethod + def setUpClass(cls): + super(TestAnalyticResourcePlanMrp, cls).setUpClass() cls.analytic_account_obj = cls.env["account.analytic.account"] cls.analytic_resource_plan_obj = cls.env["analytic.resource.plan.line"] cls.mrp_bom_obj = cls.env["mrp.bom"] @@ -39,10 +41,10 @@ def setUp(cls): cls.bom = cls._create_bom(cls.product_id) cls.resource_plan_line_wbom_id = cls._create_analytic_resource_plan( - cls.product_id - ) + cls.product_id) cls.account_id.bom_id = cls.bom.id + @classmethod def _create_bom(cls, product): test_bom = cls.mrp_bom_obj.create( { @@ -62,6 +64,7 @@ def _create_bom(cls, product): ) return test_bom + @classmethod def _create_analytic_account( cls, name, partner, analytic_plan_version, location ): @@ -74,6 +77,7 @@ def _create_analytic_account( } ) + @classmethod def _create_analytic_resource_plan(cls, product): return cls.analytic_resource_plan_obj.create( { @@ -87,40 +91,40 @@ def _create_analytic_resource_plan(cls, product): } ) - def test_resource_plan_line(cls): - cls.resource_plan_line_wbom_id.action_button_confirm() - child = cls.resource_plan_line_wbom_id.child_ids - plan_lines = cls.env["account.analytic.line.plan"].search( + def test_resource_plan_line(self): + self.resource_plan_line_wbom_id.action_button_confirm() + child = self.resource_plan_line_wbom_id.child_ids + plan_lines = self.env["account.analytic.line.plan"].search( [("resource_plan_id", "=", child.id)] ) - cls.assertEqual(len(plan_lines), 1, "bad plan lines") - cls.assertEqual(child.state, "confirm", "child not confirm") - cls.assertEqual(child.unit_amount, 4.0, "wrong qty in child") + self.assertEqual(len(plan_lines), 1, "bad plan lines") + self.assertEqual(child.state, "confirm", "child not confirm") + self.assertEqual(child.unit_amount, 4.0, "wrong qty in child") # test produce wiz_id = ( - cls.env["analytic.resource.plan.line.produce"] + self.env["analytic.resource.plan.line.produce"] .with_context( active_model="analytic.resource.plan.line", - active_ids=cls.resource_plan_line_wbom_id.id, + active_ids=self.resource_plan_line_wbom_id.id, ) .create({}) ) move_action = wiz_id.do_produce() move_id = safe_eval(move_action["domain"])[0][2] - move = cls.env["stock.move"].browse(move_id)[0] - cls.assertEqual( + move = self.env["stock.move"].browse(move_id)[0] + self.assertEqual( move.product_qty, child.unit_amount, "Wrong consumed qty" ) # test consume wiz_id = ( - cls.env["analytic.resource.plan.line.consume"] + self.env["analytic.resource.plan.line.consume"] .with_context( active_model="analytic.resource.plan.line", - active_ids=cls.resource_plan_line_wbom_id.id, + active_ids=self.resource_plan_line_wbom_id.id, ) .create({}) ) wiz_id.do_consume() - cls.assertEqual( + self.assertEqual( move.product_qty, child.unit_amount, "Wrong consumed qty" ) diff --git a/analytic_resource_plan_purchase_request/tests/test_analytic_resource_plan_purchase.py b/analytic_resource_plan_purchase_request/tests/test_analytic_resource_plan_purchase.py index a576197db..5f45491f8 100644 --- a/analytic_resource_plan_purchase_request/tests/test_analytic_resource_plan_purchase.py +++ b/analytic_resource_plan_purchase_request/tests/test_analytic_resource_plan_purchase.py @@ -12,41 +12,43 @@ class TestAnalyticResourcePlanPurchase( test_analytic_resource_plan_stock.TestAnalyticResourcePlanStock ): - def setUp(cls): - super(TestAnalyticResourcePlanPurchase, cls).setUp() - def test_res_purchase(cls): - cls.assertEqual( - cls.resource_plan_line.qty_available, + @classmethod + def setUpClass(cls): + super(TestAnalyticResourcePlanPurchase, cls).setUpClass() + + def test_res_purchase(self): + self.assertEqual( + self.resource_plan_line.qty_available, 0.0, "Showing qty where there is not", ) - cls.assertEqual( - cls.resource_plan_line.request_state, "none", "should no request" + self.assertEqual( + self.resource_plan_line.request_state, "none", "should no request" ) - cls.resource_plan_line.action_button_confirm() - cls.assertEqual( - cls.resource_plan_line.request_state, + self.resource_plan_line.action_button_confirm() + self.assertEqual( + self.resource_plan_line.request_state, "draft", "should draft request", ) - purchase_request_line = cls.resource_plan_line.purchase_request_lines[ + purchase_request_line = self.resource_plan_line.purchase_request_lines[ 0 ] purchase_request = purchase_request_line.request_id purchase_request.button_to_approve() purchase_request.button_approved() - cls.assertEqual( - cls.resource_plan_line.request_state, + self.assertEqual( + self.resource_plan_line.request_state, "approved", "should approved request", ) - cls.assertEqual( - cls.resource_plan_line.requested_qty, 1.0, "requested wrong qty" + self.assertEqual( + self.resource_plan_line.requested_qty, 1.0, "requested wrong qty" ) - cls.resource_plan_line.action_button_draft() - cls.assertEqual( - cls.resource_plan_line.request_state, + self.resource_plan_line.action_button_draft() + self.assertEqual( + self.resource_plan_line.request_state, "rejected", "should rejected request", ) diff --git a/analytic_resource_plan_stock/tests/test_analytic_resource_plan_stock.py b/analytic_resource_plan_stock/tests/test_analytic_resource_plan_stock.py index 22310779e..293bd19b2 100644 --- a/analytic_resource_plan_stock/tests/test_analytic_resource_plan_stock.py +++ b/analytic_resource_plan_stock/tests/test_analytic_resource_plan_stock.py @@ -11,72 +11,72 @@ class TestAnalyticResourcePlanStock( test_analytic_resource_plan.TestAnalyticResourcePlan): - def setUp(cls): - super(TestAnalyticResourcePlanStock, cls).setUp() + @classmethod + def setUpClass(cls): + super(TestAnalyticResourcePlanStock, cls).setUpClass() cls.location = cls.env['stock.location'].create({ 'name': 'ACC', 'usage': 'internal', - 'parent_id': cls.env.ref('stock.stock_location_stock').id, 'analytic_account_id': cls.account_id.id}) cls.account_id.location_id = cls.location - def test_res_stock(cls): - cls.assertEqual(cls.resource_plan_line.qty_available, 0.0, - 'Showing qty where there is not') - cls.resource_plan_line.action_button_confirm() + def test_res_stock(self): + self.assertEqual(self.resource_plan_line.qty_available, 0.0, + 'Showing qty where there is not') + self.resource_plan_line.action_button_confirm() - picking_in = cls.env['stock.picking'].create({ - 'picking_type_id': cls.env.ref('stock.picking_type_in').id, - 'location_id': cls.env.ref('stock.stock_location_suppliers').id, - 'location_dest_id': cls.account_id.location_id.id}) - move1 = cls.env['stock.move'].create({ + picking_in = self.env['stock.picking'].create({ + 'picking_type_id': self.env.ref('stock.picking_type_in').id, + 'location_id': self.env.ref('stock.stock_location_suppliers').id, + 'location_dest_id': self.account_id.location_id.id}) + move1 = self.env['stock.move'].create({ 'name': '/', - 'product_id': cls.resource_plan_line.product_id.id, + 'product_id': self.resource_plan_line.product_id.id, 'product_uom_qty': 5.0, - 'analytic_account_id': cls.account_id.id, + 'analytic_account_id': self.account_id.id, 'picking_id': picking_in.id, 'procure_method': 'make_to_stock', - 'product_uom': cls.resource_plan_line.product_id.uom_id.id, - 'location_id': cls.env.ref('stock.stock_location_suppliers').id, - 'location_dest_id': cls.account_id.location_id.id, + 'product_uom': self.resource_plan_line.product_id.uom_id.id, + 'location_id': self.env.ref('stock.stock_location_suppliers').id, + 'location_dest_id': self.account_id.location_id.id, }) picking_in.action_confirm() - cls.resource_plan_line._compute_quantities() + self.resource_plan_line._compute_quantities() # recomputing here as no relation to the pickings in this module # to put in the api depends - cls.assertEqual(cls.resource_plan_line.incoming_qty, 5.0, - 'Bad Incoming Qty') - cls.assertEqual(cls.resource_plan_line.virtual_available, 5.0, - 'Bad virtual Qty') + self.assertEqual(self.resource_plan_line.incoming_qty, 5.0, + 'Bad Incoming Qty') + self.assertEqual(self.resource_plan_line.virtual_available, 5.0, + 'Bad virtual Qty') picking_in.button_validate() - cls.assertEqual(cls.resource_plan_line.qty_available, 0.0, - 'Bad QTY Available') - picking_out = cls.env['stock.picking'].create({ - 'picking_type_id': cls.env.ref('stock.picking_type_out').id, - 'location_id': cls.location.id, - 'location_dest_id': cls.env.ref( + self.assertEqual(self.resource_plan_line.qty_available, 0.0, + 'Bad QTY Available') + picking_out = self.env['stock.picking'].create({ + 'picking_type_id': self.env.ref('stock.picking_type_out').id, + 'location_id': self.location.id, + 'location_dest_id': self.env.ref( 'stock.stock_location_customers').id}) move1.move_line_ids.qty_done = 5.0 picking_in.action_done() - cls.env['stock.move'].create({ + self.env['stock.move'].create({ 'name': '/', - 'product_id': cls.resource_plan_line.product_id.id, + 'product_id': self.resource_plan_line.product_id.id, 'product_uom_qty': 4.0, 'procure_method': 'make_to_stock', - 'analytic_account_id': cls.account_id.id, + 'analytic_account_id': self.account_id.id, 'picking_id': picking_out.id, - 'product_uom': cls.resource_plan_line.product_id.uom_id.id, - 'location_id': cls.location.id, + 'product_uom': self.resource_plan_line.product_id.uom_id.id, + 'location_id': self.location.id, 'location_dest_id': - cls.env.ref('stock.stock_location_customers').id, + self.env.ref('stock.stock_location_customers').id, }) picking_out.action_confirm() - cls.resource_plan_line._compute_quantities() + self.resource_plan_line._compute_quantities() # recomputing here as no relation to the pickings in this module # to put in the api depends - cls.assertEqual(cls.resource_plan_line.virtual_available, 1.0, - 'Bad Virtually Qty available') - cls.assertEqual(cls.resource_plan_line.outgoing_qty, 4.0, - 'Bad Outgoing Qty') + self.assertEqual(self.resource_plan_line.virtual_available, 1.0, + 'Bad Virtually Qty available') + self.assertEqual(self.resource_plan_line.outgoing_qty, 4.0, + 'Bad Outgoing Qty') diff --git a/analytic_resource_plan_stock_picking_operating_unit/tests/test_analytic_resource_plan_stock_picking.py b/analytic_resource_plan_stock_picking_operating_unit/tests/test_analytic_resource_plan_stock_picking.py index cb48db537..240c65e5c 100644 --- a/analytic_resource_plan_stock_picking_operating_unit/tests/test_analytic_resource_plan_stock_picking.py +++ b/analytic_resource_plan_stock_picking_operating_unit/tests/test_analytic_resource_plan_stock_picking.py @@ -10,8 +10,10 @@ class TestAnalyticResourcePlanStockPicking( test_analytic_resource_plan_stock.TestAnalyticResourcePlanStock ): - def setUp(cls): - super(TestAnalyticResourcePlanStockPicking, cls).setUp() + + @classmethod + def setUpClass(cls): + super(TestAnalyticResourcePlanStockPicking, cls).setUpClass() cls.analytic_account_obj = cls.env["account.analytic.account"] cls.resource_plan_line_obj = cls.env["analytic.resource.plan.line"] cls.product_id = cls.env.ref("product.product_product_27") @@ -42,26 +44,26 @@ def setUp(cls): } ) - def test_analytic_resource_plan_stock_picking(cls): + def test_analytic_resource_plan_stock_picking(self): # error if no location - with cls.assertRaises(ValidationError): - cls.account_id.location_id = False - cls.resource_plan_line.action_button_confirm() - cls.account_id.location_id = cls.env.ref( + with self.assertRaises(ValidationError): + self.account_id.location_id = False + self.resource_plan_line.action_button_confirm() + self.account_id.location_id = self.env.ref( "stock.stock_location_stock" ) - cls.unit_amount = 2.0 - upd_qty = cls.env["stock.change.product.qty"].create( + self.unit_amount = 2.0 + upd_qty = self.env["stock.change.product.qty"].create( { - "product_id": cls.resource_plan_line.product_id.id, + "product_id": self.resource_plan_line.product_id.id, "product_tmpl_id": - cls.resource_plan_line.product_id.product_tmpl_id.id, + self.resource_plan_line.product_id.product_tmpl_id.id, "new_quantity": 1.0, - "location_id": cls.env.ref("stock.stock_location_stock").id, + "location_id": self.env.ref("stock.stock_location_stock").id, } ) upd_qty.change_product_qty() - cls.resource_plan_line.action_button_confirm() - cls.assertEqual( - cls.resource_plan_line.qty_fetched, 1.0, "bad qty fetched" + self.resource_plan_line.action_button_confirm() + self.assertEqual( + self.resource_plan_line.qty_fetched, 1.0, "bad qty fetched" ) diff --git a/analytic_resource_plan_stock_picking_purchase_request/tests/test_analytic_resource_plan_stock_picking_purchase_request.py b/analytic_resource_plan_stock_picking_purchase_request/tests/test_analytic_resource_plan_stock_picking_purchase_request.py index 562f3e345..eb3af7a66 100644 --- a/analytic_resource_plan_stock_picking_purchase_request/tests/test_analytic_resource_plan_stock_picking_purchase_request.py +++ b/analytic_resource_plan_stock_picking_purchase_request/tests/test_analytic_resource_plan_stock_picking_purchase_request.py @@ -9,9 +9,12 @@ class TestAnalyticResourcePlanStockPickingPurchaseRequest( test_analytic_resource_plan_stock.TestAnalyticResourcePlanStock ): - def setUp(cls): + + @classmethod + def setUpClass(cls): super( - TestAnalyticResourcePlanStockPickingPurchaseRequest, cls).setUp() + TestAnalyticResourcePlanStockPickingPurchaseRequest, cls + ).setUpClass() cls.analytic_account_obj = cls.env["account.analytic.account"] cls.resource_plan_line_obj = cls.env["analytic.resource.plan.line"] cls.product_id = cls.env.ref("product.product_product_27") @@ -42,30 +45,30 @@ def setUp(cls): } ) - def test_analytic_resource_plan_stock_picking(cls): - cls.resource_plan_line.unit_amount = 2.0 - upd_qty = cls.env["stock.change.product.qty"].create( + def test_analytic_resource_plan_stock_picking(self): + self.resource_plan_line.unit_amount = 2.0 + upd_qty = self.env["stock.change.product.qty"].create( { - "product_id": cls.resource_plan_line.product_id.id, + "product_id": self.resource_plan_line.product_id.id, "product_tmpl_id": - cls.resource_plan_line.product_id.product_tmpl_id.id, + self.resource_plan_line.product_id.product_tmpl_id.id, "new_quantity": 1.0, - "location_id": cls.env.ref("stock.stock_location_stock").id, + "location_id": self.env.ref("stock.stock_location_stock").id, } ) upd_qty.change_product_qty() - cls.resource_plan_line.action_button_confirm() - purchase_request_line = cls.resource_plan_line.purchase_request_lines[ + self.resource_plan_line.action_button_confirm() + purchase_request_line = self.resource_plan_line.purchase_request_lines[ 0 ] purchase_request = purchase_request_line.request_id purchase_request.button_to_approve() purchase_request.button_approved() - cls.assertEqual( - cls.resource_plan_line.request_state, + self.assertEqual( + self.resource_plan_line.request_state, "approved", "should approved request", ) - cls.assertEqual( - cls.resource_plan_line.requested_qty, 1.0, "bad qty requested" + self.assertEqual( + self.resource_plan_line.requested_qty, 1.0, "bad qty requested" ) diff --git a/analytic_schedule/tests/test_analytic_resource_plan.py b/analytic_schedule/tests/test_analytic_resource_plan.py index 5d96c9ab1..afb51d930 100644 --- a/analytic_schedule/tests/test_analytic_resource_plan.py +++ b/analytic_schedule/tests/test_analytic_resource_plan.py @@ -11,8 +11,10 @@ class TestAnalyticSchedule(common.SavepointCase): - def setUp(cls): - super(TestAnalyticSchedule, cls).setUp() + + @classmethod + def setUpClass(cls): + super(TestAnalyticSchedule, cls).setUpClass() cls.project_project = cls.env["project.project"] cls.project = cls.project_project.create( @@ -30,25 +32,25 @@ def setUp(cls): cls.grand_son_account = cls.project_grand_son.analytic_account_id cls.grand_son_account.parent_id = cls.son_account - def test_schedule(cls): + def test_schedule(self): date = datetime.strftime(datetime.today(), DEFAULT_SERVER_DATE_FORMAT) - cls.project_grand_son.date_start = date - cls.project_grand_son.date = date + self.project_grand_son.date_start = date + self.project_grand_son.date = date - cls.assertEquals( - cls.parent_account.date_start, cls.grand_son_account.date_start + self.assertEquals( + self.parent_account.date_start, self.grand_son_account.date_start ) - cls.project_son.date = datetime.strftime( + self.project_son.date = datetime.strftime( datetime.today() + relativedelta(months=9), DEFAULT_SERVER_DATE_FORMAT, ) - cls.assertNotEqual( - cls.grand_son_account.date, - cls.son_account.date, + self.assertNotEqual( + self.grand_son_account.date, + self.son_account.date, "Should Not propagate downwards", ) - cls.assertEquals( - cls.son_account.date, - cls.parent_account.date, + self.assertEquals( + self.son_account.date, + self.parent_account.date, "Should propagate upwards", ) diff --git a/purchase_request_sale/tests/test_purchase_request_sale.py b/purchase_request_sale/tests/test_purchase_request_sale.py index e6d02474f..ace3d0f08 100644 --- a/purchase_request_sale/tests/test_purchase_request_sale.py +++ b/purchase_request_sale/tests/test_purchase_request_sale.py @@ -6,37 +6,38 @@ class TestPurchaseRequestProcurement(common.SavepointCase): - def setUp(self): - super(TestPurchaseRequestProcurement, self).setUp() - self.pr_model = self.env['purchase.request'] - self.prl_model = self.env['purchase.request.line'] - self.product_uom_model = self.env['uom.uom'] - self.supplierinfo_model = self.env['product.supplierinfo'] + @classmethod + def setUpClass(cls): + super(TestPurchaseRequestProcurement, cls).setUpClass() + cls.pr_model = cls.env['purchase.request'] + cls.prl_model = cls.env['purchase.request.line'] + cls.product_uom_model = cls.env['uom.uom'] + cls.supplierinfo_model = cls.env['product.supplierinfo'] partner_values = {'name': 'Tupac'} - self.partner = self.env['res.partner'].create(partner_values) + cls.partner = cls.env['res.partner'].create(partner_values) partner_values = {'name': 'Todo a 100'} - self.partner_buy = self.env['res.partner'].create(partner_values) - self.uom_unit_categ = self.env.ref('uom.product_uom_categ_unit') + cls.partner_buy = cls.env['res.partner'].create(partner_values) + cls.uom_unit_categ = cls.env.ref('uom.product_uom_categ_unit') product_values = {'name': 'Odoo', 'list_price': 5, 'type': 'product'} - self.product = self.env['product.product'].create(product_values) - self.product_uom_unit = self.env.ref('uom.product_uom_unit') - self.product.route_ids = ( - self.env.ref('stock.route_warehouse0_mto') | - self.env.ref('purchase_stock.route_warehouse0_buy') + cls.product = cls.env['product.product'].create(product_values) + cls.product_uom_unit = cls.env.ref('uom.product_uom_unit') + cls.product.route_ids = ( + cls.env.ref('stock.route_warehouse0_mto') | + cls.env.ref('purchase_stock.route_warehouse0_buy') ) - for rule in self.env.ref( + for rule in cls.env.ref( 'purchase_stock.route_warehouse0_buy').rule_ids: rule.propagate = True rule.group_propagation_option = 'propagate' supplierinfo_vals = { - 'name': self.partner_buy.id, - 'product_tmpl_id': self.product.product_tmpl_id.id, + 'name': cls.partner_buy.id, + 'product_tmpl_id': cls.product.product_tmpl_id.id, 'price': 121.0 } - self.supplierinfo_model.create(supplierinfo_vals) - self.product.product_tmpl_id.purchase_request = True + cls.supplierinfo_model.create(supplierinfo_vals) + cls.product.product_tmpl_id.purchase_request = True def create_sale_order(self): sale_obj = self.env['sale.order']