|
@ -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])], |
|
|
})], |
|
|
})], |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|