diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 3debf0e4c47..c2df289ec50 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -2278,7 +2278,7 @@ class AccountMoveLine(models.Model): ), ( 'check_accountable_required_fields', - "CHECK(display_type IN ('line_section', 'line_note') OR account_id IS NOT NULL)", + "CHECK(COALESCE(display_type IN ('line_section', 'line_note'), 'f') OR account_id IS NOT NULL)", "Missing required account on accountable invoice line." ), ( diff --git a/addons/account/tests/account_test_no_chart.py b/addons/account/tests/account_test_no_chart.py index ca1c971d0a6..aebee74f64e 100644 --- a/addons/account/tests/account_test_no_chart.py +++ b/addons/account/tests/account_test_no_chart.py @@ -83,12 +83,16 @@ class TestAccountNoChartCommon(SavepointCase): 'code': 'AJ-PURC', 'type': 'purchase', 'company_id': cls.env.user.company_id.id, + 'default_debit_account_id': cls.account_expense.id, + 'default_credit_account_id': cls.account_expense.id, }) cls.journal_sale = cls.env['account.journal'].create({ 'name': 'Sale Journal - Test', 'code': 'AJ-SALE', 'type': 'sale', 'company_id': cls.env.user.company_id.id, + 'default_debit_account_id': cls.account_income.id, + 'default_credit_account_id': cls.account_income.id, }) @classmethod diff --git a/addons/purchase/tests/test_purchase_order_report.py b/addons/purchase/tests/test_purchase_order_report.py index b78a83d9829..5852c76bcd9 100644 --- a/addons/purchase/tests/test_purchase_order_report.py +++ b/addons/purchase/tests/test_purchase_order_report.py @@ -56,7 +56,7 @@ class TestPurchaseOrderReport(common.TransactionCase): }) po.button_confirm() - f = Form(self.env['account.move']) + f = Form(self.env['account.move'].with_context(default_type='in_invoice')) f.partner_id = po.partner_id f.purchase_id = po invoice = f.save() diff --git a/addons/sale/tests/test_reinvoice.py b/addons/sale/tests/test_reinvoice.py index b7640fd23e9..bc6e3457a1c 100644 --- a/addons/sale/tests/test_reinvoice.py +++ b/addons/sale/tests/test_reinvoice.py @@ -216,17 +216,14 @@ class TestReInvoice(TestCommonSaleNoChart): self.sale_order.action_confirm() # create invoice lines and validate it - invoice_a = self.AccountMove.create({ - 'partner_id': self.partner_customer_usd.id, - 'journal_id': self.journal_purchase.id, - 'line_ids': [ - (0, 0, { - 'product_id': self.product_no_expense.id, - 'quantity': 3, - 'analytic_account_id': self.analytic_account.id, - }), - ], - }) + move_form = Form(self.AccountMove) + move_form.partner_id = self.partner_customer_usd + move_form.journal_id = self.journal_purchase + with move_form.line_ids.new() as line_form: + line_form.product_id = self.product_no_expense + line_form.quantity = 3.0 + line_form.analytic_account_id = self.analytic_account + invoice_a = move_form.save() invoice_a.post() self.assertEquals(len(self.sale_order.order_line), 1, "No SO line should have been created (or removed) when validating vendor bill") diff --git a/addons/sale/tests/test_sale_order.py b/addons/sale/tests/test_sale_order.py index f694400d220..7e98806470c 100644 --- a/addons/sale/tests/test_sale_order.py +++ b/addons/sale/tests/test_sale_order.py @@ -184,7 +184,6 @@ class TestSaleOrder(TestCommonSaleNoChart): so._create_analytic_account() inv = self.env['account.move'].with_context(default_type='in_invoice').create({ - 'type': 'in_invoice', 'partner_id': self.partner_customer_usd.id, 'invoice_line_ids': [ (0, 0, {