[FIX] account: add constraint to ensure that receivable and payable account are reconciliable + fix l10n_be CoA

This commit is contained in:
Cedric Snauwaert
2015-05-22 10:52:33 +02:00
committed by Cédric Snauwaert
parent 320ef8c16f
commit d55a796dbb
5 changed files with 24 additions and 6 deletions
+12
View File
@@ -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):
+6
View File
@@ -334,18 +334,21 @@
<field name="code">404</field>
<field name="user_type" ref="account.data_account_type_receivable"/>
<field name="chart_template_id" ref="l10nbe_chart_template"/>
<field eval="True" name="reconcile"/>
</record>
<record id="a406" model="account.account.template">
<field name="name">Acomptes versés</field>
<field name="code">406</field>
<field name="user_type" ref="account.data_account_type_receivable"/>
<field name="chart_template_id" ref="l10nbe_chart_template"/>
<field eval="True" name="reconcile"/>
</record>
<record id="a407" model="account.account.template">
<field name="name">Créances douteuses</field>
<field name="code">407</field>
<field name="user_type" ref="account.data_account_type_receivable"/>
<field name="chart_template_id" ref="l10nbe_chart_template"/>
<field eval="True" name="reconcile"/>
</record>
<record id="a411059" model="account.account.template">
<field name="name">T.V.A Déductible</field>
@@ -510,18 +513,21 @@
<field name="code">444</field>
<field name="user_type" ref="account.data_account_type_payable"/>
<field name="chart_template_id" ref="l10nbe_chart_template"/>
<field eval="True" name="reconcile"/>
</record>
<record id="a446" model="account.account.template">
<field name="name">Acomptes reçus</field>
<field name="code">446</field>
<field name="user_type" ref="account.data_account_type_payable"/>
<field name="chart_template_id" ref="l10nbe_chart_template"/>
<field eval="True" name="reconcile"/>
</record>
<record id="a448" model="account.account.template">
<field name="name">Compensations fournisseurs</field>
<field name="code">448</field>
<field name="user_type" ref="account.data_account_type_payable"/>
<field name="chart_template_id" ref="l10nbe_chart_template"/>
<field eval="True" name="reconcile"/>
</record>
<record id="a4500" model="account.account.template">
<field name="name">Dettes fiscales estimées</field>
@@ -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})
+2 -2
View File
@@ -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
@@ -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})