From 44b83eab9bda9f828b9dda2b19e2bb4639864a9f Mon Sep 17 00:00:00 2001 From: Denis Leemann Date: Wed, 31 May 2017 15:57:43 +0200 Subject: [PATCH] Add tests --- .../data/sale_project_fixed_price_demo.xml | 35 ++++++++++++++++++ .../tests/__init__.py | 2 ++ .../tests/sale_project_fixed_price.py | 36 +++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 sale_project_fixed_price_task_completed_invoicing/data/sale_project_fixed_price_demo.xml create mode 100644 sale_project_fixed_price_task_completed_invoicing/tests/sale_project_fixed_price.py diff --git a/sale_project_fixed_price_task_completed_invoicing/data/sale_project_fixed_price_demo.xml b/sale_project_fixed_price_task_completed_invoicing/data/sale_project_fixed_price_demo.xml new file mode 100644 index 000000000000..d43721730325 --- /dev/null +++ b/sale_project_fixed_price_task_completed_invoicing/data/sale_project_fixed_price_demo.xml @@ -0,0 +1,35 @@ + + + + + timesheet + + + Support Contract (on timesheet) + timesheet + + + + + Advance + + + 150.0 + 5.0 + + + + + Internal - GAP Analysis + 2 + employees + project.task + + + + + task + + + + diff --git a/sale_project_fixed_price_task_completed_invoicing/tests/__init__.py b/sale_project_fixed_price_task_completed_invoicing/tests/__init__.py index e69de29bb2d1..4bcef9f22298 100644 --- a/sale_project_fixed_price_task_completed_invoicing/tests/__init__.py +++ b/sale_project_fixed_price_task_completed_invoicing/tests/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . sale_project_fixed_price diff --git a/sale_project_fixed_price_task_completed_invoicing/tests/sale_project_fixed_price.py b/sale_project_fixed_price_task_completed_invoicing/tests/sale_project_fixed_price.py new file mode 100644 index 000000000000..0f0f44259d2e --- /dev/null +++ b/sale_project_fixed_price_task_completed_invoicing/tests/sale_project_fixed_price.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. +from odoo.addons.sale.tests.test_sale_common import TestSale + + +class TestSaleProjectFixedPrice(TestSale): + + def test_sale_project_fixed_price(self): + prod_task = self.env.ref('product.product_product_fixed_price') + so_vals = { + 'partner_id': self.partner.id, + 'partner_invoice_id': self.partner.id, + 'partner_shipping_id': self.partner.id, + 'order_line': [(0, 0, {'name': prod_task.name, + 'product_id': prod_task.id, + 'product_uom_qty': 1, + 'product_uom': prod_task.uom_id.id, + 'price_unit': prod_task.list_price})], + 'pricelist_id': self.env.ref('product.list0').id, + } + so = self.env['sale.order'].create(so_vals) + so.action_confirm() + + # check task creation + project = self.env.ref('sale_timesheet.project_GAP') + task = project.task_ids.filtered( + lambda t: t.name == '%s:%s' % (so.name, prod_task.name)) + self.assertTrue(task, 'Sale Service: task is not created') + self.assertEqual(task.partner_id, so.partner_id, + 'Sale Service: customer should be the same on task ' + 'and on SO') + # validate the task + task.toggle_invoiceable() + line = so.order_line + self.assertTrue(line.product_uom_qty == line.qty_delivered, + 'Sale Service: line should be invoiced completely')