mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[10.0][FIX] tests not working
[FIX] test [IMP] test [FIX] pep8
This commit is contained in:
@@ -1,32 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# © 2016 Carlos Dauden <carlos.dauden@tecnativa.com>
|
|
||||||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
|
||||||
|
|
||||||
from odoo.tests.common import TransactionCase
|
|
||||||
|
|
||||||
|
|
||||||
class TestContractShowInvoice(TransactionCase):
|
|
||||||
def setUp(self):
|
|
||||||
super(TestContractShowInvoice, self).setUp()
|
|
||||||
self.analytic_account = self.env['account.analytic.account'].create({
|
|
||||||
'name': 'Test contract show invoice',
|
|
||||||
})
|
|
||||||
self.invoice = self.env['account.invoice'].create(
|
|
||||||
{'partner_id': self.env.ref('base.res_partner_2').id,
|
|
||||||
'type': 'out_invoice',
|
|
||||||
})
|
|
||||||
self.invoice._onchange_partner_id()
|
|
||||||
self.invoice_line = self.env['account.invoice.line'].create(
|
|
||||||
{'product_id': self.env.ref('product.product_product_2').id,
|
|
||||||
'quantity': 1.0,
|
|
||||||
'invoice_id': self.invoice.id,
|
|
||||||
'account_analytic_id': self.analytic_account.id,
|
|
||||||
})
|
|
||||||
self.invoice_line._onchange_product_id()
|
|
||||||
|
|
||||||
def test_contract_show_invoice(self):
|
|
||||||
self.assertEqual(len(self.analytic_account.analytic_account_ids), 1)
|
|
||||||
|
|
||||||
def test_contract_total_invoiced(self):
|
|
||||||
self.assertEqual(self.invoice.amount_total,
|
|
||||||
self.analytic_account.total_invoiced)
|
|
||||||
68
contract_show_invoice/tests/test_contract_show_invoice.py
Normal file
68
contract_show_invoice/tests/test_contract_show_invoice.py
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# © 2016 Carlos Dauden <carlos.dauden@tecnativa.com>
|
||||||
|
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
||||||
|
|
||||||
|
from odoo.tests.common import TransactionCase
|
||||||
|
|
||||||
|
|
||||||
|
class TestContractShowInvoice(TransactionCase):
|
||||||
|
def setUp(self):
|
||||||
|
super(TestContractShowInvoice, self).setUp()
|
||||||
|
self.analytic_account = self.env['account.analytic.account'].create({
|
||||||
|
'name': 'Test contract show invoice',
|
||||||
|
})
|
||||||
|
self.invoice = self.env['account.invoice'].create(
|
||||||
|
{'partner_id': self.env.ref('base.res_partner_2').id,
|
||||||
|
'type': 'out_invoice',
|
||||||
|
})
|
||||||
|
self.invoice.journal_id.update_posted = True
|
||||||
|
self.invoice._onchange_partner_id()
|
||||||
|
self.a_sale = self.env['account.account'].search([
|
||||||
|
('user_type_id', '=',
|
||||||
|
self.env.ref('account.data_account_type_revenue').id)
|
||||||
|
], limit=1)
|
||||||
|
self.invoice_line = self.env['account.invoice.line'].create(
|
||||||
|
{'product_id': self.env.ref('product.product_product_2').id,
|
||||||
|
'quantity': 1.0,
|
||||||
|
'invoice_id': self.invoice.id,
|
||||||
|
'account_analytic_id': self.analytic_account.id,
|
||||||
|
'account_id': self.a_sale.id,
|
||||||
|
'price_unit': 50.0,
|
||||||
|
'name': 'Invoice line with analytic account',
|
||||||
|
'invoice_line_tax_ids': [(4, self.env['account.tax'].search(
|
||||||
|
[('type_tax_use', '=', 'sale')], limit=1).id, 0)]
|
||||||
|
})
|
||||||
|
self.invoice.compute_taxes()
|
||||||
|
self.invoice.action_invoice_open()
|
||||||
|
|
||||||
|
def test_invoice_two_line(self):
|
||||||
|
self.assertEqual(
|
||||||
|
self.analytic_account.total_invoiced,
|
||||||
|
self.invoice_line.price_subtotal,
|
||||||
|
msg="Amount invoiced is different from single invoice line wich "
|
||||||
|
"has analytic account")
|
||||||
|
self.invoice.action_invoice_cancel()
|
||||||
|
self.invoice.action_invoice_draft()
|
||||||
|
self.invoice_line1 = self.env['account.invoice.line'].create(
|
||||||
|
{'product_id': self.env.ref('product.product_product_2').id,
|
||||||
|
'quantity': 2.0,
|
||||||
|
'invoice_id': self.invoice.id,
|
||||||
|
'account_analytic_id': False,
|
||||||
|
'account_id': self.a_sale.id,
|
||||||
|
'price_unit': 100.0,
|
||||||
|
'name': 'Invoice line without analytic account',
|
||||||
|
'invoice_line_tax_ids': [(4, self.env['account.tax'].search(
|
||||||
|
[('type_tax_use', '=', 'sale')], limit=1).id, 0)]
|
||||||
|
})
|
||||||
|
self.invoice.compute_taxes()
|
||||||
|
self.invoice.action_invoice_open()
|
||||||
|
self.assertFalse(self.invoice_line1.account_analytic_id,
|
||||||
|
msg="Invoice line has analytic account")
|
||||||
|
self.assertEqual(len(self.invoice.analytic_account_ids), 1,
|
||||||
|
msg="Invoice lines with analytic account are more "
|
||||||
|
"than one")
|
||||||
|
self.assertEqual(
|
||||||
|
self.analytic_account.total_invoiced,
|
||||||
|
self.invoice_line.price_subtotal,
|
||||||
|
msg="Amount invoiced is different from invoice lines wich "
|
||||||
|
"has analytic account")
|
||||||
Reference in New Issue
Block a user