summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons/account/data/data_account_type.xml6
-rw-r--r--addons/account/models/account.py18
-rw-r--r--addons/account/models/account_move.py11
-rw-r--r--addons/account/views/account_view.xml7
-rw-r--r--addons/l10n_ch/data/l10n_ch_chart_data.xml2
5 files changed, 37 insertions, 7 deletions
diff --git a/addons/account/data/data_account_type.xml b/addons/account/data/data_account_type.xml
index 05f4a76bf36..ca4676f05f0 100644
--- a/addons/account/data/data_account_type.xml
+++ b/addons/account/data/data_account_type.xml
@@ -96,6 +96,10 @@
<field name="type">other</field>
<field name="internal_group">expense</field>
</record>
+ <record model="account.account.type" id="data_account_off_sheet">
+ <field name="name">Off-Balance Sheet</field>
+ <field name="type">other</field>
+ <field name="internal_group">off_balance</field>
+ </record>
</data>
</odoo>
-
diff --git a/addons/account/models/account.py b/addons/account/models/account.py
index 8968ce5a40a..92a94fab82c 100644
--- a/addons/account/models/account.py
+++ b/addons/account/models/account.py
@@ -39,6 +39,7 @@ class AccountAccountType(models.Model):
('liability', 'Liability'),
('income', 'Income'),
('expense', 'Expense'),
+ ('off_balance', 'Off Balance'),
], string="Internal Group",
help="The 'Internal Group' is used to filter accounts based on the internal group set on the account type.")
note = fields.Text(string='Description')
@@ -231,6 +232,15 @@ class AccountAccount(models.Model):
('code_company_uniq', 'unique (code,company_id)', 'The code of the account must be unique per company !')
]
+ @api.constrains('reconcile', 'internal_group', 'tax_ids')
+ def _constrains_reconcile(self):
+ for record in self:
+ if record.internal_group == 'off_balance':
+ if record.reconcile:
+ raise UserError(_('An Off-Balance account can not be reconcilable'))
+ if record.tax_ids:
+ raise UserError(_('An Off-Balance account can not have taxes'))
+
@api.model
def _search_new_account_code(self, company, digits, prefix):
for num in range(1, 10000):
@@ -330,12 +340,16 @@ class AccountAccount(models.Model):
account_ids = self._search(expression.AND([domain, args]), limit=limit, access_rights_uid=name_get_uid)
return self.browse(account_ids).name_get()
- @api.onchange('internal_type')
- def onchange_internal_type(self):
+ @api.onchange('user_type_id')
+ def _onchange_user_type_id(self):
self.reconcile = self.internal_type in ('receivable', 'payable')
if self.internal_type == 'liquidity':
self.reconcile = False
+ if self.internal_group == 'off_balance':
+ self.reconcile = False
+ self.tax_ids = False
+
@api.onchange('code')
def onchange_code(self):
AccountGroup = self.env['account.group']
diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py
index 647043e8d81..9fb8b0a5cd4 100644
--- a/addons/account/models/account_move.py
+++ b/addons/account/models/account_move.py
@@ -2727,6 +2727,17 @@ class AccountMoveLine(models.Model):
if control_type_failed or control_account_failed:
raise UserError(_('You cannot use this general account in this journal, check the tab \'Entry Controls\' on the related journal.'))
+ @api.constrains('account_id', 'tax_ids', 'tax_line_id', 'reconciled')
+ def _check_off_balance(self):
+ for line in self:
+ if line.account_id.internal_group == 'off_balance':
+ if any(a.internal_group != line.account_id.internal_group for a in line.move_id.line_ids.account_id):
+ raise UserError(_('If you want to use "Off-Balance Sheet" accounts, all the accounts of the journal entry must be of this type'))
+ if line.tax_ids or line.tax_line_id:
+ raise UserError(_('You cannot use taxes on lines with an Off-Balance account'))
+ if line.reconciled:
+ raise UserError(_('Lines from "Off-Balance Sheet" accounts cannot be reconciled'))
+
@api.constrains('tax_ids', 'tax_line_id')
def _check_tax_lock_date1(self):
for line in self:
diff --git a/addons/account/views/account_view.xml b/addons/account/views/account_view.xml
index 767d6779c79..0fec57c4c87 100644
--- a/addons/account/views/account_view.xml
+++ b/addons/account/views/account_view.xml
@@ -16,14 +16,15 @@
<field name="code" placeholder="code"/>
<field name="name"/>
<field name="user_type_id" widget="selection"/>
- <field name="tax_ids" widget="many2many_tags" domain="[('company_id','=',company_id)]"/>
+ <field name="tax_ids" widget="many2many_tags" domain="[('company_id','=',company_id)]" attrs="{'invisible': [('internal_group', '=', 'off_balance')]}"/>
<field name="tag_ids" widget="many2many_tags" domain="[('applicability', '!=', 'taxes')]" context="{'default_applicability': 'accounts'}" options="{'no_create_edit': True}"/>
<field name="group_id"/>
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
<field name="currency_id" options="{'no_create': True}" groups="base.group_multi_currency"/>
<field name="internal_type" invisible="1" readonly="1"/>
- <label for="reconcile" attrs="{'invisible': [('internal_type','=','liquidity')]}"/>
- <div attrs="{'invisible': [('internal_type','=','liquidity')]}">
+ <field name="internal_group" invisible="1" readonly="1"/>
+ <label for="reconcile" attrs="{'invisible': ['|', ('internal_type','=','liquidity'), ('internal_group', '=', 'off_balance')]}"/>
+ <div attrs="{'invisible': ['|', ('internal_type','=','liquidity'), ('internal_group', '=', 'off_balance')]}">
<field name="reconcile"/>
<button name="action_open_reconcile" class="oe_link" type="object" string=" -> Reconcile" attrs="{'invisible': [('reconcile', '=', False)]}"/>
</div>
diff --git a/addons/l10n_ch/data/l10n_ch_chart_data.xml b/addons/l10n_ch/data/l10n_ch_chart_data.xml
index b854e222a11..484af4b7ee2 100644
--- a/addons/l10n_ch/data/l10n_ch_chart_data.xml
+++ b/addons/l10n_ch/data/l10n_ch_chart_data.xml
@@ -5,7 +5,7 @@
<data noupdate="1">
<!-- Account Tags -->
<record id="l10nch_chart_template" model="account.chart.template">
- <field name="name">Plan comptable 2015</field>
+ <field name="name">Plan comptable 2015 (Suisse)</field>
<field name="code_digits">4</field>
<field name="bank_account_code_prefix">102</field>
<field name="cash_account_code_prefix">100</field>