[IMP] account_reports: add off sheets acount type
Task 1998268 closes odoo/odoo#35150 Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
@@ -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']
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user