Browse Source

[FIX] Use AccountingTestCase for tests

pull/442/head
Joao Alfredo Gama Batista 8 years ago
committed by Agathe Mollé
parent
commit
d5a79af9f2
  1. 49
      partner_financial_risk/tests/test_partner_financial_risk.py
  2. 31
      partner_sale_risk/tests/test_partner_sale_risk.py

49
partner_financial_risk/tests/test_partner_financial_risk.py

@ -2,66 +2,65 @@
# © 2016 Carlos Dauden <carlos.dauden@tecnativa.com> # © 2016 Carlos Dauden <carlos.dauden@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.tests.common import SavepointCase
from odoo.addons.account.tests.account_test_classes import AccountingTestCase
from odoo import fields from odoo import fields
class TestPartnerFinancialRisk(SavepointCase):
@classmethod
def setUpClass(cls):
super(TestPartnerFinancialRisk, cls).setUpClass()
cls.env.user.groups_id |= cls.env.ref('sales_team.group_sale_manager')
cls.partner = cls.env['res.partner'].create({
class TestPartnerFinancialRisk(AccountingTestCase):
def setUp(self):
super(TestPartnerFinancialRisk, self).setUp()
self.env.user.groups_id |= self.env.ref('sales_team.group_sale_manager')
self.partner = self.env['res.partner'].create({
'name': 'Partner test', 'name': 'Partner test',
'customer': True, 'customer': True,
}) })
cls.invoice_address = cls.env['res.partner'].create({
self.invoice_address = self.env['res.partner'].create({
'name': 'Partner test invoice', 'name': 'Partner test invoice',
'parent_id': cls.partner.id,
'parent_id': self.partner.id,
'type': 'invoice', 'type': 'invoice',
}) })
type_revenue = cls.env.ref('account.data_account_type_revenue')
type_payable = cls.env.ref('account.data_account_type_payable')
tax_group_taxes = cls.env.ref('account.tax_group_taxes')
cls.account_sale = cls.env['account.account'].create({
type_revenue = self.env.ref('account.data_account_type_revenue')
type_payable = self.env.ref('account.data_account_type_payable')
tax_group_taxes = self.env.ref('account.tax_group_taxes')
self.account_sale = self.env['account.account'].create({
'name': 'Sale', 'name': 'Sale',
'code': 'XX_700', 'code': 'XX_700',
'user_type_id': type_revenue.id, 'user_type_id': type_revenue.id,
'reconcile': True, 'reconcile': True,
}) })
cls.account_customer = cls.env['account.account'].create({
self.account_customer = self.env['account.account'].create({
'name': 'Customer', 'name': 'Customer',
'code': 'XX_430', 'code': 'XX_430',
'user_type_id': type_payable.id, 'user_type_id': type_payable.id,
'reconcile': True, 'reconcile': True,
}) })
cls.partner.property_account_payable_id = cls.account_customer.id
cls.journal_sale = cls.env['account.journal'].create({
self.journal_sale = self.env['account.journal'].create({
'name': 'Test journal for sale', 'name': 'Test journal for sale',
'type': 'sale', 'type': 'sale',
'code': 'TSALE', 'code': 'TSALE',
'default_debit_account_id': cls.account_sale.id,
'default_credit_account_id': cls.account_sale.id,
'default_debit_account_id': self.account_sale.id,
'default_credit_account_id': self.account_sale.id,
}) })
cls.tax = cls.env['account.tax'].create({
self.tax = self.env['account.tax'].create({
'name': 'Tax for sale 10%', 'name': 'Tax for sale 10%',
'type_tax_use': 'sale', 'type_tax_use': 'sale',
'tax_group_id': tax_group_taxes.id, 'tax_group_id': tax_group_taxes.id,
'amount_type': 'percent', 'amount_type': 'percent',
'amount': 10.0, 'amount': 10.0,
}) })
cls.invoice = cls.env['account.invoice'].create({
'partner_id': cls.partner.id,
'account_id': cls.account_customer.id,
self.invoice = self.env['account.invoice'].create({
'partner_id': self.partner.id,
'account_id': self.partner.property_account_payable_id.id,
'type': 'out_invoice', 'type': 'out_invoice',
'journal_id': cls.journal_sale.id,
'journal_id': self.journal_sale.id,
'payment_term_id': False, 'payment_term_id': False,
'invoice_line_ids': [(0, 0, { 'invoice_line_ids': [(0, 0, {
'name': 'Test product', 'name': 'Test product',
'account_id': cls.account_sale.id,
'account_id': self.account_sale.id,
'price_unit': 50, 'price_unit': 50,
'quantity': 10, 'quantity': 10,
'invoice_line_tax_ids': [(6, 0, [cls.tax.id])],
'invoice_line_tax_ids': [(6, 0, [self.tax.id])],
})], })],
}) })

31
partner_sale_risk/tests/test_partner_sale_risk.py

@ -2,31 +2,30 @@
# © 2016 Carlos Dauden <carlos.dauden@tecnativa.com> # © 2016 Carlos Dauden <carlos.dauden@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.tests.common import SavepointCase
from odoo.addons.account.tests.account_test_classes import AccountingTestCase
class TestPartnerSaleRisk(SavepointCase):
@classmethod
def setUpClass(cls):
super(TestPartnerSaleRisk, cls).setUpClass()
cls.env.user.groups_id |= cls.env.ref('sales_team.group_sale_manager')
cls.partner = cls.env['res.partner'].create({
class TestPartnerSaleRisk(AccountingTestCase):
def setUp(self):
super(TestPartnerSaleRisk, self).setUp()
self.env.user.groups_id |= self.env.ref('sales_team.group_sale_manager')
self.partner = self.env['res.partner'].create({
'name': 'Partner test', 'name': 'Partner test',
'customer': True, 'customer': True,
}) })
cls.product = cls.env.ref('product.product_product_2')
cls.product.invoice_policy = 'order'
cls.sale_order = cls.env['sale.order'].create({
'partner_id': cls.partner.id,
'pricelist_id': cls.env.ref('product.list0').id,
self.product = self.env.ref('product.product_product_2')
self.product.invoice_policy = 'order'
self.sale_order = self.env['sale.order'].create({
'partner_id': self.partner.id,
'pricelist_id': self.env.ref('product.list0').id,
'order_line': [(0, 0, { 'order_line': [(0, 0, {
'name': cls.product.name,
'product_id': cls.product.id,
'name': self.product.name,
'product_id': self.product.id,
'product_uom_qty': 1, 'product_uom_qty': 1,
'product_uom': cls.product.uom_id.id,
'product_uom': self.product.uom_id.id,
'price_unit': 100.0})], 'price_unit': 100.0})],
}) })
cls.env.user.lang = 'en_US'
self.env.user.lang = 'en_US'
def test_sale_order(self): def test_sale_order(self):
self.sale_order.action_confirm() self.sale_order.action_confirm()

Loading…
Cancel
Save