| 1 |
# -*- coding: utf-8 -*- |
| 2 |
# Part of Odoo. See LICENSE file for full copyright and licensing details. |
| 3 |
|
| 4 |
from odoo.addons.sale.tests.common import TestSaleCommon |
| 5 |
from odoo import Command |
| 6 |
|
| 7 |
class TestCommonSalePurchaseNoChart(TestSaleCommon): |
| 8 |
|
| 9 |
@classmethod |
| 10 |
def setUpClass(cls): |
| 11 |
super().setUpClass() |
| 12 |
|
| 13 |
uom_unit = cls.env.ref('uom.product_uom_unit') |
| 14 |
uom_dozen = cls.env.ref('uom.product_uom_dozen') |
| 15 |
|
| 16 |
# Create category |
| 17 |
cls.product_category_purchase = cls.env['product.category'].create({ |
| 18 |
'name': 'Product Category with Income account', |
| 19 |
'property_account_income_categ_id': cls.company_data['default_account_expense'].id |
| 20 |
}) |
| 21 |
|
| 22 |
cls.partner_vendor_service = cls.env['res.partner'].create({ |
| 23 |
'name': 'Super Service Supplier', |
| 24 |
'email': '[email protected]', |
| 25 |
}) |
| 26 |
|
| 27 |
# Create product |
| 28 |
# When service_to_purchase is True add the supplier i.e 'seller_ids' on the product to void the Validation error at product creation time |
| 29 |
cls.service_purchase_1 = cls.env['product.product'].create({ |
| 30 |
'name': "Out-sourced Service 1", |
| 31 |
'standard_price': 200.0, |
| 32 |
'list_price': 180.0, |
| 33 |
'type': 'service', |
| 34 |
'uom_id': uom_unit.id, |
| 35 |
'invoice_policy': 'delivery', |
| 36 |
'expense_policy': 'no', |
| 37 |
'default_code': 'SERV_DEL', |
| 38 |
'service_type': 'manual', |
| 39 |
'taxes_id': False, |
| 40 |
'categ_id': cls.product_category_purchase.id, |
| 41 |
'service_to_purchase': True, |
| 42 |
'seller_ids': [Command.create({ |
| 43 |
'product_uom_id': uom_unit.id, |
| 44 |
'partner_id': cls.partner_vendor_service.id, |
| 45 |
'price': 100, |
| 46 |
'delay': 1, |
| 47 |
'discount': 30, |
| 48 |
})], |
| 49 |
}) |
| 50 |
cls.service_purchase_2 = cls.env['product.product'].create({ |
| 51 |
'name': "Out-sourced Service 2", |
| 52 |
'standard_price': 20.0, |
| 53 |
'list_price': 15.0, |
| 54 |
'type': 'service', |
| 55 |
'uom_id': uom_dozen.id, # different UoM |
| 56 |
'invoice_policy': 'order', |
| 57 |
'expense_policy': 'no', |
| 58 |
'default_code': 'SERV_ORD', |
| 59 |
'service_type': 'manual', |
| 60 |
'taxes_id': False, |
| 61 |
'categ_id': cls.product_category_purchase.id, |
| 62 |
'service_to_purchase': True, |
| 63 |
'seller_ids': [Command.create({ |
| 64 |
'product_uom_id': uom_dozen.id, |
| 65 |
'partner_id': cls.partner_vendor_service.id, |
| 66 |
'price': 10, |
| 67 |
'delay': 5, |
| 68 |
})], |
| 69 |
}) |