diff --git a/CHANGELOG b/CHANGELOG index bddd4d3b59..1b1ae5a8c7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Remove display balance +* Merge account kind and account type * Add origin on move line * Base journal cash report on account kind receivable and payable diff --git a/account.py b/account.py index a1ae35ded5..8fcbeb98b4 100644 --- a/account.py +++ b/account.py @@ -47,33 +47,120 @@ def inactive_records(func): return wrapper +def TypeMixin(template=False): + + class Mixin: + name = fields.Char('Name', required=True) + + statement = fields.Selection([ + (None, ""), + ('balance', "Balance"), + ('income', "Income"), + ('off-balance', "Off-Balance"), + ], "Statement", + states={ + 'required': Bool(Eval('parent')), + }, + depends=['parent']) + assets = fields.Boolean( + "Assets", + states={ + 'invisible': Eval('statement') != 'balance', + }, + depends=['statement']) + + receivable = fields.Boolean( + "Receivable", + domain=[ + If(Eval('statement') != 'balance', + ('receivable', '=', False), ()), + ], + states={ + 'invisible': ((Eval('statement') != 'balance') + | ~Eval('assets', True)), + }, + depends=['statement', 'assets']) + stock = fields.Boolean( + "Stock", + domain=[ + If(Eval('statement') == 'off-balance', + ('stock', '=', False), ()), + ], + states={ + 'invisible': Eval('statement') == 'off-balance', + }, + depends=['statement']) + + payable = fields.Boolean( + "Payable", + domain=[ + If(Eval('statement') != 'balance', + ('payable', '=', False), ()), + ], + states={ + 'invisible': ((Eval('statement') != 'balance') + | Eval('assets', False)), + }, + depends=['statement', 'assets']) + + revenue = fields.Boolean( + "Revenue", + domain=[ + If(Eval('statement') != 'income', + ('revenue', '=', False), ()), + ], + states={ + 'invisible': Eval('statement') != 'income', + }, + depends=['statement']) + + expense = fields.Boolean( + "Expense", + domain=[ + If(Eval('statement') != 'income', + ('expense', '=', False), ()), + ], + states={ + 'invisible': Eval('statement') != 'income', + }, + depends=['statement']) + if not template: + for fname in dir(Mixin): + field = getattr(Mixin, fname) + if not isinstance(field, fields.Field): + continue + field.states['readonly'] = ( + Bool(Eval('template', -1)) & ~Eval('template_override', False)) + return Mixin + + class TypeTemplate( - sequence_ordered(), tree(separator='\\'), ModelSQL, ModelView): + TypeMixin(template=True), sequence_ordered(), tree(separator='\\'), + ModelSQL, ModelView): 'Account Type Template' __name__ = 'account.account.type.template' - name = fields.Char('Name', required=True) - parent = fields.Many2One('account.account.type.template', 'Parent', - ondelete="RESTRICT") - childs = fields.One2Many('account.account.type.template', 'parent', - 'Children') - balance_sheet = fields.Boolean('Balance Sheet') - income_statement = fields.Boolean('Income Statement') - display_balance = fields.Selection([ - ('debit-credit', 'Debit - Credit'), - ('credit-debit', 'Credit - Debit'), - ], 'Display Balance', required=True) + parent = fields.Many2One( + 'account.account.type.template', "Parent", ondelete='RESTRICT', + domain=['OR', + If(Eval('statement') == 'off-balance', + ('statement', '=', 'off-balance'), + If(Eval('statement') == 'balance', + ('statement', '=', 'balance'), + ('statement', '!=', 'off-balance')), + ), + ('statement', '=', None), + ], + depends=['statement']) + childs = fields.One2Many( + 'account.account.type.template', 'parent', "Children") - @staticmethod - def default_balance_sheet(): - return False + @classmethod + def __register__(cls, module_name): + super().__register__(module_name) + table_h = cls.__table_handler__(module_name) - @staticmethod - def default_income_statement(): - return False - - @staticmethod - def default_display_balance(): - return 'debit-credit' + # Migration from 5.0: remove display_balance + table_h.drop_column('display_balance') def _get_type_value(self, type=None): ''' @@ -84,12 +171,14 @@ class TypeTemplate( res['name'] = self.name if not type or type.sequence != self.sequence: res['sequence'] = self.sequence - if not type or type.balance_sheet != self.balance_sheet: - res['balance_sheet'] = self.balance_sheet - if not type or type.income_statement != self.income_statement: - res['income_statement'] = self.income_statement - if not type or type.display_balance != self.display_balance: - res['display_balance'] = self.display_balance + if not type or type.statement != self.statement: + res['statement'] = self.statement + if not type or type.assets != self.assets: + res['assets'] = self.assets + for boolean in [ + 'receivable', 'stock', 'payable', 'revenue', 'expense']: + if not type or getattr(type, boolean) != getattr(self, boolean): + res[boolean] = getattr(self, boolean) if not type or type.template != self: res['template'] = self.id return res @@ -132,26 +221,28 @@ class TypeTemplate( childs = sum((c.childs for c in childs), ()) -class Type(sequence_ordered(), tree(separator='\\'), ModelSQL, ModelView): +class Type( + TypeMixin(), sequence_ordered(), tree(separator='\\'), + ModelSQL, ModelView): 'Account Type' __name__ = 'account.account.type' - _states = { - 'readonly': (Bool(Eval('template', -1)) & - ~Eval('template_override', False)), - } - name = fields.Char('Name', size=None, required=True, states=_states) parent = fields.Many2One('account.account.type', 'Parent', - ondelete="RESTRICT", states=_states, + ondelete="RESTRICT", + states={ + 'readonly': (Bool(Eval('template', -1)) & + ~Eval('template_override', False)), + }, domain=[ ('company', '=', Eval('company')), ], - depends=['company']) + depends=['company', 'statement']) childs = fields.One2Many('account.account.type', 'parent', 'Children', domain=[ ('company', '=', Eval('company')), ], depends=['company']) + currency_digits = fields.Function(fields.Integer('Currency Digits'), 'get_currency_digits') amount = fields.Function(fields.Numeric('Amount', @@ -160,12 +251,7 @@ class Type(sequence_ordered(), tree(separator='\\'), ModelSQL, ModelView): amount_cmp = fields.Function(fields.Numeric('Amount', digits=(16, Eval('currency_digits', 2)), depends=['currency_digits']), 'get_amount_cmp') - balance_sheet = fields.Boolean('Balance Sheet', states=_states) - income_statement = fields.Boolean('Income Statement', states=_states) - display_balance = fields.Selection([ - ('debit-credit', 'Debit - Credit'), - ('credit-debit', 'Credit - Debit'), - ], 'Display Balance', required=True, states=_states) + company = fields.Many2One('company.company', 'Company', required=True, ondelete="RESTRICT") template = fields.Many2One('account.account.type.template', 'Template') @@ -175,19 +261,14 @@ class Type(sequence_ordered(), tree(separator='\\'), ModelSQL, ModelView): 'invisible': ~Bool(Eval('template', -1)), }, depends=['template']) - del _states - @staticmethod - def default_balance_sheet(): - return False + @classmethod + def __register__(cls, module_name): + super().__register__(module_name) + table_h = cls.__table_handler__(module_name) - @staticmethod - def default_income_statement(): - return False - - @staticmethod - def default_display_balance(): - return 'debit-credit' + # Migration from 5.0: remove display_balance + table_h.drop_column('display_balance') @classmethod def default_template_override(cls): @@ -221,10 +302,9 @@ class Type(sequence_ordered(), tree(separator='\\'), ModelSQL, ModelView): with Transaction().set_context(periods=period_ids): accounts = Account.search([ ('type', 'in', [t.id for t in childs]), - ('kind', '!=', 'view'), ]) for account in accounts: - type_sum[account.type.id] += (account.debit - account.credit) + type_sum[account.type.id] += (account.credit - account.debit) for type_ in types: childs = cls.search([ @@ -234,7 +314,7 @@ class Type(sequence_ordered(), tree(separator='\\'), ModelSQL, ModelView): res[type_.id] += type_sum[child.id] exp = Decimal(str(10.0 ** -type_.currency_digits)) res[type_.id] = res[type_.id].quantize(exp) - if type_.display_balance == 'credit-debit': + if type_.statement == 'balance' and type_.assets: res[type_.id] = - res[type_.id] return res @@ -331,53 +411,136 @@ class OpenType(Wizard): do_ledger_account = open_action -class AccountTemplate(PeriodMixin, tree(), ModelSQL, ModelView): +def AccountMixin(template=False): + + class Mixin: + name = fields.Char('Name', required=True, select=True) + code = fields.Char('Code', select=True) + + closed = fields.Boolean( + "Closed", + states={ + 'invisible': ~Eval('type'), + }, + depends=['type'], + help="Check to prevent posting move on the account.") + reconcile = fields.Boolean( + "Reconcile", + states={ + 'invisible': ~Eval('type'), + }, + depends=['type'], + help="Allow move lines of this account to be reconciled.") + + party_required = fields.Boolean('Party Required', + domain=[ + If(~Eval('type') | ~Eval('deferral', False), + ('party_required', '=', False), + ()), + ], + states={ + 'invisible': ~Eval('type') | ~Eval('deferral', False), + }, + depends=['type', 'deferral']) + + general_ledger_balance = fields.Boolean('General Ledger Balance', + states={ + 'invisible': ~Eval('type'), + }, + depends=['type'], + help="Display only the balance in the general ledger report") + + deferral = fields.Function(fields.Boolean( + "Deferral", + states={ + 'invisible': ~Eval('type'), + }, + depends=['type']), + 'on_change_with_deferral', searcher='search_deferral') + + @classmethod + def default_closed(cls): + return False + + @classmethod + def default_reconcile(cls): + return False + + @classmethod + def default_party_required(cls): + return False + + @classmethod + def default_general_ledger_balance(cls): + return False + + @fields.depends('type') + def on_change_with_deferral(self, name=None): + return (self.type + and self.type.statement in {'balance', 'off-balance'}) + + @classmethod + def search_deferral(cls, name, clause): + _, operator, value = clause + if operator in {'in', 'not in'}: + if operator == 'in': + operator = '=' + else: + operator = '!=' + if True in value and False not in value: + value = '=', True + elif False in value and True not in value: + value = '=', False + else: + return [('id', operator, None)] + if ((operator == '=' and value) + or (operator == '!=' and not value)): + return [ + ('type.statement', 'in', ['balance', 'off-balance']), + ] + else: + return ['OR', + ('type', '=', None), + ('type.statement', 'not in', ['balance', 'off-balance']), + ] + + def get_rec_name(self, name): + if self.code: + return self.code + ' - ' + self.name + else: + return self.name + + @classmethod + def search_rec_name(cls, name, clause): + if clause[1].startswith('!') or clause[1].startswith('not '): + bool_op = 'AND' + else: + bool_op = 'OR' + return [bool_op, + ('code',) + tuple(clause[1:]), + (cls._rec_name,) + tuple(clause[1:]), + ] + + if not template: + for fname in dir(Mixin): + field = getattr(Mixin, fname) + if (not isinstance(field, fields.Field) + or isinstance(field, fields.Function)): + continue + field.states['readonly'] = ( + Bool(Eval('template', -1)) & ~Eval('template_override', False)) + return Mixin + + +class AccountTemplate( + AccountMixin(template=True), PeriodMixin, tree(), ModelSQL, ModelView): 'Account Template' __name__ = 'account.account.template' - name = fields.Char('Name', size=None, required=True, select=True) - code = fields.Char('Code', size=None, select=True) - type = fields.Many2One('account.account.type.template', 'Type', - ondelete="RESTRICT", - states={ - 'invisible': Eval('kind') == 'view', - 'required': Eval('kind') != 'view', - }, depends=['kind']) + type = fields.Many2One( + 'account.account.type.template', "Type", ondelete="RESTRICT") parent = fields.Many2One('account.account.template', 'Parent', select=True, ondelete="RESTRICT") childs = fields.One2Many('account.account.template', 'parent', 'Children') - reconcile = fields.Boolean('Reconcile', - states={ - 'invisible': Eval('kind') == 'view', - }, depends=['kind']) - kind = fields.Selection([ - ('other', 'Other'), - ('payable', 'Payable'), - ('revenue', 'Revenue'), - ('receivable', 'Receivable'), - ('expense', 'Expense'), - ('stock', 'Stock'), - ('view', 'View'), - ], 'Kind', required=True) - deferral = fields.Boolean('Deferral', states={ - 'invisible': Eval('kind') == 'view', - }, depends=['kind']) - party_required = fields.Boolean('Party Required', - domain=[ - If((Eval('kind') == 'view') | ~Eval('deferral', False), - ('party_required', '=', False), - (), - ) - ], - states={ - 'invisible': (Eval('kind') == 'view') | ~Eval('deferral', False), - }, - depends=['kind', 'deferral']) - general_ledger_balance = fields.Boolean('General Ledger Balance', - states={ - 'invisible': Eval('kind') == 'view', - }, - depends=['kind'], - help="Display only the balance in the general ledger report") taxes = fields.Many2Many('account.account.template-account.tax.template', 'account', 'tax', 'Default Taxes', domain=[('parent', '=', None)]) @@ -393,42 +556,14 @@ class AccountTemplate(PeriodMixin, tree(), ModelSQL, ModelView): cls._order.insert(0, ('code', 'ASC')) cls._order.insert(1, ('name', 'ASC')) - @staticmethod - def default_kind(): - return 'view' - - @staticmethod - def default_reconcile(): - return False - - @staticmethod - def default_deferral(): - return True - - @staticmethod - def default_party_required(): - return False - - @staticmethod - def default_general_ledger_balance(): - return False - - def get_rec_name(self, name): - if self.code: - return self.code + ' - ' + self.name - else: - return self.name - @classmethod - def search_rec_name(cls, name, clause): - if clause[1].startswith('!') or clause[1].startswith('not '): - bool_op = 'AND' - else: - bool_op = 'OR' - return [bool_op, - ('code',) + tuple(clause[1:]), - (cls._rec_name,) + tuple(clause[1:]), - ] + def __register__(cls, module_name): + super().__register__(module_name) + + table_h = cls.__table_handler__(module_name) + + # Migration from 5.0: remove kind + table_h.drop_column('kind') def _get_account_value(self, account=None): ''' @@ -439,16 +574,14 @@ class AccountTemplate(PeriodMixin, tree(), ModelSQL, ModelView): res['name'] = self.name if not account or account.code != self.code: res['code'] = self.code - if not account or account.kind != self.kind: - res['kind'] = self.kind if not account or account.start_date != self.start_date: res['start_date'] = self.start_date if not account or account.end_date != self.end_date: res['end_date'] = self.end_date + if not account or account.closed != self.closed: + res['closed'] = self.closed if not account or account.reconcile != self.reconcile: res['reconcile'] = self.reconcile - if not account or account.deferral != self.deferral: - res['deferral'] = self.deferral if not account or account.party_required != self.party_required: res['party_required'] = self.party_required if (not account @@ -563,15 +696,13 @@ class AccountTemplateTaxTemplate(ModelSQL): ondelete='RESTRICT', select=True, required=True) -class Account(ActivePeriodMixin, tree(), ModelSQL, ModelView): +class Account(AccountMixin(), ActivePeriodMixin, tree(), ModelSQL, ModelView): 'Account' __name__ = 'account.account' _states = { 'readonly': (Bool(Eval('template', -1)) & ~Eval('template_override', False)), } - name = fields.Char('Name', required=True, select=True, states=_states) - code = fields.Char('Code', select=True, states=_states) company = fields.Many2One('company.company', 'Company', required=True, ondelete="RESTRICT") currency = fields.Function(fields.Many2One('currency.currency', @@ -586,22 +717,20 @@ class Account(ActivePeriodMixin, tree(), ModelSQL, ModelView): ], states={ 'reaodnly': _states['readonly'], - 'invisible': (Eval('kind').in_( - ['payable', 'revenue', 'receivable', 'expense']) - | ~Eval('deferral', False)), + 'invisible': ~Eval('deferral', False), }, - depends=['currency', 'kind', 'deferral']) + depends=['currency', 'deferral']) second_currency_digits = fields.Function(fields.Integer( "Second Currency Digits"), 'get_second_currency_digits') - type = fields.Many2One('account.account.type', 'Type', ondelete="RESTRICT", + type = fields.Many2One( + 'account.account.type', "Type", ondelete='RESTRICT', states={ - 'invisible': Eval('kind') == 'view', - 'required': Eval('kind') != 'view', 'readonly': _states['readonly'], }, domain=[ ('company', '=', Eval('company')), - ], depends=['kind', 'company']) + ], + depends=['company']) parent = fields.Many2One( 'account.account', 'Parent', select=True, left="left", right="right", ondelete="RESTRICT", states=_states) @@ -626,48 +755,13 @@ class Account(ActivePeriodMixin, tree(), ModelSQL, ModelView): }, depends=['second_currency_digits', 'second_currency']), 'get_credit_debit') - reconcile = fields.Boolean('Reconcile', - help='Allow move lines of this account \nto be reconciled.', - states={ - 'invisible': Eval('kind') == 'view', - 'readonly': _states['readonly'], - }, depends=['kind']) note = fields.Text('Note') - kind = fields.Selection([ - ('other', 'Other'), - ('payable', 'Payable'), - ('revenue', 'Revenue'), - ('receivable', 'Receivable'), - ('expense', 'Expense'), - ('stock', 'Stock'), - ('view', 'View'), - ], 'Kind', required=True, states=_states) - deferral = fields.Boolean('Deferral', states={ - 'invisible': Eval('kind') == 'view', - 'readonly': _states['readonly'], - }, depends=['kind']) - deferrals = fields.One2Many('account.account.deferral', 'account', - 'Deferrals', readonly=True, states={ - 'invisible': Eval('kind') == 'view', - }, depends=['kind']) - party_required = fields.Boolean('Party Required', - domain=[ - If((Eval('kind') == 'view') | ~Eval('deferral', False), - ('party_required', '=', False), - (), - ) - ], + deferrals = fields.One2Many( + 'account.account.deferral', 'account', "Deferrals", readonly=True, states={ - 'invisible': (Eval('kind') == 'view') | ~Eval('deferral', False), - 'readonly': _states['readonly'], + 'invisible': ~Eval('type'), }, - depends=['kind', 'deferral']) - general_ledger_balance = fields.Boolean('General Ledger Balance', - states={ - 'invisible': Eval('kind') == 'view', - }, - depends=['kind'], - help="Display only the balance in the general ledger report") + depends=['type']) taxes = fields.Many2Many('account.account-account.tax', 'account', 'tax', 'Default Taxes', domain=[ @@ -705,6 +799,15 @@ class Account(ActivePeriodMixin, tree(), ModelSQL, ModelView): cls._order.insert(0, ('code', 'ASC')) cls._order.insert(1, ('name', 'ASC')) + @classmethod + def __register__(cls, module_name): + super().__register__(module_name) + + table_h = cls.__table_handler__(module_name) + + # Migration from 5.0: remove kind + table_h.drop_column('kind') + @classmethod def validate(cls, accounts): super(Account, cls).validate(accounts) @@ -722,26 +825,6 @@ class Account(ActivePeriodMixin, tree(), ModelSQL, ModelView): def default_company(): return Transaction().context.get('company') or None - @staticmethod - def default_reconcile(): - return False - - @staticmethod - def default_deferral(): - return True - - @staticmethod - def default_party_required(): - return False - - @staticmethod - def default_general_ledger_balance(): - return False - - @staticmethod - def default_kind(): - return 'view' - @classmethod def default_template_override(cls): return False @@ -916,14 +999,8 @@ class Account(ActivePeriodMixin, tree(), ModelSQL, ModelView): return values - def get_rec_name(self, name): - if self.code: - return self.code + ' - ' + self.name - else: - return self.name - __on_change_parent_fields = ['name', 'code', 'company', 'type', - 'reconcile', 'kind', 'deferral', 'party_required', + 'reconcile', 'deferral', 'party_required', 'general_ledger_balance', 'taxes'] @fields.depends('parent', *__on_change_parent_fields) @@ -932,7 +1009,7 @@ class Account(ActivePeriodMixin, tree(), ModelSQL, ModelView): return for field in self.__on_change_parent_fields: if (not getattr(self, field) - or field in {'reconcile', 'kind', 'deferral', + or field in {'reconcile', 'deferral', 'party_required', 'general_ledger_balance'}): setattr(self, field, getattr(self.parent, field)) @@ -954,7 +1031,11 @@ class Account(ActivePeriodMixin, tree(), ModelSQL, ModelView): for account in accounts: if not account.second_currency: continue - if account.kind != 'other': + if (not account.type + or account.type.payable + or account.type.revenue + or account.type.receivable + or account.type.expense): raise SecondCurrencyError( gettext('account.msg_account_invalid_type_second_currency', account=account.rec_name)) @@ -1301,7 +1382,7 @@ class GeneralLedgerAccount(ActivePeriodMixin, ModelSQL, ModelView): columns.append(Column(account, fname).as_(fname)) return account.select(*columns, where=(account.company == context.get('company')) - & (account.kind != 'view')) + & (account.type != Null)) @classmethod def get_period_ids(cls, name): @@ -1963,17 +2044,19 @@ class AgedBalance(ModelSQL, ModelView): Move = pool.get('account.move') Reconciliation = pool.get('account.move.reconciliation') Account = pool.get('account.account') + Type = pool.get('account.account.type') line = MoveLine.__table__() move = Move.__table__() reconciliation = Reconciliation.__table__() account = Account.__table__() + type_ = Type.__table__() company_id = context.get('company') date = context.get('date') with Transaction().set_context(date=None): line_query, _ = MoveLine.query_get(line) - kind = cls.get_kind() + kind = cls.get_kind(type_) columns = [ line.party.as_('id'), Literal(0).as_('create_uid'), @@ -2008,11 +2091,12 @@ class AgedBalance(ModelSQL, ModelView): return line.join(move, condition=line.move == move.id ).join(account, condition=line.account == account.id + ).join(type_, condition=account.type == type_.id ).join(reconciliation, 'LEFT', condition=reconciliation.id == line.reconciliation ).select(*columns, where=(line.party != Null) - & account.kind.in_(kind) + & kind & ((line.reconciliation == Null) | (reconciliation.date > date)) & (move.date <= date) @@ -2040,17 +2124,17 @@ class AgedBalance(ModelSQL, ModelView): return datetime.timedelta(days=1) @classmethod - def get_kind(cls): + def get_kind(cls, account_type): context = Transaction().context type_ = context.get('type', 'customer') if type_ == 'customer_supplier': - return ['payable', 'receivable'] + return account_type.payable | account_type.receivable elif type_ == 'supplier': - return ['payable'] + return account_type.payable elif type_ == 'customer': - return ['receivable'] + return account_type.receivable else: - return [] + return Literal(False) def get_currency_digits(self, name): return self.company.currency.digits @@ -2111,14 +2195,14 @@ class CreateChartProperties(ModelView): account_receivable = fields.Many2One('account.account', 'Default Receivable Account', domain=[ - ('kind', '=', 'receivable'), + ('type.receivable', '=', True), ('company', '=', Eval('company')), ], depends=['company']) account_payable = fields.Many2One('account.account', 'Default Payable Account', domain=[ - ('kind', '=', 'payable'), + ('type.payable', '=', True), ('company', '=', Eval('company')), ], depends=['company']) diff --git a/account.xml b/account.xml index 08ef0625da..0ae86af1ad 100644 --- a/account.xml +++ b/account.xml @@ -360,7 +360,7 @@ this repository contains the full copyright notices and license terms. --> eval="[('company', '=', Eval('company', -1))]" pyson="1"/> @@ -614,7 +614,7 @@ this repository contains the full copyright notices and license terms. --> eval="[('company', '=', Eval('company', -1))]" pyson="1"/> @@ -653,7 +653,7 @@ this repository contains the full copyright notices and license terms. --> eval="[('company', '=', Eval('company', -1))]" pyson="1"/> diff --git a/configuration.py b/configuration.py index dd4d80b44e..4b23f2e109 100644 --- a/configuration.py +++ b/configuration.py @@ -22,14 +22,14 @@ class Configuration( default_account_receivable = fields.MultiValue(fields.Many2One( 'account.account', "Default Account Receivable", domain=[ - ('kind', '=', 'receivable'), + ('type.receivable', '=', True), ('party_required', '=', True), ('company', '=', Eval('context', {}).get('company', -1)), ])) default_account_payable = fields.MultiValue(fields.Many2One( 'account.account', "Default Account Payable", domain=[ - ('kind', '=', 'payable'), + ('type.payable', '=', True), ('party_required', '=', True), ('company', '=', Eval('context', {}).get('company', -1)), ])) @@ -54,7 +54,7 @@ class ConfigurationDefaultAccount(ModelSQL, CompanyValueMixin): default_account_receivable = fields.Many2One( 'account.account', "Default Account Receivable", domain=[ - ('kind', '=', 'receivable'), + ('type.receivable', '=', True), ('party_required', '=', True), ('company', '=', Eval('company', -1)), ], @@ -62,7 +62,7 @@ class ConfigurationDefaultAccount(ModelSQL, CompanyValueMixin): default_account_payable = fields.Many2One( 'account.account', "Default Account Payable", domain=[ - ('kind', '=', 'payable'), + ('type.payable', '=', True), ('party_required', '=', True), ('company', '=', Eval('company', -1)), ], diff --git a/doc/index.rst b/doc/index.rst index 1322cac1cb..34447937a9 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -48,14 +48,8 @@ Account Type ************ The Account Type Model defines the structure of the accounting -reports: - -- Income Statement: A checkbox that tells if accounts of this type - must appear at the top level of the Income Statement report. -- Balance Sheet: A checkbox that tells if accounts of this type - must appear at the top level of the Balance Sheet report. -- Display Balance: A selection that allow to choose how the balance - should be computed (Debit - Credit or Credit - Debit) +reports as balance sheet and income statement. +It also defines check boxes to filter its accounts by usage. Account @@ -68,23 +62,12 @@ An Account is defined by these fields: - Company - Parent Account - Currency -- kind: can take one of these values: - - - Payable or Receivable: if the account is used respectively on - credit and debit moves of parties. - - Expense or Revenue: if the account is used respectively on expense - and revenue moves of parties. - - View: means that the account is used to group other accounts in - the account chart. - - Other: For other accounts. - - Type: The Account Type of the account. - Start and End Date: The period for which the account can be used. - Replaced By: the account to use after end date. -- Deferral: A checkbox. If set to true, credit and debit are carried - over form fiscal year to fiscal year. - Second currency: Force all moves for the account to have this secondary currency. +- Closed: Forbid move on the account. - Reconcile: Allow move lines of this account to be reconciled. - Party Required: Make party required for move lines of this account. - Taxes: This list of tax auto-complete move with new moves lines diff --git a/fiscalyear.py b/fiscalyear.py index d2b417e31e..71cdbe9d49 100644 --- a/fiscalyear.py +++ b/fiscalyear.py @@ -249,7 +249,7 @@ class FiscalYear(Workflow, ModelSQL, ModelView): Currency = pool.get('currency.currency') Deferral = pool.get('account.account.deferral') - if account.kind == 'view': + if not account.type: return if not account.deferral: if not Currency.is_zero(self.company.currency, account.balance): @@ -365,7 +365,8 @@ class BalanceNonDeferralStart(ModelView): credit_account = fields.Many2One('account.account', 'Credit Account', required=True, domain=[ - ('kind', '!=', 'view'), + ('type', '!=', None), + ('closed', '!=', True), ('company', '=', Eval('company', -1)), ('deferral', '=', True), ], @@ -373,7 +374,8 @@ class BalanceNonDeferralStart(ModelView): debit_account = fields.Many2One('account.account', 'Debit Account', required=True, domain=[ - ('kind', '!=', 'view'), + ('type', '!=', None), + ('closed', '!=', True), ('company', '=', Eval('company', -1)), ('deferral', '=', True), ], @@ -438,7 +440,8 @@ class BalanceNonDeferral(Wizard): accounts = Account.search([ ('company', '=', self.start.fiscalyear.company.id), ('deferral', '=', False), - ('kind', '!=', 'view'), + ('type', '!=', None), + ('closed', '!=', True), ]) lines = [] for account in accounts: diff --git a/journal.py b/journal.py index 18df4c7e4d..3d1df491e3 100644 --- a/journal.py +++ b/journal.py @@ -103,6 +103,7 @@ class Journal( MoveLine = pool.get('account.move.line') Move = pool.get('account.move') Account = pool.get('account.account') + AccountType = pool.get('account.account.type') Company = pool.get('company.company') context = Transaction().context cursor = Transaction().connection.cursor() @@ -120,15 +121,19 @@ class Journal( line = MoveLine.__table__() move = Move.__table__() account = Account.__table__() + account_type = AccountType.__table__() where = ((move.date >= context.get('start_date')) & (move.date <= context.get('end_date')) - & ~account.kind.in_(['receivable', 'payable']) + & ~account_type.receivable + & ~account_type.payable & (move.company == company.id)) for sub_journals in grouped_slice(journals): sub_journals = list(sub_journals) red_sql = reduce_ids(move.journal, [j.id for j in sub_journals]) query = line.join(move, 'LEFT', condition=line.move == move.id ).join(account, 'LEFT', condition=line.account == account.id + ).join(account_type, 'LEFT', + condition=account.type == account_type.id ).select(move.journal, Sum(line.debit), Sum(line.credit), where=where & red_sql, group_by=move.journal) diff --git a/message.xml b/message.xml index 4ca2f20a7f..4a145e45a4 100644 --- a/message.xml +++ b/message.xml @@ -87,7 +87,7 @@ this repository contains the full copyright notices and license terms. --> You cannot delete account "%(account)s" because it has move lines. - To set a second currency for account "%(account)s", it must have the type "Other". + To set a second currency for account "%(account)s", it must not have a type "payable", "revenue", "receivable" nor "expense". To set a second currency for account "%(account)s", it must be deferral. @@ -155,8 +155,8 @@ Use the current period to cancel the move? You cannot modify reconciled line "%(line)s". - - To create a line on account "%(account)s", you must change its "view" kind. + + To create a line on account "%(account)s", you must set a type or unclose it. You cannot reconcile already reconciled line "%(line)s". diff --git a/minimal_chart.xml b/minimal_chart.xml index a309271bdd..a9e1246db7 100644 --- a/minimal_chart.xml +++ b/minimal_chart.xml @@ -16,6 +16,7 @@ this repository contains the full copyright notices and license terms. --> Минимальная схема типов счетов Minimalni kontni načrt + @@ -31,7 +32,8 @@ this repository contains the full copyright notices and license terms. --> Sredstvo - + balance + @@ -46,6 +48,8 @@ this repository contains the full copyright notices and license terms. --> Текущие Kratkoročno + balance + Наличные Denar + balance + Наличные Denar + balance + + @@ -91,6 +100,8 @@ this repository contains the full copyright notices and license terms. --> Долгосрочные Dolgoročno + balance + Obveznosti - + balance @@ -122,6 +133,7 @@ this repository contains the full copyright notices and license terms. --> Текущие Kratkoročno + balance Подлежащие уплате Obveznosti + balance + @@ -152,6 +166,7 @@ this repository contains the full copyright notices and license terms. --> Налоги Davek + balance Долгосрочные Dolgoročno + balance Kapital - + balance @@ -198,9 +214,8 @@ this repository contains the full copyright notices and license terms. --> Поступления Prihodki + income - - credit-debit @@ -215,8 +230,9 @@ this repository contains the full copyright notices and license terms. --> Доходы Prihodki + income - credit-debit + @@ -231,8 +247,9 @@ this repository contains the full copyright notices and license terms. --> Расходы Odhodki + income - credit-debit + @@ -248,6 +265,7 @@ this repository contains the full copyright notices and license terms. --> Zunaj bilance + off-balance @@ -262,6 +280,7 @@ this repository contains the full copyright notices and license terms. --> Минимальная схема счетов Minimalni kontni načrt + Main Receivable @@ -276,10 +295,8 @@ this repository contains the full copyright notices and license terms. --> Glavne terjatve - - receivable Main Payable @@ -294,10 +311,8 @@ this repository contains the full copyright notices and license terms. --> Glavne obveznosti - - payable Main Revenue @@ -311,9 +326,7 @@ this repository contains the full copyright notices and license terms. --> Основной Доходы Glavni prihodki - - revenue Main Expense @@ -327,9 +340,7 @@ this repository contains the full copyright notices and license terms. --> Основной Расходы Glavni odhodki - - expense Main Cash @@ -345,7 +356,6 @@ this repository contains the full copyright notices and license terms. --> - other Main Tax @@ -361,7 +371,6 @@ this repository contains the full copyright notices and license terms. --> - other diff --git a/minimal_chart_bg.xml b/minimal_chart_bg.xml index eb9fc61ba5..82baf6d74b 100644 --- a/minimal_chart_bg.xml +++ b/minimal_chart_bg.xml @@ -13,7 +13,9 @@ this repository contains the full copyright notices and license terms. --> + + @@ -25,9 +27,11 @@ this repository contains the full copyright notices and license terms. --> + - + balance + @@ -39,7 +43,10 @@ this repository contains the full copyright notices and license terms. --> + + balance + @@ -52,7 +59,10 @@ this repository contains the full copyright notices and license terms. --> + + balance + @@ -65,8 +75,12 @@ this repository contains the full copyright notices and license terms. --> + + balance + + @@ -78,7 +92,10 @@ this repository contains the full copyright notices and license terms. --> + + balance + @@ -91,9 +108,10 @@ this repository contains the full copyright notices and license terms. --> + - + balance @@ -105,7 +123,9 @@ this repository contains the full copyright notices and license terms. --> + + balance @@ -118,8 +138,11 @@ this repository contains the full copyright notices and license terms. --> + + balance + @@ -131,7 +154,9 @@ this repository contains the full copyright notices and license terms. --> + + balance @@ -144,7 +169,9 @@ this repository contains the full copyright notices and license terms. --> + + balance @@ -157,9 +184,10 @@ this repository contains the full copyright notices and license terms. --> + - + balance @@ -171,10 +199,10 @@ this repository contains the full copyright notices and license terms. --> + + income - - credit-debit @@ -186,9 +214,11 @@ this repository contains the full copyright notices and license terms. --> + + income - credit-debit + @@ -200,9 +230,11 @@ this repository contains the full copyright notices and license terms. --> + + income - credit-debit + @@ -214,8 +246,10 @@ this repository contains the full copyright notices and license terms. --> + + off-balance @@ -228,7 +262,9 @@ this repository contains the full copyright notices and license terms. --> + + @@ -240,12 +276,11 @@ this repository contains the full copyright notices and license terms. --> + - - receivable @@ -257,12 +292,11 @@ this repository contains the full copyright notices and license terms. --> + - - payable @@ -274,10 +308,9 @@ this repository contains the full copyright notices and license terms. --> + - - revenue @@ -289,10 +322,9 @@ this repository contains the full copyright notices and license terms. --> + - - expense @@ -304,10 +336,10 @@ this repository contains the full copyright notices and license terms. --> + - other @@ -319,10 +351,10 @@ this repository contains the full copyright notices and license terms. --> + - other diff --git a/minimal_chart_ca.xml b/minimal_chart_ca.xml index 3bd1e90bed..81e5c4816e 100644 --- a/minimal_chart_ca.xml +++ b/minimal_chart_ca.xml @@ -13,7 +13,9 @@ this repository contains the full copyright notices and license terms. --> + + @@ -25,9 +27,11 @@ this repository contains the full copyright notices and license terms. --> + - + balance + @@ -39,7 +43,10 @@ this repository contains the full copyright notices and license terms. --> + + balance + @@ -52,7 +59,10 @@ this repository contains the full copyright notices and license terms. --> + + balance + @@ -65,8 +75,12 @@ this repository contains the full copyright notices and license terms. --> + + balance + + @@ -78,7 +92,10 @@ this repository contains the full copyright notices and license terms. --> + + balance + @@ -91,9 +108,10 @@ this repository contains the full copyright notices and license terms. --> + - + balance @@ -105,7 +123,9 @@ this repository contains the full copyright notices and license terms. --> + + balance @@ -118,8 +138,11 @@ this repository contains the full copyright notices and license terms. --> + + balance + @@ -131,7 +154,9 @@ this repository contains the full copyright notices and license terms. --> + + balance @@ -144,7 +169,9 @@ this repository contains the full copyright notices and license terms. --> + + balance @@ -157,9 +184,10 @@ this repository contains the full copyright notices and license terms. --> + - + balance @@ -171,10 +199,10 @@ this repository contains the full copyright notices and license terms. --> + + income - - credit-debit @@ -186,9 +214,11 @@ this repository contains the full copyright notices and license terms. --> + + income - credit-debit + @@ -200,9 +230,11 @@ this repository contains the full copyright notices and license terms. --> + + income - credit-debit + @@ -214,8 +246,10 @@ this repository contains the full copyright notices and license terms. --> + + off-balance @@ -228,7 +262,9 @@ this repository contains the full copyright notices and license terms. --> + + @@ -240,12 +276,11 @@ this repository contains the full copyright notices and license terms. --> + - - receivable @@ -257,12 +292,11 @@ this repository contains the full copyright notices and license terms. --> + - - payable @@ -274,10 +308,9 @@ this repository contains the full copyright notices and license terms. --> + - - revenue @@ -289,10 +322,9 @@ this repository contains the full copyright notices and license terms. --> + - - expense @@ -304,10 +336,10 @@ this repository contains the full copyright notices and license terms. --> + - other @@ -319,10 +351,10 @@ this repository contains the full copyright notices and license terms. --> + - other diff --git a/minimal_chart_de.xml b/minimal_chart_de.xml index 455536034f..4a82207e17 100644 --- a/minimal_chart_de.xml +++ b/minimal_chart_de.xml @@ -13,7 +13,9 @@ this repository contains the full copyright notices and license terms. --> + + @@ -25,9 +27,11 @@ this repository contains the full copyright notices and license terms. --> + - + balance + @@ -39,7 +43,10 @@ this repository contains the full copyright notices and license terms. --> + + balance + @@ -52,7 +59,10 @@ this repository contains the full copyright notices and license terms. --> + + balance + @@ -65,8 +75,12 @@ this repository contains the full copyright notices and license terms. --> + + balance + + @@ -78,7 +92,10 @@ this repository contains the full copyright notices and license terms. --> + + balance + @@ -91,9 +108,10 @@ this repository contains the full copyright notices and license terms. --> + - + balance @@ -105,7 +123,9 @@ this repository contains the full copyright notices and license terms. --> + + balance @@ -118,8 +138,11 @@ this repository contains the full copyright notices and license terms. --> + + balance + @@ -131,7 +154,9 @@ this repository contains the full copyright notices and license terms. --> + + balance @@ -144,7 +169,9 @@ this repository contains the full copyright notices and license terms. --> + + balance @@ -157,9 +184,10 @@ this repository contains the full copyright notices and license terms. --> + - + balance @@ -171,10 +199,10 @@ this repository contains the full copyright notices and license terms. --> + + income - - credit-debit @@ -186,9 +214,11 @@ this repository contains the full copyright notices and license terms. --> + + income - credit-debit + @@ -200,9 +230,11 @@ this repository contains the full copyright notices and license terms. --> + + income - credit-debit + @@ -214,8 +246,10 @@ this repository contains the full copyright notices and license terms. --> + + off-balance @@ -228,7 +262,9 @@ this repository contains the full copyright notices and license terms. --> + + @@ -240,12 +276,11 @@ this repository contains the full copyright notices and license terms. --> + - - receivable @@ -257,12 +292,11 @@ this repository contains the full copyright notices and license terms. --> + - - payable @@ -274,10 +308,9 @@ this repository contains the full copyright notices and license terms. --> + - - revenue @@ -289,10 +322,9 @@ this repository contains the full copyright notices and license terms. --> + - - expense @@ -304,10 +336,10 @@ this repository contains the full copyright notices and license terms. --> + - other @@ -319,10 +351,10 @@ this repository contains the full copyright notices and license terms. --> + - other diff --git a/minimal_chart_en.xml b/minimal_chart_en.xml index 9e8377c3c2..e2490b57fb 100644 --- a/minimal_chart_en.xml +++ b/minimal_chart_en.xml @@ -15,6 +15,7 @@ this repository contains the full copyright notices and license terms. --> + Asset @@ -29,7 +30,8 @@ this repository contains the full copyright notices and license terms. --> - + balance + Current @@ -43,6 +45,8 @@ this repository contains the full copyright notices and license terms. --> + balance + @@ -57,6 +61,8 @@ this repository contains the full copyright notices and license terms. --> + balance + @@ -71,7 +77,10 @@ this repository contains the full copyright notices and license terms. --> + balance + + Long-term @@ -85,6 +94,8 @@ this repository contains the full copyright notices and license terms. --> + balance + @@ -100,7 +111,7 @@ this repository contains the full copyright notices and license terms. --> - + balance Current @@ -114,6 +125,7 @@ this repository contains the full copyright notices and license terms. --> + balance @@ -128,7 +140,9 @@ this repository contains the full copyright notices and license terms. --> + balance + Tax @@ -142,6 +156,7 @@ this repository contains the full copyright notices and license terms. --> + balance @@ -156,6 +171,7 @@ this repository contains the full copyright notices and license terms. --> + balance @@ -171,7 +187,7 @@ this repository contains the full copyright notices and license terms. --> - + balance Income @@ -185,9 +201,8 @@ this repository contains the full copyright notices and license terms. --> + income - - credit-debit Revenue @@ -201,8 +216,9 @@ this repository contains the full copyright notices and license terms. --> + income - credit-debit + Expense @@ -216,8 +232,9 @@ this repository contains the full copyright notices and license terms. --> + income - credit-debit + Off-Balance @@ -232,6 +249,7 @@ this repository contains the full copyright notices and license terms. --> + off-balance @@ -246,6 +264,7 @@ this repository contains the full copyright notices and license terms. --> + Main Receivable @@ -260,10 +279,8 @@ this repository contains the full copyright notices and license terms. --> - - receivable Main Payable @@ -278,10 +295,8 @@ this repository contains the full copyright notices and license terms. --> - - payable Main Revenue @@ -295,9 +310,7 @@ this repository contains the full copyright notices and license terms. --> - - revenue Main Expense @@ -311,9 +324,7 @@ this repository contains the full copyright notices and license terms. --> - - expense Main Cash @@ -329,7 +340,6 @@ this repository contains the full copyright notices and license terms. --> - other Main Tax @@ -345,7 +355,6 @@ this repository contains the full copyright notices and license terms. --> - other diff --git a/minimal_chart_es.xml b/minimal_chart_es.xml index 91ab6e7e6b..3e4e566de1 100644 --- a/minimal_chart_es.xml +++ b/minimal_chart_es.xml @@ -13,7 +13,9 @@ this repository contains the full copyright notices and license terms. --> + + @@ -25,9 +27,11 @@ this repository contains the full copyright notices and license terms. --> + - + balance + @@ -39,7 +43,10 @@ this repository contains the full copyright notices and license terms. --> + + balance + @@ -52,7 +59,10 @@ this repository contains the full copyright notices and license terms. --> + + balance + @@ -65,8 +75,12 @@ this repository contains the full copyright notices and license terms. --> + + balance + + @@ -78,7 +92,10 @@ this repository contains the full copyright notices and license terms. --> + + balance + @@ -91,9 +108,10 @@ this repository contains the full copyright notices and license terms. --> + - + balance @@ -105,7 +123,9 @@ this repository contains the full copyright notices and license terms. --> + + balance @@ -118,8 +138,11 @@ this repository contains the full copyright notices and license terms. --> + + balance + @@ -131,7 +154,9 @@ this repository contains the full copyright notices and license terms. --> + + balance @@ -144,7 +169,9 @@ this repository contains the full copyright notices and license terms. --> + + balance @@ -157,9 +184,10 @@ this repository contains the full copyright notices and license terms. --> + - + balance @@ -171,10 +199,10 @@ this repository contains the full copyright notices and license terms. --> + + income - - credit-debit @@ -186,9 +214,11 @@ this repository contains the full copyright notices and license terms. --> + + income - credit-debit + @@ -200,9 +230,11 @@ this repository contains the full copyright notices and license terms. --> + + income - credit-debit + @@ -214,8 +246,10 @@ this repository contains the full copyright notices and license terms. --> + + off-balance @@ -228,7 +262,9 @@ this repository contains the full copyright notices and license terms. --> + + @@ -240,12 +276,11 @@ this repository contains the full copyright notices and license terms. --> + - - receivable @@ -257,12 +292,11 @@ this repository contains the full copyright notices and license terms. --> + - - payable @@ -274,10 +308,9 @@ this repository contains the full copyright notices and license terms. --> + - - revenue @@ -289,10 +322,9 @@ this repository contains the full copyright notices and license terms. --> + - - expense @@ -304,10 +336,10 @@ this repository contains the full copyright notices and license terms. --> + - other @@ -319,10 +351,10 @@ this repository contains the full copyright notices and license terms. --> + - other diff --git a/minimal_chart_fr.xml b/minimal_chart_fr.xml index 088b71a2da..626d9a51a4 100644 --- a/minimal_chart_fr.xml +++ b/minimal_chart_fr.xml @@ -15,6 +15,7 @@ this repository contains the full copyright notices and license terms. --> + @@ -29,7 +30,8 @@ this repository contains the full copyright notices and license terms. --> - + balance + @@ -43,6 +45,8 @@ this repository contains the full copyright notices and license terms. --> + balance + @@ -57,6 +61,8 @@ this repository contains the full copyright notices and license terms. --> + balance + @@ -71,7 +77,10 @@ this repository contains the full copyright notices and license terms. --> + balance + + @@ -85,6 +94,8 @@ this repository contains the full copyright notices and license terms. --> + balance + @@ -100,7 +111,7 @@ this repository contains the full copyright notices and license terms. --> - + balance @@ -114,6 +125,7 @@ this repository contains the full copyright notices and license terms. --> + balance @@ -128,7 +140,9 @@ this repository contains the full copyright notices and license terms. --> + balance + @@ -142,6 +156,7 @@ this repository contains the full copyright notices and license terms. --> + balance @@ -156,6 +171,7 @@ this repository contains the full copyright notices and license terms. --> + balance @@ -171,7 +187,7 @@ this repository contains the full copyright notices and license terms. --> - + balance @@ -185,9 +201,8 @@ this repository contains the full copyright notices and license terms. --> + income - - credit-debit @@ -201,8 +216,9 @@ this repository contains the full copyright notices and license terms. --> + income - credit-debit + @@ -216,8 +232,9 @@ this repository contains the full copyright notices and license terms. --> + income - credit-debit + @@ -232,6 +249,7 @@ this repository contains the full copyright notices and license terms. --> + off-balance @@ -246,6 +264,7 @@ this repository contains the full copyright notices and license terms. --> + @@ -260,10 +279,8 @@ this repository contains the full copyright notices and license terms. --> - - receivable @@ -278,10 +295,8 @@ this repository contains the full copyright notices and license terms. --> - - payable @@ -295,9 +310,7 @@ this repository contains the full copyright notices and license terms. --> - - revenue @@ -311,9 +324,7 @@ this repository contains the full copyright notices and license terms. --> - - expense @@ -329,7 +340,6 @@ this repository contains the full copyright notices and license terms. --> - other @@ -345,7 +355,6 @@ this repository contains the full copyright notices and license terms. --> - other diff --git a/minimal_chart_nl.xml b/minimal_chart_nl.xml index 1466e1d117..94cee1d277 100644 --- a/minimal_chart_nl.xml +++ b/minimal_chart_nl.xml @@ -13,7 +13,9 @@ this repository contains the full copyright notices and license terms. --> Basaal rekeningschematype + + @@ -25,9 +27,11 @@ this repository contains the full copyright notices and license terms. --> Activa + - + balance + @@ -39,7 +43,10 @@ this repository contains the full copyright notices and license terms. --> Actueel + + balance + @@ -52,7 +59,10 @@ this repository contains the full copyright notices and license terms. --> Kas + + balance + @@ -65,8 +75,12 @@ this repository contains the full copyright notices and license terms. --> Kas + + balance + + @@ -78,7 +92,10 @@ this repository contains the full copyright notices and license terms. --> Langlopend + + balance + @@ -91,9 +108,10 @@ this repository contains the full copyright notices and license terms. --> Verplichting + - + balance @@ -105,7 +123,9 @@ this repository contains the full copyright notices and license terms. --> Actueel + + balance @@ -118,8 +138,11 @@ this repository contains the full copyright notices and license terms. --> Te betalen + + balance + @@ -131,7 +154,9 @@ this repository contains the full copyright notices and license terms. --> Belasting + + balance @@ -144,7 +169,9 @@ this repository contains the full copyright notices and license terms. --> Langlopend + + balance @@ -157,9 +184,10 @@ this repository contains the full copyright notices and license terms. --> Eigen vermogen + - + balance @@ -171,10 +199,10 @@ this repository contains the full copyright notices and license terms. --> Inkomsten + + income - - credit-debit @@ -186,9 +214,11 @@ this repository contains the full copyright notices and license terms. --> Opbrengst + + income - credit-debit + @@ -200,9 +230,11 @@ this repository contains the full copyright notices and license terms. --> Kosten + + income - credit-debit + @@ -214,8 +246,10 @@ this repository contains the full copyright notices and license terms. --> Buiten balans + + off-balance @@ -228,7 +262,9 @@ this repository contains the full copyright notices and license terms. --> Basaal rekeningschema + + @@ -240,12 +276,11 @@ this repository contains the full copyright notices and license terms. --> Basisrekening ontvangen + - - receivable @@ -257,12 +292,11 @@ this repository contains the full copyright notices and license terms. --> Basisrekening betalen + - - payable @@ -274,10 +308,9 @@ this repository contains the full copyright notices and license terms. --> Basis opbrengstrekening + - - revenue @@ -289,10 +322,9 @@ this repository contains the full copyright notices and license terms. --> Basis kostenrekening + - - expense @@ -304,10 +336,10 @@ this repository contains the full copyright notices and license terms. --> Basis kasrekening + - other @@ -319,10 +351,10 @@ this repository contains the full copyright notices and license terms. --> Basis belastingrekening + - other diff --git a/minimal_chart_pt.xml b/minimal_chart_pt.xml index 20f0caf10a..8ea55aea48 100644 --- a/minimal_chart_pt.xml +++ b/minimal_chart_pt.xml @@ -15,6 +15,7 @@ this repository contains the full copyright notices and license terms. --> + @@ -29,7 +30,8 @@ this repository contains the full copyright notices and license terms. --> - + balance + @@ -43,6 +45,8 @@ this repository contains the full copyright notices and license terms. --> + balance + @@ -57,6 +61,8 @@ this repository contains the full copyright notices and license terms. --> + balance + @@ -71,7 +77,10 @@ this repository contains the full copyright notices and license terms. --> + balance + + @@ -85,6 +94,8 @@ this repository contains the full copyright notices and license terms. --> + balance + @@ -100,7 +111,7 @@ this repository contains the full copyright notices and license terms. --> - + balance @@ -114,6 +125,7 @@ this repository contains the full copyright notices and license terms. --> + balance @@ -128,7 +140,9 @@ this repository contains the full copyright notices and license terms. --> + balance + @@ -142,6 +156,7 @@ this repository contains the full copyright notices and license terms. --> + balance @@ -156,6 +171,7 @@ this repository contains the full copyright notices and license terms. --> + balance @@ -171,7 +187,7 @@ this repository contains the full copyright notices and license terms. --> - + balance @@ -181,13 +197,12 @@ this repository contains the full copyright notices and license terms. --> - Ingressos + Resultados + income - - credit-debit @@ -201,8 +216,9 @@ this repository contains the full copyright notices and license terms. --> + income - credit-debit + @@ -216,8 +232,9 @@ this repository contains the full copyright notices and license terms. --> + income - credit-debit + @@ -232,6 +249,7 @@ this repository contains the full copyright notices and license terms. --> + off-balance @@ -246,6 +264,7 @@ this repository contains the full copyright notices and license terms. --> + @@ -260,10 +279,8 @@ this repository contains the full copyright notices and license terms. --> - - receivable @@ -278,10 +295,8 @@ this repository contains the full copyright notices and license terms. --> - - payable @@ -295,9 +310,7 @@ this repository contains the full copyright notices and license terms. --> - - revenue @@ -311,9 +324,7 @@ this repository contains the full copyright notices and license terms. --> - - expense @@ -329,7 +340,6 @@ this repository contains the full copyright notices and license terms. --> - other @@ -345,7 +355,6 @@ this repository contains the full copyright notices and license terms. --> - other diff --git a/minimal_chart_ru.xml b/minimal_chart_ru.xml index 73b2676335..85e1142e10 100644 --- a/minimal_chart_ru.xml +++ b/minimal_chart_ru.xml @@ -11,9 +11,11 @@ this repository contains the full copyright notices and license terms. --> + Минимальная схема типов счетов + @@ -23,11 +25,13 @@ this repository contains the full copyright notices and license terms. --> + Активы - + balance + @@ -37,9 +41,12 @@ this repository contains the full copyright notices and license terms. --> + Текущие + balance + @@ -50,9 +57,12 @@ this repository contains the full copyright notices and license terms. --> + Наличные + balance + @@ -63,10 +73,14 @@ this repository contains the full copyright notices and license terms. --> + Наличные + balance + + @@ -76,9 +90,12 @@ this repository contains the full copyright notices and license terms. --> + Долгосрочные + balance + @@ -89,11 +106,12 @@ this repository contains the full copyright notices and license terms. --> + Пассивы - + balance @@ -103,9 +121,11 @@ this repository contains the full copyright notices and license terms. --> + Текущие + balance @@ -116,10 +136,13 @@ this repository contains the full copyright notices and license terms. --> + Подлежащие уплате + balance + @@ -129,9 +152,11 @@ this repository contains the full copyright notices and license terms. --> + Налоги + balance @@ -142,9 +167,11 @@ this repository contains the full copyright notices and license terms. --> + Долгосрочные + balance @@ -155,11 +182,12 @@ this repository contains the full copyright notices and license terms. --> + Собственные средства - + balance @@ -169,12 +197,12 @@ this repository contains the full copyright notices and license terms. --> + Поступления + income - - credit-debit @@ -184,11 +212,13 @@ this repository contains the full copyright notices and license terms. --> + Доходы + income - credit-debit + @@ -198,11 +228,13 @@ this repository contains the full copyright notices and license terms. --> + Расходы + income - credit-debit + @@ -212,10 +244,12 @@ this repository contains the full copyright notices and license terms. --> + Внебалансовые + off-balance @@ -226,9 +260,11 @@ this repository contains the full copyright notices and license terms. --> + Минимальная схема счетов + @@ -238,14 +274,13 @@ this repository contains the full copyright notices and license terms. --> + Основной Подлежащий получению - - receivable @@ -255,14 +290,13 @@ this repository contains the full copyright notices and license terms. --> + Основной Подлежащий уплате - - payable @@ -272,12 +306,11 @@ this repository contains the full copyright notices and license terms. --> + Основной Доходы - - revenue @@ -287,12 +320,11 @@ this repository contains the full copyright notices and license terms. --> + Основной Расходы - - expense @@ -302,12 +334,12 @@ this repository contains the full copyright notices and license terms. --> + Основной Наличные - other @@ -317,12 +349,12 @@ this repository contains the full copyright notices and license terms. --> + Основной Налоги - other diff --git a/minimal_chart_sl.xml b/minimal_chart_sl.xml index b860d840a3..8840213cf0 100644 --- a/minimal_chart_sl.xml +++ b/minimal_chart_sl.xml @@ -12,8 +12,10 @@ this repository contains the full copyright notices and license terms. --> + Minimalni kontni načrt + @@ -24,10 +26,12 @@ this repository contains the full copyright notices and license terms. --> + Sredstvo - + balance + @@ -38,8 +42,11 @@ this repository contains the full copyright notices and license terms. --> + Kratkoročno + balance + @@ -51,8 +58,11 @@ this repository contains the full copyright notices and license terms. --> + Denar + balance + @@ -64,9 +74,13 @@ this repository contains the full copyright notices and license terms. --> + Denar + balance + + @@ -77,8 +91,11 @@ this repository contains the full copyright notices and license terms. --> + Dolgoročno + balance + @@ -90,10 +107,11 @@ this repository contains the full copyright notices and license terms. --> + Obveznosti - + balance @@ -104,8 +122,10 @@ this repository contains the full copyright notices and license terms. --> + Kratkoročno + balance @@ -117,9 +137,12 @@ this repository contains the full copyright notices and license terms. --> + Obveznosti + balance + @@ -130,8 +153,10 @@ this repository contains the full copyright notices and license terms. --> + Davek + balance @@ -143,8 +168,10 @@ this repository contains the full copyright notices and license terms. --> + Dolgoročno + balance @@ -156,10 +183,11 @@ this repository contains the full copyright notices and license terms. --> + Kapital - + balance @@ -170,11 +198,11 @@ this repository contains the full copyright notices and license terms. --> + Prihodki + income - - credit-debit @@ -185,10 +213,12 @@ this repository contains the full copyright notices and license terms. --> + Prihodki + income - credit-debit + @@ -199,10 +229,12 @@ this repository contains the full copyright notices and license terms. --> + Odhodki + income - credit-debit + @@ -213,9 +245,11 @@ this repository contains the full copyright notices and license terms. --> + Zunaj bilance + off-balance @@ -227,8 +261,10 @@ this repository contains the full copyright notices and license terms. --> + Minimalni kontni načrt + @@ -239,13 +275,12 @@ this repository contains the full copyright notices and license terms. --> + Glavne terjatve - - receivable @@ -256,13 +291,12 @@ this repository contains the full copyright notices and license terms. --> + Glavne obveznosti - - payable @@ -273,11 +307,10 @@ this repository contains the full copyright notices and license terms. --> + Glavni prihodki - - revenue @@ -288,11 +321,10 @@ this repository contains the full copyright notices and license terms. --> + Glavni odhodki - - expense @@ -303,11 +335,11 @@ this repository contains the full copyright notices and license terms. --> + Glavna denarna sredstva - other @@ -318,11 +350,11 @@ this repository contains the full copyright notices and license terms. --> + Glavni davki - other diff --git a/move.py b/move.py index 2d4305e422..1eb8a8209e 100644 --- a/move.py +++ b/move.py @@ -546,7 +546,8 @@ class Line(ModelSQL, ModelView): _depends) account = fields.Many2One('account.account', 'Account', required=True, domain=[ - ('kind', '!=', 'view'), + ('type', '!=', None), + ('closed', '!=', True), ['OR', ('start_date', '=', None), ('start_date', '<=', Eval('date', None)), @@ -884,7 +885,7 @@ class Line(ModelSQL, ModelView): order_move_state = _order_move_field('state') def get_amount(self, name): - sign = 1 if self.account.type.display_balance == 'debit-credit' else -1 + sign = -1 if self.account.type.statement == 'income' else 1 if self.amount_second_currency is not None: return self.amount_second_currency * sign else: @@ -990,9 +991,9 @@ class Line(ModelSQL, ModelView): line.check_account() def check_account(self): - if self.account.kind in ('view',): + if not self.account.type or self.account.closed: raise AccessError( - gettext('account.msg_line_view_account', + gettext('account.msg_line_closed_account', account=self.account.rec_name)) if bool(self.party) != bool(self.account.party_required): error = 'party_set' if self.party else 'party_required' @@ -1258,14 +1259,16 @@ class WriteOff(DeactivableMixin, ModelSQL, ModelView): credit_account = fields.Many2One('account.account', "Credit Account", required=True, domain=[ - ('kind', '!=', 'view'), + ('type', '!=', None), + ('closed', '!=', True), ('company', '=', Eval('company')), ], depends=['company']) debit_account = fields.Many2One('account.account', "Debit Account", required=True, domain=[ - ('kind', '!=', 'view'), + ('type', '!=', None), + ('closed', '!=', True), ('company', '=', Eval('company')), ], depends=['company']) @@ -1517,7 +1520,9 @@ class Reconcile(Wizard): Line = pool.get('account.move.line') line = Line.__table__() Account = pool.get('account.account') + AccountType = pool.get('account.account.type') account = Account.__table__() + account_type = AccountType.__table__() cursor = Transaction().connection.cursor() account_rule = Rule.query_get(Account.__name__) @@ -1529,18 +1534,23 @@ class Reconcile(Wizard): balance = line.debit - line.credit cursor.execute(*line.join(account, - condition=line.account == account.id).select( + condition=line.account == account.id) + .join(account_type, condition=account.type == account_type.id) + .select( account.id, where=((line.reconciliation == Null) & account.reconcile & account.id.in_(account_rule)), - group_by=[account.id, account.kind], + group_by=[account.id, + account_type.receivable, account_type.payable], having=(( Sum(Case((balance > 0, 1), else_=0)) > 0) & (Sum(Case((balance < 0, 1), else_=0)) > 0) - | (Case((account.kind == 'receivable', Sum(balance) < 0), - else_=False)) - | (Case((account.kind == 'payable', Sum(balance) > 0), - else_=False)) + | Case((account_type.receivable & ~account_type.payable, + Sum(balance) < 0), + else_=False) + | Case((account_type.payable & ~account_type.receivable, + Sum(balance) > 0), + else_=False) ))) return [a for a, in cursor.fetchall()] @@ -1565,10 +1575,10 @@ class Reconcile(Wizard): having=(( Sum(Case((balance > 0, 1), else_=0)) > 0) & (Sum(Case((balance < 0, 1), else_=0)) > 0) - | (Case((account.kind == 'receivable', Sum(balance) < 0), - else_=False)) - | (Case((account.kind == 'payable', Sum(balance) > 0), - else_=False)) + | Case((account.type.receivable, Sum(balance) < 0), + else_=False) + | Case((account.type.payable, Sum(balance) > 0), + else_=False) ))) return [p for p, in cursor.fetchall()] diff --git a/move.xml b/move.xml index bf42bda1ce..647231f3be 100644 --- a/move.xml +++ b/move.xml @@ -211,7 +211,7 @@ this repository contains the full copyright notices and license terms. --> Payable/Receivable Lines account.move.line @@ -228,7 +228,7 @@ this repository contains the full copyright notices and license terms. --> Payable + eval="[('account.type.payable', '=', True)]" pyson="1"/> Receivable + eval="[('account.type.payable', '=', True)]" pyson="1"/> - + diff --git a/view/account_template_form.xml b/view/account_template_form.xml index 27b42488b4..c1c1a3994e 100644 --- a/view/account_template_form.xml +++ b/view/account_template_form.xml @@ -8,24 +8,25 @@ this repository contains the full copyright notices and license terms. -->