Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
leemannd committed May 31, 2017
1 parent 352dad1 commit 44b83ea
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="product.service_order_01" model="product.product">
<field name="track_service">timesheet</field>
</record>
<record id="product.product_product_2" model="product.product">
<field name="name">Support Contract (on timesheet)</field>
<field name="track_service">timesheet</field>
</record>

<record id="line_services" model="sale.order.line">
<field name="order_id" ref="sale.sale_order_3"/>
<field name="name">Advance</field>
<field name="product_id" ref="sale.advance_product_0"/>
<field name="product_uom" ref="product.product_uom_day"/>
<field name="price_unit">150.0</field>
<field name="product_uom_qty">5.0</field>
</record>

<record id="project_GAP" model="project.project">
<field name="date_start" eval="time.strftime('%Y-%m-01 10:00:00')"/>
<field name="name">Internal - GAP Analysis</field>
<field name="color">2</field>
<field name="privacy_visibility">employees</field>
<field name="alias_model">project.task</field>
<field name="type_ids" eval="[(4, ref('project.project_stage_0')) ,(4,ref('project.project_stage_1')) ,(4,ref('project.project_stage_2')) ,(4,ref('project.project_stage_3'))]"/>
</record>

<record id="product.product_product_fixed_price" model="product.product">
<field name="track_service">task</field>
<field name="project_id" ref="project_GAP"/>
</record>
</data>
</odoo>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . sale_project_fixed_price
Original file line number Diff line number Diff line change
@@ -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')

0 comments on commit 44b83ea

Please sign in to comment.