Files
account-financial-tools/account_group/models/account_account.py
Pedro M. Baeza 9015eb9736 [ADD] account_group: Groups for accounts
Installation
============

If you have already the chart of accounts loaded on your company, you will
need to update it through the module `account_chart_update`. Follow the
instructions on that module for that.

Configuration
=============

To configure account groups, you need to:

* Be "Account / Adviser" role.
* Go to *Invoicing > Configuration > Accounts Groups*.
* Create or modify existing groups.

For assigning groups to account templates, you have to:

* Set the group on your account chart module or extension.
* Or develop/create UI access.

When you have groups on your account templates, you can load a chart template
for a new company, and they will be transferred to created accounts.

Usage
=====

For assigning groups to accounts:

* Go to *Invoicing > Adviser > Chart of Accounts*.
* Edit one account and set "Group" field.
2018-09-22 12:10:22 +02:00

31 lines
862 B
Python

# coding: utf-8
# Copyright 2018 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class AccountAccount(models.Model):
_inherit = "account.account"
group_id = fields.Many2one(
comodel_name='account.group',
string="Group",
)
@api.onchange('code')
def onchange_code(self):
AccountGroup = self.env['account.group']
group = False
code_prefix = self.code
# find group with longest matching prefix
while code_prefix:
matching_group = AccountGroup.search([
('code_prefix', '=', code_prefix),
], limit=1)
if matching_group:
group = matching_group
break
code_prefix = code_prefix[:-1]
self.group_id = group