[IMP] account_exception: make it work on write and specific states

H11044
This commit is contained in:
Jorge Che
2022-09-30 15:38:53 +00:00
parent 8a09a73afa
commit 78fa2aec94
7 changed files with 58 additions and 13 deletions

View File

@@ -0,0 +1 @@
from . import test_account_move_exception

View File

@@ -0,0 +1,24 @@
# from odoo.tests import common
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
from odoo.tests import tagged
@tagged('post_install', '-at_install')
class TestAccountMoveException(AccountTestInvoicingCommon):
def test_10_validation_on_write(self):
self.env.user.groups_id += self.env.ref('analytic.group_analytic_accounting')
exception = self.env.ref('account_exception.excep_no_phone').sudo()
exception.active = True
invoice = self.init_invoice('out_invoice', products=self.product_a)
# must be exceptions when no phone and posting
invoice.partner_id.phone = False
invoice.action_post()
self.assertTrue(invoice.exception_ids)
# no exceptions when phone and posting
invoice.partner_id.phone = '123'
invoice.action_post()
self.assertTrue(invoice.exception_ids)
self.assertTrue(invoice.state='posted')