Files
account-financial-tools/account_credit_control/tests/test_res_partner.py
Sylvain Van Hoof 0ecb0c835c [MIG] Add some unit tests on the module account_credit_control
(cherry picked from commit 7fa1b0ac883914f3cdfcaaa1a00016a35cced368)

[IMP] Add some unitest and fix a bug with exceptions

(cherry picked from commit c2f34ecd06fa5ba093084cf32f35c722c5866ff5)

[FIX] Reindent line

(cherry picked from commit b643a48f86b20ed6496f2e08366a407095d1540b)

[IMP] Add some new unittests

(cherry picked from commit f118e2391de3b443558d26186fe44f55a7f0b9c4)

[IMP] Add encoding in each python files

(cherry picked from commit 9599a88303b921c8e73174db61318f6dc9f02017)
2017-06-09 11:28:10 +02:00

38 lines
1.3 KiB
Python

# -*- coding: utf-8 -*-
# Copyright 2017 Okia SPRL (https://okia.be)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.tests.common import TransactionCase
from odoo.exceptions import ValidationError
class TestCreditControlPolicyLevel(TransactionCase):
post_install = True
at_install = False
def test_check_credit_policy(self):
"""
Test the constrains on res.partner
First we try to assign an account and a policy with a wrong policy
(this policy doesn't contains the account of the partner).
After that we add the previous account in the policy and
retry to assign this policy and this account on the partner
:return:
"""
policy = self.env.ref('account_credit_control.credit_control_3_time')
partner = self.env['res.partner'].create({
'name': 'Partner 1',
})
account = partner.property_account_receivable_id
with self.assertRaises(ValidationError):
partner.write({
'credit_policy_id': policy.id,
})
policy.write({
'account_ids': [(6, 0, [account.id])]
})
partner.property_account_receivable_id = account.id
partner.credit_policy_id = policy.id