diff --git a/addons/account/account.py b/addons/account/account.py index a0afbea6c08..6d6abd9226d 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -87,6 +87,13 @@ class AccountAccount(models.Model): # if res[account.id]: # account.has_unreconciled_entries = True + @api.multi + @api.constrains('internal_type', 'reconcile') + def _check_reconcile(self): + for account in self: + if account.internal_type in ('receivable', 'payable') and account.reconcile == False: + raise ValueError(_('You cannot have a receivable/payable account that is not reconciliable. (account code: %s)') % account.code) + name = fields.Char(required=True, index=True) currency_id = fields.Many2one('res.currency', string='Secondary Currency', help="Forces all moves for this account to have this secondary currency.") @@ -124,6 +131,11 @@ class AccountAccount(models.Model): accounts = self.search(domain + args, limit=limit) return accounts.name_get() + @api.onchange('internal_type') + def onchange_internal_type(self): + if self.internal_type in ('receivable', 'payable'): + self.reconcile = True + @api.multi @api.depends('name', 'code') def name_get(self): diff --git a/addons/l10n_be/account_pcmn_belgium.xml b/addons/l10n_be/account_pcmn_belgium.xml index f5306fd0901..5c87952a488 100644 --- a/addons/l10n_be/account_pcmn_belgium.xml +++ b/addons/l10n_be/account_pcmn_belgium.xml @@ -334,18 +334,21 @@ 404 + Acomptes versés 406 + Créances douteuses 407 + T.V.A Déductible @@ -510,18 +513,21 @@ 444 + Acomptes reçus 446 + Compensations fournisseurs 448 + Dettes fiscales estimées diff --git a/addons/purchase/tests/test_purchase_to_invoice.py b/addons/purchase/tests/test_purchase_to_invoice.py index 9ead5b2c1c1..5c870b92133 100644 --- a/addons/purchase/tests/test_purchase_to_invoice.py +++ b/addons/purchase/tests/test_purchase_to_invoice.py @@ -14,9 +14,9 @@ class TestPurchase(common.TransactionCase): # Useful accounts user_type_id = self.ref('account.data_account_type_expenses') - account_exp_id = self.env['account.account'].create({'code': 'X2020', 'name': 'Purchase - Test Expense Account', 'user_type': user_type_id}) + account_exp_id = self.env['account.account'].create({'code': 'X2020', 'name': 'Purchase - Test Expense Account', 'user_type': user_type_id, 'reconcile': True}) user_type_id = self.ref('account.data_account_type_payable') - account_pay_id = self.env['account.account'].create({'code': 'X1012', 'name': 'Purchase - Test Payable Account', 'user_type': user_type_id}) + account_pay_id = self.env['account.account'].create({'code': 'X1012', 'name': 'Purchase - Test Payable Account', 'user_type': user_type_id, 'reconcile': True}) self.env['product.product'].browse(product_id).product_tmpl_id.write({'property_account_expense': account_exp_id}) diff --git a/addons/sale/tests/test_sale_to_invoice.py b/addons/sale/tests/test_sale_to_invoice.py index 315fb0938ad..17a4f17e949 100644 --- a/addons/sale/tests/test_sale_to_invoice.py +++ b/addons/sale/tests/test_sale_to_invoice.py @@ -47,9 +47,9 @@ class TestSale(TestMail): # Usefull accounts user_type_id = IrModelData.xmlid_to_res_id('account.data_account_type_revenue') - account_rev_id = account_obj.create({'code': 'X2020', 'name': 'Sales - Test Sales Account', 'user_type': user_type_id}) + account_rev_id = account_obj.create({'code': 'X2020', 'name': 'Sales - Test Sales Account', 'user_type': user_type_id, 'reconcile': True}) user_type_id = IrModelData.xmlid_to_res_id('account.data_account_type_receivable') - account_recv_id = account_obj.create({'code': 'X1012', 'name': 'Sales - Test Reicv Account', 'user_type': user_type_id}) + account_recv_id = account_obj.create({'code': 'X1012', 'name': 'Sales - Test Reicv Account', 'user_type': user_type_id, 'reconcile': True}) # Add account to product product_template_id = self.env.ref('sale.advance_product_0').product_tmpl_id diff --git a/addons/stock_dropshipping/tests/test_invoicing.py b/addons/stock_dropshipping/tests/test_invoicing.py index 871d0d9e4b1..dae746056c8 100644 --- a/addons/stock_dropshipping/tests/test_invoicing.py +++ b/addons/stock_dropshipping/tests/test_invoicing.py @@ -31,9 +31,9 @@ class TestCreateInvoice(TransactionCase): self.env['account.journal'].create({'name': 'Purchase Journal - Test', 'code': 'DSTPJ', 'type': 'purchase', 'company_id': self.env.ref('base.main_company').id}) user_type_id = self.env.ref('account.data_account_type_payable') - account_pay_id = self.env['account.account'].create({'code': 'X1012', 'name': 'Purchase - Test Payable Account', 'user_type': user_type_id.id}) + account_pay_id = self.env['account.account'].create({'code': 'X1012', 'name': 'Purchase - Test Payable Account', 'user_type': user_type_id.id, 'reconcile': True}) user_type_id = self.env.ref('account.data_account_type_expenses') - account_exp_id = self.env['account.account'].create({'code': 'X1013', 'name': 'Purchase - Test Expense Account', 'user_type': user_type_id.id}) + account_exp_id = self.env['account.account'].create({'code': 'X1013', 'name': 'Purchase - Test Expense Account', 'user_type': user_type_id.id, 'reconcile': True}) self.customer.write({'property_account_payable': account_pay_id.id})