diff --git a/addons/account/__manifest__.py b/addons/account/__manifest__.py index fb08a1befc342..5070b45ca5576 100644 --- a/addons/account/__manifest__.py +++ b/addons/account/__manifest__.py @@ -19,7 +19,6 @@ 'data': [ 'security/account_security.xml', 'security/ir.model.access.csv', - 'data/data_account_type.xml', 'data/account_data.xml', 'data/digest_data.xml', 'views/account_report.xml', @@ -33,7 +32,6 @@ 'views/account_move_views.xml', 'wizard/setup_wizards_view.xml', 'wizard/pos_box.xml', - 'views/account_account_type_views.xml', 'views/account_account_views.xml', 'views/account_group_views.xml', 'views/account_journal_views.xml', diff --git a/addons/account/data/data_account_type.xml b/addons/account/data/data_account_type.xml deleted file mode 100644 index 6bd9dbc72eb93..0000000000000 --- a/addons/account/data/data_account_type.xml +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - Receivable - receivable - asset - - - - Payable - payable - liability - - - - Bank and Cash - liquidity - asset - - - - Credit Card - liquidity - liability - - - - Current Assets - other - asset - - - - Non-current Assets - other - asset - - - - Prepayments - other - asset - - - - Fixed Assets - other - asset - - - - Current Liabilities - other - liability - - - - Non-current Liabilities - other - liability - - - - Equity - equity - - - - Current Year Earnings - equity - - - - Income - other - income - - - Other Income - other - income - - - Expenses - other - expense - - - Depreciation - other - expense - - - Cost of Revenue - other - expense - - - Off-Balance Sheet - other - off_balance - - - diff --git a/addons/account/demo/account_demo.py b/addons/account/demo/account_demo.py index 8cf75751a4632..b249bce960054 100644 --- a/addons/account/demo/account_demo.py +++ b/addons/account/demo/account_demo.py @@ -173,7 +173,7 @@ def _get_demo_data_reconcile_model(self): 'label': 'Due amount', 'account_id': self._get_demo_account( 'income', - 'account.data_account_type_revenue', + 'income', self.env.company, ).id, 'amount_type': 'regex', @@ -183,7 +183,7 @@ def _get_demo_data_reconcile_model(self): 'label': 'Bank Fees', 'account_id': self._get_demo_account( 'cost_of_goods_sold', - 'account.data_account_type_direct_costs', + 'expense_direct_cost', self.env.company, ).id, 'amount_type': 'percentage', @@ -336,11 +336,11 @@ def _post_create_demo_data(self, created): created.button_post() @api.model - def _get_demo_account(self, xml_id, user_type_id, company): + def _get_demo_account(self, xml_id, account_type, company): """Find the most appropriate account possible for demo data creation. :param xml_id (str): the xml_id of the account template in the generic coa - :param user_type_id (str): the full xml_id of the account type wanted + :param account_type (str): the full xml_id of the account type wanted :param company (Model): the company for which we search the account :return (Model): the most appropriate record found """ @@ -351,7 +351,7 @@ def _get_demo_account(self, xml_id, user_type_id, company): ('module', '=like', 'l10n%') ], limit=1).res_id) or self.env['account.account'].search([ - ('user_type_id', '=', self.env.ref(user_type_id).id), + ('account_type', '=', account_type), ('company_id', '=', company.id) ], limit=1) or self.env['account.account'].search([('company_id', '=', company.id)], limit=1) diff --git a/addons/account/models/account_account.py b/addons/account/models/account_account.py index 1b781bc373fc7..521234e05bc6a 100644 --- a/addons/account/models/account_account.py +++ b/addons/account/models/account_account.py @@ -4,34 +4,6 @@ from odoo.exceptions import UserError, ValidationError -class AccountAccountType(models.Model): - _name = "account.account.type" - _description = "Account Type" - - name = fields.Char(string='Account Type', required=True, translate=True) - include_initial_balance = fields.Boolean(string="Bring Accounts Balance Forward", help="Used in reports to know if we should consider journal items from the beginning of time instead of from the fiscal year only. Account types that should be reset to zero at each new fiscal year (like expenses, revenue..) should not have this option set.") - type = fields.Selection([ - ('other', 'Regular'), - ('receivable', 'Receivable'), - ('payable', 'Payable'), - ('liquidity', 'Liquidity'), - ], required=True, default='other', - help="The 'Internal Type' is used for features available on "\ - "different types of accounts: liquidity type is for cash or bank accounts"\ - ", payable/receivable is for vendor/customer accounts.") - internal_group = fields.Selection([ - ('equity', 'Equity'), - ('asset', 'Asset'), - ('liability', 'Liability'), - ('income', 'Income'), - ('expense', 'Expense'), - ('off_balance', 'Off Balance'), - ], string="Internal Group", - required=True, - help="The 'Internal Group' is used to filter accounts based on the internal group set on the account type.") - note = fields.Text(string='Description') - - class AccountAccount(models.Model): _name = "account.account" _inherit = ['mail.thread'] @@ -39,17 +11,16 @@ class AccountAccount(models.Model): _order = "is_off_balance, code, company_id" _check_company_auto = True - @api.constrains('internal_type', 'reconcile') + @api.constrains('account_type', 'reconcile') def _check_reconcile(self): for account in self: - if account.internal_type in ('receivable', 'payable') and account.reconcile == False: + if account.account_type in ('asset_receivable', 'liability_payable') and not account.reconcile: raise ValidationError(_('You cannot have a receivable/payable account that is not reconcilable. (account code: %s)', account.code)) - @api.constrains('user_type_id') - def _check_user_type_id_unique_current_year_earning(self): - data_unaffected_earnings = self.env.ref('account.data_unaffected_earnings') + @api.constrains('account_type') + def _check_account_type_unique_current_year_earning(self): result = self._read_group( - domain=[('user_type_id', '=', data_unaffected_earnings.id)], + domain=[('account_type', '=', 'equity_unaffected')], fields=['company_id', 'ids:array_agg(id)'], groupby=['company_id'], ) @@ -64,10 +35,46 @@ def _check_user_type_id_unique_current_year_earning(self): code = fields.Char(size=64, required=True, tracking=True) deprecated = fields.Boolean(default=False, tracking=True) used = fields.Boolean(compute='_compute_used', search='_search_used') - user_type_id = fields.Many2one('account.account.type', string='Type', required=True, tracking=True, - help="Account Type is used for information purpose, to generate country-specific legal reports, and set the rules to close a fiscal year and generate opening entries.") - internal_type = fields.Selection(related='user_type_id.type', string="Internal Type", store=True, readonly=True) - internal_group = fields.Selection(related='user_type_id.internal_group', string="Internal Group", store=True, readonly=True) + account_type = fields.Selection( + selection=[ + ("asset_receivable", "Receivable"), + ("asset_cash", "Bank and Cash"), + ("asset_current", "Current Assets"), + ("asset_non_current", "Non-current Assets"), + ("asset_prepayments", "Prepayments"), + ("asset_fixed", "Fixed Assets"), + ("liability_payable", "Payable"), + ("liability_credit_card", "Credit Card"), + ("liability_current", "Current Liabilities"), + ("liability_non_current", "Non-current Liabilities"), + ("equity", "Equity"), + ("equity_unaffected", "Current Year Earnings"), + ("income", "Income"), + ("income_other", "Other Income"), + ("expense", "Expenses"), + ("expense_depreciation", "Depreciation"), + ("expense_direct_cost", "Cost of Revenue"), + ("off_balance", "Off-Balance Sheet"), + ], + string="Type", tracking=True, + required=True, + help="Account Type is used for information purpose, to generate country-specific legal reports, and set the rules to close a fiscal year and generate opening entries." + ) + include_initial_balance = fields.Boolean(string="Bring Accounts Balance Forward", + help="Used in reports to know if we should consider journal items from the beginning of time instead of from the fiscal year only. Account types that should be reset to zero at each new fiscal year (like expenses, revenue..) should not have this option set.", + compute="_compute_include_initial_balance", + store=True) + internal_group = fields.Selection( + selection=[ + ('equity', 'Equity'), + ('asset', 'Asset'), + ('liability', 'Liability'), + ('income', 'Income'), + ('expense', 'Expense'), + ('off_balance', 'Off Balance'), + ], + string="Internal Group", readonly=True, compute="_compute_internal_group", store=True + ) #has_unreconciled_entries = fields.Boolean(compute='_compute_has_unreconciled_entries', # help="The account has at least one unreconciled debit and credit since last time the invoices & payments matching was performed.") reconcile = fields.Boolean(string='Allow Reconciliation', default=False, tracking=True, @@ -216,21 +223,19 @@ def _check_company_consistency(self): if self._cr.fetchone(): raise UserError(_("You can't change the company of your account since there are some journal items linked to it.")) - @api.constrains('user_type_id') - def _check_user_type_id_sales_purchase_journal(self): + @api.constrains('account_type') + def _check_account_type_sales_purchase_journal(self): if not self: return - self.flush_recordset(['user_type_id']) - self.env['account.account.type'].flush_model(['type']) + self.env['account.account'].flush_model(['account_type']) self.env['account.journal'].flush_model(['type', 'default_account_id']) self._cr.execute(''' SELECT account.id FROM account_account account - JOIN account_account_type acc_type ON account.user_type_id = acc_type.id JOIN account_journal journal ON journal.default_account_id = account.id WHERE account.id IN %s - AND acc_type.type IN ('receivable', 'payable') + AND account.account_type IN ('asset_receivable', 'liability_payable') AND journal.type IN ('sale', 'purchase') LIMIT 1; ''', [tuple(self.ids)]) @@ -366,6 +371,17 @@ def _compute_is_off_balance(self): for account in self: account.is_off_balance = account.internal_group == "off_balance" + @api.depends('account_type') + def _compute_include_initial_balance(self): + for account in self: + account.include_initial_balance = account.account_type not in ('income', 'income_other', 'expense', 'expense_depreciation', 'expense_direct_cost', 'off_balance') + + @api.depends('account_type') + def _compute_internal_group(self): + for account in self: + if account.account_type: + account.internal_group = 'off_balance' if account.account_type == 'off_balance' else account.account_type.split('_')[0] + def _set_opening_debit(self): for record in self: record._set_opening_debit_credit(record.opening_debit, 'debit') @@ -484,10 +500,10 @@ def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_ui domain = ['&', '!'] + domain[1:] return self._search(expression.AND([domain, args]), limit=limit, access_rights_uid=name_get_uid) - @api.onchange('user_type_id') - def _onchange_user_type_id(self): - self.reconcile = self.internal_type in ('receivable', 'payable') - if self.internal_type == 'liquidity': + @api.onchange('account_type') + def _onchange_account_type(self): + self.reconcile = self.account_type in ('asset_receivable', 'liability_payable') + if self.account_type in ('asset_cash', 'liability_credit_card'): self.reconcile = False elif self.internal_group == 'off_balance': self.reconcile = False diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py index c202f6aa5e428..3f0ae6d9f31a7 100644 --- a/addons/account/models/account_bank_statement.py +++ b/addons/account/models/account_bank_statement.py @@ -980,7 +980,7 @@ def _get_default_amls_matching_domain(self): ('account_id.reconcile', '=', True), # Special domain for payments. '|', - ('account_id.internal_type', 'not in', ('receivable', 'payable')), + ('account_id.account_type', 'not in', ('asset_receivable', 'liability_payable')), ('payment_id', '=', False), # Special domain for statement lines. ('statement_line_id', '!=', self.id), diff --git a/addons/account/models/account_journal.py b/addons/account/models/account_journal.py index cdd2965b3b84e..a924f6a76f17e 100644 --- a/addons/account/models/account_journal.py +++ b/addons/account/models/account_journal.py @@ -77,25 +77,23 @@ def _default_invoice_reference_model(self): "Select 'Purchase' for vendor bills journals.\n"\ "Select 'Cash' or 'Bank' for journals that are used in customer or vendor payments.\n"\ "Select 'General' for miscellaneous operations journals.") - type_control_ids = fields.Many2many('account.account.type', 'journal_account_type_control_rel', 'journal_id', 'type_id', string='Allowed account types') account_control_ids = fields.Many2many('account.account', 'journal_account_control_rel', 'journal_id', 'account_id', string='Allowed accounts', check_company=True, domain="[('deprecated', '=', False), ('company_id', '=', company_id), ('is_off_balance', '=', False)]") - default_account_type = fields.Many2one('account.account.type', compute="_compute_default_account_type") + default_account_type = fields.Char(string='Default Account Type', compute="_compute_default_account_type") default_account_id = fields.Many2one( comodel_name='account.account', check_company=True, copy=False, ondelete='restrict', string='Default Account', domain="[('deprecated', '=', False), ('company_id', '=', company_id)," - "'|', ('user_type_id', '=', default_account_type), ('user_type_id', 'in', type_control_ids)," - "('user_type_id.type', 'not in', ('receivable', 'payable'))]") + "'|', ('account_type', '=', default_account_type), ('account_type', 'not in', ('asset_receivable', 'liability_payable'))]") suspense_account_id = fields.Many2one( comodel_name='account.account', check_company=True, ondelete='restrict', readonly=False, store=True, compute='_compute_suspense_account_id', help="Bank statements transactions will be posted on the suspense account until the final reconciliation " "allowing finding the right account.", string='Suspense Account', - domain=lambda self: "[('deprecated', '=', False), ('company_id', '=', company_id), \ - ('user_type_id.type', 'not in', ('receivable', 'payable')), \ - ('user_type_id', '=', %s)]" % self.env.ref('account.data_account_type_current_assets').id) + domain="[('deprecated', '=', False), ('company_id', '=', company_id), \ + ('account_type', 'not in', ('asset_receivable', 'liability_payable')), \ + ('account_type', '=', 'asset_current')]") restrict_mode_hash_table = fields.Boolean(string="Lock Posted Entries with Hash", help="If ticked, the accounting entry or invoice receives a hash as soon as it is posted and cannot be modified anymore.") sequence = fields.Integer(help='Used to order Journals in the dashboard view', default=10) @@ -149,17 +147,16 @@ def _default_invoice_reference_model(self): comodel_name='account.account', check_company=True, help="Used to register a profit when the ending balance of a cash register differs from what the system computes", string='Profit Account', - domain=lambda self: "[('deprecated', '=', False), ('company_id', '=', company_id), \ - ('user_type_id.type', 'not in', ('receivable', 'payable')), \ - ('user_type_id', 'in', %s)]" % [self.env.ref('account.data_account_type_revenue').id, - self.env.ref('account.data_account_type_other_income').id]) + domain="[('deprecated', '=', False), ('company_id', '=', company_id), \ + ('account_type', 'not in', ('asset_receivable', 'liability_payable')), \ + ('account_type', 'in', ('income', 'income_other'))]") loss_account_id = fields.Many2one( comodel_name='account.account', check_company=True, help="Used to register a loss when the ending balance of a cash register differs from what the system computes", string='Loss Account', - domain=lambda self: "[('deprecated', '=', False), ('company_id', '=', company_id), \ - ('user_type_id.type', 'not in', ('receivable', 'payable')), \ - ('user_type_id', '=', %s)]" % self.env.ref('account.data_account_type_expenses').id) + domain="[('deprecated', '=', False), ('company_id', '=', company_id), \ + ('account_type', 'not in', ('asset_receivable', 'liability_payable')), \ + ('account_type', '=', 'expense')]") # Bank journals fields company_partner_id = fields.Many2one('res.partner', related='company_id.partner_id', string='Account Holder', readonly=True, store=False) @@ -277,15 +274,15 @@ def _compute_available_payment_method_ids(self): @api.depends('type') def _compute_default_account_type(self): default_account_id_types = { - 'bank': 'account.data_account_type_liquidity', - 'cash': 'account.data_account_type_liquidity', - 'sale': 'account.data_account_type_revenue', - 'purchase': 'account.data_account_type_expenses' + 'bank': 'asset_cash', + 'cash': 'asset_cash', + 'sale': 'income', + 'purchase': 'expense' } for journal in self: if journal.type in default_account_id_types: - journal.default_account_type = self.env.ref(default_account_id_types[journal.type]).id + journal.default_account_type = default_account_id_types[journal.type] else: journal.default_account_type = False @@ -382,23 +379,6 @@ def _compute_alias_name(self): for journal in self: journal.alias_name = journal.alias_id.alias_name - @api.constrains('type_control_ids') - def _constrains_type_control_ids(self): - self.env['account.move.line'].flush_model(['account_id', 'journal_id']) - self.env['account.account'].flush_model(['user_type_id']) - self.flush_recordset(['type_control_ids']) - self._cr.execute(""" - SELECT aml.id - FROM account_move_line aml - WHERE aml.journal_id in (%s) - AND EXISTS (SELECT 1 FROM journal_account_type_control_rel rel WHERE rel.journal_id = aml.journal_id) - AND NOT EXISTS (SELECT 1 FROM account_account acc - JOIN journal_account_type_control_rel rel ON acc.user_type_id = rel.type_id - WHERE acc.id = aml.account_id AND rel.journal_id = aml.journal_id) - """, tuple(self.ids)) - if self._cr.fetchone(): - raise ValidationError(_('Some journal items already exist in this journal but with accounts from different types than the allowed ones.')) - @api.constrains('account_control_ids') def _constrains_account_control_ids(self): self.env['account.move.line'].flush_model(['account_id', 'journal_id', 'display_type']) @@ -445,7 +425,7 @@ def _check_company_consistency(self): @api.constrains('type', 'default_account_id') def _check_type_default_account_id_type(self): for journal in self: - if journal.type in ('sale', 'purchase') and journal.default_account_id.user_type_id.type in ('receivable', 'payable'): + if journal.type in ('sale', 'purchase') and journal.default_account_id.account_type in ('asset_receivable', 'liability_payable'): raise ValidationError(_("The type of the journal's default credit/debit account shouldn't be 'receivable' or 'payable'.")) @api.constrains('inbound_payment_method_line_ids', 'outbound_payment_method_line_ids') @@ -601,7 +581,7 @@ def _prepare_liquidity_account_vals(self, company, code, vals): return { 'name': vals.get('name'), 'code': code, - 'user_type_id': self.env.ref('account.data_account_type_liquidity').id, + 'account_type': 'asset_cash', 'currency_id': vals.get('currency_id'), 'company_id': company.id, } @@ -622,9 +602,6 @@ def _fill_missing_values(self, vals): random_account = self.env['account.account'].search([('company_id', '=', company.id)], limit=1) digits = len(random_account.code) if random_account else 6 - liquidity_type = self.env.ref('account.data_account_type_liquidity') - current_assets_type = self.env.ref('account.data_account_type_current_assets') - if journal_type in ('bank', 'cash'): has_liquidity_accounts = vals.get('default_account_id') has_profit_account = vals.get('profit_account_id') diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 79d3ab0d9781c..a824aaa2ef234 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -588,7 +588,7 @@ def _onchange_partner_id(self): for line in self.line_ids: line.partner_id = self.partner_id.commercial_partner_id - if new_term_account and line.account_id.user_type_id.type in ('receivable', 'payable'): + if new_term_account and line.account_id.account_type in ('asset_receivable', 'liability_payable'): line.account_id = new_term_account self._compute_bank_partner_id() @@ -619,7 +619,7 @@ def _onchange_currency(self): @api.onchange('payment_reference') def _onchange_payment_reference(self): - for line in self.line_ids.filtered(lambda line: line.account_id.user_type_id.type in ('receivable', 'payable')): + for line in self.line_ids.filtered(lambda line: line.account_id.account_type in ('asset_receivable', 'liability_payable')): line.name = self.payment_reference or '' @api.onchange('invoice_vendor_bill_id') @@ -1057,7 +1057,7 @@ def _apply_cash_rounding(self, diff_balance, diff_amount_currency, cash_rounding self.line_ids -= existing_cash_rounding_line existing_cash_rounding_line = self.env['account.move.line'] - others_lines = self.line_ids.filtered(lambda line: line.account_id.user_type_id.type not in ('receivable', 'payable')) + others_lines = self.line_ids.filtered(lambda line: line.account_id.account_type not in ('asset_receivable', 'liability_payable')) others_lines -= existing_cash_rounding_line total_amount_currency = sum(others_lines.mapped('amount_currency')) @@ -1107,7 +1107,7 @@ def _get_payment_terms_account(self, payment_terms_lines): # Search new account. domain = [ ('company_id', '=', self.company_id.id), - ('internal_type', '=', 'receivable' if self.move_type in ('out_invoice', 'out_refund', 'out_receipt') else 'payable'), + ('account_type', '=', 'asset_receivable' if self.move_type in ('out_invoice', 'out_refund', 'out_receipt') else 'liability_payable'), ] return self.env['account.account'].search(domain, limit=1) @@ -1180,8 +1180,8 @@ def _compute_diff_payment_terms_lines(self, existing_terms_lines, account, to_co candidate.update(candidate._get_fields_onchange_balance(force_computation=True)) return new_terms_lines - existing_terms_lines = self.line_ids.filtered(lambda line: line.account_id.user_type_id.type in ('receivable', 'payable')) - others_lines = self.line_ids.filtered(lambda line: line.account_id.user_type_id.type not in ('receivable', 'payable')) + existing_terms_lines = self.line_ids.filtered(lambda line: line.account_id.account_type in ('asset_receivable', 'liability_payable')) + others_lines = self.line_ids.filtered(lambda line: line.account_id.account_type not in ('asset_receivable', 'liability_payable')) company_currency_id = (self.company_id or self.env.company).currency_id total_balance = sum(others_lines.mapped(lambda l: company_currency_id.round(l.balance))) total_amount_currency = sum(others_lines.mapped('amount_currency')) @@ -1576,7 +1576,7 @@ def _compute_amount(self): SELECT source_line.id AS source_line_id, source_line.move_id AS source_move_id, - account_type.type AS source_line_account_type, + account.account_type AS source_line_account_type, ARRAY_AGG(counterpart_move.reversed_entry_id) FILTER (WHERE counterpart_move.reversed_entry_id IS NOT NULL) AS counterpart_reversed_entry_ids, ARRAY_AGG(counterpart_move.move_type) @@ -1586,7 +1586,6 @@ def _compute_amount(self): FROM account_partial_reconcile part JOIN account_move_line source_line ON source_line.id = part.{source_field}_move_id JOIN account_account account ON account.id = source_line.account_id - JOIN account_account_type account_type ON account_type.id = account.user_type_id JOIN account_move_line counterpart_line ON counterpart_line.id = part.{counterpart_field}_move_id JOIN account_move counterpart_move ON counterpart_move.id = counterpart_line.move_id LEFT JOIN account_payment pay ON pay.id = counterpart_move.payment_id @@ -1639,7 +1638,7 @@ def _compute_amount(self): total_tax_currency += line.amount_currency total += line.balance total_currency += line.amount_currency - elif line.account_id.user_type_id.type in ('receivable', 'payable') and move.state == 'posted': + elif line.account_id.account_type in ('asset_receivable', 'liability_payable') and move.state == 'posted': # Residual amount. total_to_pay += line.balance total_residual += line.amount_residual @@ -1672,7 +1671,7 @@ def _compute_amount(self): # Restrict on 'receivable'/'payable' lines for invoices/expense entries. if payment_state_matters: - reconciliation_vals = [x for x in reconciliation_vals if x['source_line_account_type'] in ('receivable', 'payable')] + reconciliation_vals = [x for x in reconciliation_vals if x['source_line_account_type'] in ('asset_receivable', 'liability_payable')] new_pmt_state = 'not_paid' if move.state == 'posted': @@ -1751,7 +1750,7 @@ def _compute_payments_widget_to_reconcile_info(self): continue pay_term_lines = move.line_ids\ - .filtered(lambda line: line.account_id.user_type_id.type in ('receivable', 'payable')) + .filtered(lambda line: line.account_id.account_type in ('asset_receivable', 'liability_payable')) domain = [ ('account_id', 'in', pay_term_lines.account_id.ids), @@ -1897,7 +1896,7 @@ def _compute_tax_lock_date_message(self): else: move.tax_lock_date_message = False - @api.depends('line_ids.account_id.internal_type') + @api.depends('line_ids.account_id.account_type') def _compute_always_tax_exigible(self): for record in self: # We need to check is_invoice as well because always_tax_exigible is used to @@ -2426,7 +2425,7 @@ def _collect_tax_cash_basis_values(self): currencies = set() has_term_lines = False for line in self.line_ids: - if line.account_internal_type in ('receivable', 'payable'): + if line.account_type in ('asset_receivable', 'liability_payable'): sign = 1 if line.balance > 0.0 else -1 currencies.add(line.currency_id) @@ -2595,28 +2594,28 @@ def _get_move_display_name(self, show_ref=False): def _get_reconciled_payments(self): """Helper used to retrieve the reconciled payments on this journal entry""" - reconciled_lines = self.line_ids.filtered(lambda line: line.account_id.user_type_id.type in ('receivable', 'payable')) + reconciled_lines = self.line_ids.filtered(lambda line: line.account_id.account_type in ('asset_receivable', 'liability_payable')) reconciled_amls = reconciled_lines.mapped('matched_debit_ids.debit_move_id') + \ reconciled_lines.mapped('matched_credit_ids.credit_move_id') return reconciled_amls.move_id.payment_id def _get_reconciled_statement_lines(self): """Helper used to retrieve the reconciled payments on this journal entry""" - reconciled_lines = self.line_ids.filtered(lambda line: line.account_id.user_type_id.type in ('receivable', 'payable')) + reconciled_lines = self.line_ids.filtered(lambda line: line.account_id.account_type in ('asset_receivable', 'liability_payable')) reconciled_amls = reconciled_lines.mapped('matched_debit_ids.debit_move_id') + \ reconciled_lines.mapped('matched_credit_ids.credit_move_id') return reconciled_amls.move_id.statement_line_id def _get_reconciled_invoices(self): """Helper used to retrieve the reconciled payments on this journal entry""" - reconciled_lines = self.line_ids.filtered(lambda line: line.account_id.user_type_id.type in ('receivable', 'payable')) + reconciled_lines = self.line_ids.filtered(lambda line: line.account_id.account_type in ('asset_receivable', 'liability_payable')) reconciled_amls = reconciled_lines.mapped('matched_debit_ids.debit_move_id') + \ reconciled_lines.mapped('matched_credit_ids.credit_move_id') return reconciled_amls.move_id.filtered(lambda move: move.is_invoice(include_receipts=True)) def _get_all_reconciled_invoice_partials(self): self.ensure_one() - reconciled_lines = self.line_ids.filtered(lambda line: line.account_id.user_type_id.type in ('receivable', 'payable')) + reconciled_lines = self.line_ids.filtered(lambda line: line.account_id.account_type in ('asset_receivable', 'liability_payable')) if not reconciled_lines: return {} @@ -2698,7 +2697,7 @@ def _get_reconciled_invoices_partials(self): ''' self.ensure_one() pay_term_lines = self.line_ids\ - .filtered(lambda line: line.account_internal_type in ('receivable', 'payable')) + .filtered(lambda line: line.account_type in ('asset_receivable', 'liability_payable')) invoice_partials = [] exchange_diff_moves = [] @@ -2892,7 +2891,7 @@ def _reverse_moves(self, default_values_list=None, cancel=False): for line in (move.line_ids + reverse_move.line_ids).filtered(lambda l: not l.reconciled): group[(line.account_id, line.currency_id)].append(line.id) for (account, dummy), line_ids in group.items(): - if account.reconcile or account.internal_type == 'liquidity': + if account.reconcile or account.account_type in ('asset_cash', 'liability_credit_card'): self.env['account.move.line'].browse(line_ids).with_context(move_reverse_cancel=cancel).reconcile() return reverse_moves @@ -3066,7 +3065,7 @@ def _post(self, soft=True): 'payment_reference': move._get_invoice_computed_reference(), 'line_ids': [] } - for line in move.line_ids.filtered(lambda line: line.account_id.user_type_id.type in ('receivable', 'payable')): + for line in move.line_ids.filtered(lambda line: line.account_id.account_type in ('asset_receivable', 'liability_payable')): to_write['line_ids'].append((1, line.id, {'name': to_write['payment_reference']})) move.write(to_write) @@ -3701,8 +3700,8 @@ class AccountMoveLine(models.Model): domain="[('deprecated', '=', False), ('company_id', '=', 'company_id'),('is_off_balance', '=', False)]", check_company=True, tracking=True) - account_internal_type = fields.Selection(related='account_id.user_type_id.type', string="Internal Type", readonly=True) - account_internal_group = fields.Selection(related='account_id.user_type_id.internal_group', string="Internal Group", readonly=True) + account_type = fields.Selection(related='account_id.account_type', readonly=True) + account_internal_group = fields.Selection(related='account_id.internal_group', readonly=True) account_root_id = fields.Many2one(related='account_id.root_id', string="Account Root", store=True, readonly=True) sequence = fields.Integer(default=10) name = fields.Char(string='Label', tracking=True) @@ -4432,7 +4431,7 @@ def _compute_amount_residual(self): This amount will be 0 for fully reconciled lines or lines from a non-reconcilable account, the original line amount for unreconciled lines, and something in-between for partially reconciled lines. """ - need_residual_lines = self.filtered(lambda x: x.account_id.reconcile or x.account_id.internal_type == 'liquidity') + need_residual_lines = self.filtered(lambda x: x.account_id.reconcile or x.account_id.account_type in ('asset_cash', 'liability_credit_card')) stored_lines = need_residual_lines.filtered('id') if stored_lines: @@ -4590,7 +4589,6 @@ def _check_constrains_account_id_journal_id(self): account_currency = account.currency_id if account_currency and account_currency != line.company_currency_id and account_currency != line.currency_id: raise UserError(_('The account selected on your journal entry forces to provide a secondary currency. You should remove the secondary currency on the account.')) - if account.allowed_journal_ids and journal not in account.allowed_journal_ids: raise UserError(_('You cannot use this account (%s) in this journal, check the field \'Allowed Journals\' on the related account.', account.display_name)) @@ -4598,9 +4596,8 @@ def _check_constrains_account_id_journal_id(self): continue is_account_control_ok = not journal.account_control_ids or account in journal.account_control_ids - is_type_control_ok = not journal.type_control_ids or account.user_type_id in journal.type_control_ids - if not is_account_control_ok or not is_type_control_ok: + if not is_account_control_ok: raise UserError(_("You cannot use this account (%s) in this journal, check the section 'Control-Access' under " "tab 'Advanced Settings' on the related journal.", account.display_name)) @@ -4815,14 +4812,14 @@ def write(self, vals): # Check switching receivable / payable accounts. if account_to_write: - account_type = line.account_id.user_type_id.type + account_type = line.account_id.account_type if line.move_id.is_sale_document(include_receipts=True): - if (account_type == 'receivable' and account_to_write.user_type_id.type != account_type) \ - or (account_type != 'receivable' and account_to_write.user_type_id.type == 'receivable'): + if (account_type == 'asset_receivable' and account_to_write.account_type != account_type) \ + or (account_type != 'asset_receivable' and account_to_write.account_type == 'asset_receivable'): raise UserError(_("You can only set an account having the receivable type on payment terms lines for customer invoice.")) if line.move_id.is_purchase_document(include_receipts=True): - if (account_type == 'payable' and account_to_write.user_type_id.type != account_type) \ - or (account_type != 'payable' and account_to_write.user_type_id.type == 'payable'): + if (account_type == 'liability_payable' and account_to_write.account_type != account_type) \ + or (account_type != 'liability_payable' and account_to_write.account_type == 'liability_payable'): raise UserError(_("You can only set an account having the payable type on payment terms lines for vendor bill.")) # Tracking stuff can be skipped for perfs using tracking_disable context key @@ -5700,7 +5697,7 @@ def reconcile(self): for line in self: if line.reconciled: raise UserError(_("You are trying to reconcile some entries that are already reconciled.")) - if not line.account_id.reconcile and line.account_id.internal_type != 'liquidity': + if not line.account_id.reconcile and line.account_id.account_type not in ('asset_cash', 'liability_credit_card'): raise UserError(_("Account %s does not allow reconciliation. First change the configuration of this account to allow it.") % line.account_id.display_name) if line.move_id.state != 'posted': @@ -5745,7 +5742,7 @@ def reconcile(self): # ==== Create entries for cash basis taxes ==== - is_cash_basis_needed = account.user_type_id.type in ('receivable', 'payable') + is_cash_basis_needed = account.account_type in ('asset_receivable', 'liability_payable') if is_cash_basis_needed and not self._context.get('move_reverse_cancel'): tax_cash_basis_moves = partials._create_tax_cash_basis_moves() results['tax_cash_basis_moves'] = tax_cash_basis_moves @@ -5789,7 +5786,7 @@ def is_line_reconciled(line): ) # Exchange difference for cash basis entries. - is_cash_basis_needed = account.internal_type in ('receivable', 'payable') + is_cash_basis_needed = account.account_type in ('asset_receivable', 'liability_payable') if is_cash_basis_needed: involved_lines._add_exchange_difference_cash_basis_vals(exchange_diff_vals) @@ -5838,7 +5835,7 @@ def copy_data(self, default=None): for line, values in zip(self, res): # Don't copy the name of a payment term line. - if line.move_id.is_invoice() and line.account_id.user_type_id.type in ('receivable', 'payable'): + if line.move_id.is_invoice() and line.account_id.account_type in ('asset_receivable', 'liability_payable'): values['name'] = '' # Don't copy restricted fields of notes if line.display_type in ('line_section', 'line_note'): @@ -6007,7 +6004,7 @@ def _query_get(self, domain=None): domain += [(date_field, '<=', context['date_to'])] if context.get('date_from'): if not context.get('strict_range'): - domain += ['|', (date_field, '>=', context['date_from']), ('account_id.user_type_id.include_initial_balance', '=', True)] + domain += ['|', (date_field, '>=', context['date_from']), ('account_id.include_initial_balance', '=', True)] elif context.get('initial_bal'): domain += [(date_field, '<', context['date_from'])] else: diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py index 14168daeae6ed..4e1e400c4c902 100644 --- a/addons/account/models/account_payment.py +++ b/addons/account/models/account_payment.py @@ -111,7 +111,7 @@ def _get_default_journal(self): string='Destination Account', store=True, readonly=False, compute='_compute_destination_account_id', - domain="[('user_type_id.type', 'in', ('receivable', 'payable')), ('company_id', '=', company_id)]", + domain="[('account_type', 'in', ('asset_receivable', 'liability_payable')), ('company_id', '=', company_id)]", check_company=True) destination_journal_id = fields.Many2one( comodel_name='account.journal', @@ -186,7 +186,7 @@ def _seek_for_lines(self): for line in self.move_id.line_ids: if line.account_id in self._get_valid_liquidity_accounts(): liquidity_lines += line - elif line.account_id.internal_type in ('receivable', 'payable') or line.partner_id == line.company_id.partner_id: + elif line.account_id.account_type in ('asset_receivable', 'liability_payable') or line.partner_id == line.company_id.partner_id: counterpart_lines += line else: writeoff_lines += line @@ -531,7 +531,7 @@ def _compute_destination_account_id(self): else: pay.destination_account_id = self.env['account.account'].search([ ('company_id', '=', pay.company_id.id), - ('internal_type', '=', 'receivable'), + ('account_type', '=', 'asset_receivable'), ('deprecated', '=', False), ], limit=1) elif pay.partner_type == 'supplier': @@ -541,7 +541,7 @@ def _compute_destination_account_id(self): else: pay.destination_account_id = self.env['account.account'].search([ ('company_id', '=', pay.company_id.id), - ('internal_type', '=', 'payable'), + ('account_type', '=', 'liability_payable'), ('deprecated', '=', False), ], limit=1) @@ -608,7 +608,7 @@ def _compute_stat_buttons_from_reconciliation(self): part.credit_move_id = counterpart_line.id JOIN account_move invoice ON invoice.id = counterpart_line.move_id JOIN account_account account ON account.id = line.account_id - WHERE account.internal_type IN ('receivable', 'payable') + WHERE account.account_type IN ('asset_receivable', 'liability_payable') AND payment.id IN %(payment_ids)s AND line.id != counterpart_line.id AND invoice.move_type in ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt') @@ -827,7 +827,7 @@ def _synchronize_from_moves(self, changed_fields): move.display_name, )) - if counterpart_lines.account_id.user_type_id.type == 'receivable': + if counterpart_lines.account_id.account_type == 'asset_receivable': partner_type = 'customer' else: partner_type = 'supplier' diff --git a/addons/account/models/account_payment_method.py b/addons/account/models/account_payment_method.py index 2e421dd5bd5d2..16577338b8031 100644 --- a/addons/account/models/account_payment_method.py +++ b/addons/account/models/account_payment_method.py @@ -99,11 +99,10 @@ class AccountPaymentMethodLine(models.Model): check_company=True, copy=False, ondelete='restrict', - domain=lambda self: "[('deprecated', '=', False), " - "('company_id', '=', company_id), " - "('user_type_id.type', 'not in', ('receivable', 'payable')), " - "'|', ('user_type_id', '=', %s), ('id', '=', parent.default_account_id)]" - % self.env.ref('account.data_account_type_current_assets').id + domain="[('deprecated', '=', False), " + "('company_id', '=', company_id), " + "('account_type', 'not in', ('asset_receivable', 'liability_payable')), " + "'|', ('account_type', '=', 'asset_current'), ('id', '=', parent.default_account_id)]" ) journal_id = fields.Many2one(comodel_name='account.journal', ondelete="cascade") @@ -159,7 +158,7 @@ def _auto_toggle_account_to_reconcile(self, account_id): :param account_id: The id of an account.account. """ account = self.env['account.account'].browse(account_id) - if not account.reconcile and account.internal_type != 'liquidity' and account.internal_group != 'off_balance': + if not account.reconcile and account.account_type not in ('asset_cash', 'liability_credit_card') and account.internal_group != 'off_balance': account.reconcile = True @api.model_create_multi diff --git a/addons/account/models/account_tax.py b/addons/account/models/account_tax.py index 65b1a4ae93125..8eaa8e193e141 100644 --- a/addons/account/models/account_tax.py +++ b/addons/account/models/account_tax.py @@ -1171,7 +1171,7 @@ class AccountTaxRepartitionLine(models.Model): repartition_type = fields.Selection(string="Based On", selection=[('base', 'Base'), ('tax', 'of tax')], required=True, default='tax', help="Base on which the factor will be applied.") account_id = fields.Many2one(string="Account", comodel_name='account.account', - domain="[('deprecated', '=', False), ('company_id', '=', company_id), ('internal_type', 'not in', ('receivable', 'payable'))]", + domain="[('deprecated', '=', False), ('company_id', '=', company_id), ('account_type', 'not in', ('asset_receivable', 'liability_payable'))]", check_company=True, help="Account on which to post the tax amount") tag_ids = fields.Many2many(string="Tax Grids", comodel_name='account.account.tag', domain=[('applicability', '=', 'taxes')], copy=True) diff --git a/addons/account/models/chart_template.py b/addons/account/models/chart_template.py index 41b728af59b09..a95f2b395c0bf 100644 --- a/addons/account/models/chart_template.py +++ b/addons/account/models/chart_template.py @@ -56,9 +56,31 @@ class AccountAccountTemplate(models.Model): name = fields.Char(required=True) currency_id = fields.Many2one('res.currency', string='Account Currency', help="Forces all moves for this account to have this secondary currency.") code = fields.Char(size=64, required=True) - user_type_id = fields.Many2one('account.account.type', string='Type', required=True, + account_type = fields.Selection( + selection=[ + ("asset_receivable", "Receivable"), + ("asset_cash", "Bank and Cash"), + ("asset_current", "Current Assets"), + ("asset_non_current", "Non-current Assets"), + ("asset_prepayments", "Prepayments"), + ("asset_fixed", "Fixed Assets"), + ("liability_payable", "Payable"), + ("liability_credit_card", "Credit Card"), + ("liability_current", "Current Liabilities"), + ("liability_non_current", "Non-current Liabilities"), + ("equity", "Equity"), + ("equity_unaffected", "Current Year Earnings"), + ("income", "Income"), + ("income_other", "Other Income"), + ("expense", "Expenses"), + ("expense_depreciation", "Depreciation"), + ("expense_direct_cost", "Cost of Revenue"), + ("off_balance", "Off-Balance Sheet"), + ], + string="Type", help="These types are defined according to your country. The type contains more information "\ - "about the account and its specificities.") + "about the account and its specificities." + ) reconcile = fields.Boolean(string='Allow Invoices & payments Matching', default=False, help="Check this option if you want the user to reconcile entries in this account.") note = fields.Text() @@ -101,9 +123,9 @@ class AccountChartTemplate(models.Model): cash_account_code_prefix = fields.Char(string='Prefix of the main cash accounts', required=True) transfer_account_code_prefix = fields.Char(string='Prefix of the main transfer accounts', required=True) income_currency_exchange_account_id = fields.Many2one('account.account.template', - string="Gain Exchange Rate Account", domain=[('internal_type', '=', 'other'), ('deprecated', '=', False)]) + string="Gain Exchange Rate Account", domain=[('account_type', 'not in', ('asset_receivable', 'liability_payable', 'asset_cash', 'liability_credit_card')), ('deprecated', '=', False)]) expense_currency_exchange_account_id = fields.Many2one('account.account.template', - string="Loss Exchange Rate Account", domain=[('internal_type', '=', 'other'), ('deprecated', '=', False)]) + string="Loss Exchange Rate Account", domain=[('account_type', 'not in', ('asset_receivable', 'liability_payable', 'asset_cash', 'liability_credit_card')), ('deprecated', '=', False)]) country_id = fields.Many2one(string="Country", comodel_name='res.country', help="The country this chart of accounts belongs to. None if it's generic.") account_journal_suspense_account_id = fields.Many2one('account.account.template', string='Journal Suspense Account') @@ -157,11 +179,11 @@ def _prepare_transfer_account_template(self, prefix=None): break else: raise UserError(_('Cannot generate an unused account code.')) - current_assets_type = self.env.ref('account.data_account_type_current_assets', raise_if_not_found=False) + return { 'name': _('Liquidity Transfer'), 'code': new_code, - 'user_type_id': current_assets_type and current_assets_type.id or False, + 'account_type': 'asset_current', 'reconcile': True, 'chart_template_id': self.id, } @@ -171,7 +193,7 @@ def _create_liquidity_journal_suspense_account(self, company, code_digits): return self.env['account.account'].create({ 'name': _("Bank Suspense Account"), 'code': self.env['account.account']._search_new_account_code(company, code_digits, company.bank_account_code_prefix or ''), - 'user_type_id': self.env.ref('account.data_account_type_current_assets').id, + 'account_type': 'asset_current', 'company_id': company.id, }) @@ -289,13 +311,12 @@ def _load(self, company): if not company.account_journal_suspense_account_id: company.account_journal_suspense_account_id = self._create_liquidity_journal_suspense_account(company, self.code_digits) - account_type_current_assets = self.env.ref('account.data_account_type_current_assets') if not company.account_journal_payment_debit_account_id: company.account_journal_payment_debit_account_id = self.env['account.account'].create({ 'name': _("Outstanding Receipts"), 'code': self.env['account.account']._search_new_account_code(company, self.code_digits, company.bank_account_code_prefix or ''), 'reconcile': True, - 'user_type_id': account_type_current_assets.id, + 'account_type': 'asset_current', 'company_id': company.id, }) @@ -304,7 +325,7 @@ def _load(self, company): 'name': _("Outstanding Payments"), 'code': self.env['account.account']._search_new_account_code(company, self.code_digits, company.bank_account_code_prefix or ''), 'reconcile': True, - 'user_type_id': account_type_current_assets.id, + 'account_type': 'asset_current', 'company_id': company.id, }) @@ -312,7 +333,7 @@ def _load(self, company): company.default_cash_difference_expense_account_id = self.env['account.account'].create({ 'name': _('Cash Difference Loss'), 'code': self.env['account.account']._search_new_account_code(company, self.code_digits, '999'), - 'user_type_id': self.env.ref('account.data_account_type_expenses').id, + 'account_type': 'expense', 'tag_ids': [(6, 0, self.env.ref('account.account_tag_investing').ids)], 'company_id': company.id, }) @@ -321,7 +342,7 @@ def _load(self, company): company.default_cash_difference_income_account_id = self.env['account.account'].create({ 'name': _('Cash Difference Gain'), 'code': self.env['account.account']._search_new_account_code(company, self.code_digits, '999'), - 'user_type_id': self.env.ref('account.data_account_type_revenue').id, + 'account_type': 'income', 'tag_ids': [(6, 0, self.env.ref('account.account_tag_investing').ids)], 'company_id': company.id, }) @@ -662,7 +683,7 @@ def _get_account_vals(self, company, account_template, code_acc, tax_template_re 'name': account_template.name, 'currency_id': account_template.currency_id and account_template.currency_id.id or False, 'code': code_acc, - 'user_type_id': account_template.user_type_id and account_template.user_type_id.id or False, + 'account_type': account_template.account_type or False, 'reconcile': account_template.reconcile, 'note': account_template.note, 'tax_ids': [(6, 0, tax_ids)], @@ -935,7 +956,7 @@ def create_foreign_tax_account(existing_account, additional_label): return self.env['account.account'].create({ 'name': f"{existing_account.name} - {additional_label}", 'code': new_code, - 'user_type_id': existing_account.user_type_id.id, + 'account_type': existing_account.account_type, 'company_id': existing_account.company_id.id, }) @@ -1203,11 +1224,11 @@ def create(self, vals_list): vals['tag_ids'] = self._convert_tag_syntax_to_orm(vals['tag_ids']) if vals.get('use_in_tax_closing') is None: - if not vals.get('account_id'): - vals['use_in_tax_closing'] = False - else: - internal_group = self.env['account.account.template'].browse(vals.get('account_id')).user_type_id.internal_group - vals['use_in_tax_closing'] = not (internal_group == 'income' or internal_group == 'expense') + vals['use_in_tax_closing'] = False + if vals.get('account_id'): + account_type = self.env['account.account.template'].browse(vals.get('account_id')).account_type + if account_type: + vals['use_in_tax_closing'] = not (account_type.startswith('income') or account_type.startswith('expense')) return super().create(vals_list) diff --git a/addons/account/models/company.py b/addons/account/models/company.py index d351cf168d10f..bce2c38c0f8a6 100644 --- a/addons/account/models/company.py +++ b/addons/account/models/company.py @@ -57,7 +57,7 @@ class ResCompany(models.Model): tracking=True, help="No users can edit journal entries related to a tax prior and inclusive of this date.") transfer_account_id = fields.Many2one('account.account', - domain=lambda self: [('reconcile', '=', True), ('user_type_id', '=', self.env.ref('account.data_account_type_current_assets').id), ('deprecated', '=', False)], string="Inter-Banks Transfer Account", help="Intermediary account used when moving money from a liquidity account to another") + domain="[('reconcile', '=', True), ('account_type', '=', 'asset_current'), ('deprecated', '=', False)]", string="Inter-Banks Transfer Account", help="Intermediary account used when moving money from a liqity account to another") expects_chart_of_accounts = fields.Boolean(string='Expects a Chart of Accounts', default=True) chart_template_id = fields.Many2one('account.chart.template', help='The chart template for the company (if any)') bank_account_code_prefix = fields.Char(string='Prefix of the bank accounts') @@ -78,14 +78,13 @@ class ResCompany(models.Model): income_currency_exchange_account_id = fields.Many2one( comodel_name='account.account', string="Gain Exchange Rate Account", - domain=lambda self: "[('internal_type', '=', 'other'), ('deprecated', '=', False), ('company_id', '=', id), \ - ('user_type_id', 'in', %s)]" % [self.env.ref('account.data_account_type_revenue').id, - self.env.ref('account.data_account_type_other_income').id]) + domain="[('account_type', 'not in', ('asset_receivable','liability_payable','asset_cash', 'liability_credit_card')), ('deprecated', '=', False), ('company_id', '=', id), \ + ('account_type', 'in', ('income', 'income_other'))]") expense_currency_exchange_account_id = fields.Many2one( comodel_name='account.account', string="Loss Exchange Rate Account", - domain=lambda self: "[('internal_type', '=', 'other'), ('deprecated', '=', False), ('company_id', '=', id), \ - ('user_type_id', '=', %s)]" % self.env.ref('account.data_account_type_expenses').id) + domain="[('account_type', 'not in', ('asset_receivable','liability_payable','asset_cash', 'liability_credit_card')), ('deprecated', '=', False), ('company_id', '=', id), \ + ('account_type', '=', 'expense')]") anglo_saxon_accounting = fields.Boolean(string="Use anglo-saxon accounting") property_stock_account_input_categ_id = fields.Many2one('account.account', string="Input Account for Stock Valuation") property_stock_account_output_categ_id = fields.Many2one('account.account', string="Output Account for Stock Valuation") @@ -132,10 +131,10 @@ class ResCompany(models.Model): # Accrual Accounting expense_accrual_account_id = fields.Many2one('account.account', help="Account used to move the period of an expense", - domain="[('internal_group', '=', 'liability'), ('internal_type', 'not in', ('receivable', 'payable')), ('company_id', '=', id)]") + domain="[('internal_group', '=', 'liability'), ('account_type', 'not in', ('asset_receivable', 'liability_payable')), ('company_id', '=', id)]") revenue_accrual_account_id = fields.Many2one('account.account', help="Account used to move the period of a revenue", - domain="[('internal_group', '=', 'asset'), ('internal_type', 'not in', ('receivable', 'payable')), ('company_id', '=', id)]") + domain="[('internal_group', '=', 'asset'), ('account_type', 'not in', ('asset_receivable', 'liability_payable')), ('company_id', '=', id)]") automatic_entry_default_journal_id = fields.Many2one('account.journal', help="Journal used by default for moving the period of an entry", domain="[('type', '=', 'general')]") # Technical field to hide country specific fields in company form view @@ -256,7 +255,7 @@ def get_new_account_code(self, current_code, old_prefix, new_prefix): return new_prefix + current_code.replace(old_prefix, '', 1).lstrip('0').rjust(digits-len(new_prefix), '0') def reflect_code_prefix_change(self, old_code, new_code): - accounts = self.env['account.account'].search([('code', 'like', old_code), ('internal_type', '=', 'liquidity'), + accounts = self.env['account.account'].search([('code', 'like', old_code), ('account_type', 'in', ('asset_cash', 'liability_credit_card')), ('company_id', '=', self.id)], order='code asc') for account in accounts: if account.code.startswith(old_code): @@ -395,7 +394,7 @@ def setting_chart_of_accounts_action(self): # Then, we open will open a custom tree view allowing to edit opening balances of the account view_id = self.env.ref('account.init_accounts_tree').id # Hide the current year earnings account as it is automatically computed - domain = [('user_type_id', '!=', self.env.ref('account.data_unaffected_earnings').id), ('company_id','=', company.id)] + domain = [('account_type', '!=', 'equity_unaffected'), ('company_id', '=', company.id)] return { 'type': 'ir.actions.act_window', 'name': _('Chart of Accounts'), @@ -437,9 +436,9 @@ def get_unaffected_earnings_account(self): """ Returns the unaffected earnings account for this company, creating one if none has yet been defined. """ - unaffected_earnings_type = self.env.ref("account.data_unaffected_earnings") + unaffected_earnings_type = "equity_unaffected" account = self.env['account.account'].search([('company_id', '=', self.id), - ('user_type_id', '=', unaffected_earnings_type.id)]) + ('account_type', '=', unaffected_earnings_type)]) if account: return account[0] # Do not assume '999999' doesn't exist since the user might have created such an account @@ -450,7 +449,7 @@ def get_unaffected_earnings_account(self): return self.env['account.account'].create({ 'code': str(code), 'name': _('Undistributed Profits/Losses'), - 'user_type_id': unaffected_earnings_type.id, + 'account_type': unaffected_earnings_type, 'company_id': self.id, }) diff --git a/addons/account/models/partner.py b/addons/account/models/partner.py index bbbd1b4235a70..651f4ba0aa711 100644 --- a/addons/account/models/partner.py +++ b/addons/account/models/partner.py @@ -308,25 +308,24 @@ def _credit_debit_get(self): where_params = [tuple(self.ids)] + where_params if where_clause: where_clause = 'AND ' + where_clause - self._cr.execute("""SELECT account_move_line.partner_id, act.type, SUM(account_move_line.amount_residual) + self._cr.execute("""SELECT account_move_line.partner_id, a.account_type, SUM(account_move_line.amount_residual) FROM """ + tables + """ LEFT JOIN account_account a ON (account_move_line.account_id=a.id) - LEFT JOIN account_account_type act ON (a.user_type_id=act.id) - WHERE act.type IN ('receivable','payable') + WHERE a.account_type IN ('asset_receivable','liability_payable') AND account_move_line.partner_id IN %s AND account_move_line.reconciled IS NOT TRUE """ + where_clause + """ - GROUP BY account_move_line.partner_id, act.type + GROUP BY account_move_line.partner_id, a.account_type """, where_params) treated = self.browse() for pid, type, val in self._cr.fetchall(): partner = self.browse(pid) - if type == 'receivable': + if type == 'asset_receivable': partner.credit = val if partner not in treated: partner.debit = False treated |= partner - elif type == 'payable': + elif type == 'liability_payable': partner.debit = -val if partner not in treated: partner.credit = False @@ -341,7 +340,7 @@ def _asset_difference_search(self, account_type, operator, operand): if type(operand) not in (float, int): return [] sign = 1 - if account_type == 'payable': + if account_type == 'liability_payable': sign = -1 res = self._cr.execute(''' SELECT partner.id @@ -349,7 +348,7 @@ def _asset_difference_search(self, account_type, operator, operand): LEFT JOIN account_move_line aml ON aml.partner_id = partner.id JOIN account_move move ON move.id = aml.move_id RIGHT JOIN account_account acc ON aml.account_id = acc.id - WHERE acc.internal_type = %s + WHERE acc.account_type = %s AND NOT acc.deprecated AND acc.company_id = %s AND move.state = 'posted' GROUP BY partner.id @@ -361,11 +360,11 @@ def _asset_difference_search(self, account_type, operator, operand): @api.model def _credit_search(self, operator, operand): - return self._asset_difference_search('receivable', operator, operand) + return self._asset_difference_search('asset_receivable', operator, operand) @api.model def _debit_search(self, operator, operand): - return self._asset_difference_search('payable', operator, operand) + return self._asset_difference_search('liability_payable', operator, operand) def _invoice_total(self): self.total_invoiced = 0 @@ -466,12 +465,12 @@ def _get_company_currency(self): journal_item_count = fields.Integer(compute='_compute_journal_item_count', string="Journal Items") property_account_payable_id = fields.Many2one('account.account', company_dependent=True, string="Account Payable", - domain="[('internal_type', '=', 'payable'), ('deprecated', '=', False), ('company_id', '=', current_company_id)]", + domain="[('account_type', '=', 'liability_payable'), ('deprecated', '=', False), ('company_id', '=', current_company_id)]", help="This account will be used instead of the default one as the payable account for the current partner", required=True) property_account_receivable_id = fields.Many2one('account.account', company_dependent=True, string="Account Receivable", - domain="[('internal_type', '=', 'receivable'), ('deprecated', '=', False), ('company_id', '=', current_company_id)]", + domain="[('account_type', '=', 'asset_receivable'), ('deprecated', '=', False), ('company_id', '=', current_company_id)]", help="This account will be used instead of the default one as the receivable account for the current partner", required=True) property_account_position_id = fields.Many2one('account.fiscal.position', company_dependent=True, diff --git a/addons/account/models/product.py b/addons/account/models/product.py index 34b0a85adf429..8e55e57ef0e33 100644 --- a/addons/account/models/product.py +++ b/addons/account/models/product.py @@ -3,7 +3,7 @@ from odoo import api, fields, models, _ from odoo.tools import format_amount -ACCOUNT_DOMAIN = "['&', '&', '&', ('deprecated', '=', False), ('internal_type','=','other'), ('company_id', '=', current_company_id), ('is_off_balance', '=', False)]" +ACCOUNT_DOMAIN = "['&', '&', '&', ('deprecated', '=', False), ('account_type', 'not in', ('asset_receivable','liability_payable','asset_cash','liability_credit_card')), ('company_id', '=', current_company_id), ('is_off_balance', '=', False)]" class ProductCategory(models.Model): _inherit = "product.category" diff --git a/addons/account/models/res_config_settings.py b/addons/account/models/res_config_settings.py index a6380c54c7e0b..54cd92d49787f 100644 --- a/addons/account/models/res_config_settings.py +++ b/addons/account/models/res_config_settings.py @@ -21,16 +21,15 @@ class ResConfigSettings(models.TransientModel): related="company_id.income_currency_exchange_account_id", string="Gain Account", readonly=False, - domain=lambda self: "[('internal_type', '=', 'other'), ('deprecated', '=', False), ('company_id', '=', company_id),\ - ('user_type_id', 'in', %s)]" % [self.env.ref('account.data_account_type_revenue').id, - self.env.ref('account.data_account_type_other_income').id]) + domain="[('account_type', 'not in', ('asset_receivable','liability_payable','asset_cash','liability_credit_card')), ('deprecated', '=', False), ('company_id', '=', company_id),\ + ('account_type', 'in', ('income', 'income_other'))]") expense_currency_exchange_account_id = fields.Many2one( comodel_name="account.account", related="company_id.expense_currency_exchange_account_id", string="Loss Account", readonly=False, - domain=lambda self: "[('internal_type', '=', 'other'), ('deprecated', '=', False), ('company_id', '=', company_id),\ - ('user_type_id', '=', %s)]" % self.env.ref('account.data_account_type_expenses').id) + domain="[('account_type', 'not in', ('asset_receivable','liability_payable','asset_cash','liability_credit_card')), ('deprecated', '=', False), ('company_id', '=', company_id),\ + ('account_type', '=', 'expense')]") has_chart_of_accounts = fields.Boolean(compute='_compute_has_chart_of_accounts', string='Company has a chart of accounts') chart_template_id = fields.Many2one('account.chart.template', string='Template', default=lambda self: self.env.company.chart_template_id, domain="[('visible','=', True)]") @@ -43,7 +42,7 @@ class ResConfigSettings(models.TransientModel): string='Bank Suspense Account', readonly=False, related='company_id.account_journal_suspense_account_id', - domain=lambda self: "[('deprecated', '=', False), ('company_id', '=', company_id), ('user_type_id.type', 'not in', ('receivable', 'payable')), ('user_type_id', 'in', %s)]" % [self.env.ref('account.data_account_type_current_assets').id, self.env.ref('account.data_account_type_current_liabilities').id], + domain="[('deprecated', '=', False), ('company_id', '=', company_id), ('account_type', 'not in', ('asset_receivable', 'liability_payable')), ('account_type', 'in', ('asset_current', 'liability_current'))]", help='Bank Transactions are posted immediately after import or synchronization. ' 'Their counterparty is the bank suspense account.\n' 'Reconciliation replaces the latter by the definitive account(s).') @@ -52,7 +51,7 @@ class ResConfigSettings(models.TransientModel): string='Outstanding Receipts Account', readonly=False, related='company_id.account_journal_payment_debit_account_id', - domain=lambda self: "[('deprecated', '=', False), ('company_id', '=', company_id), ('user_type_id.type', 'not in', ('receivable', 'payable')), ('user_type_id', '=', %s)]" % self.env.ref('account.data_account_type_current_assets').id, + domain="[('deprecated', '=', False), ('company_id', '=', company_id), ('account_type', 'not in', ('asset_receivable', 'liability_payable')), ('account_type', '=', 'asset_current')]", help='Incoming payments are posted on an Outstanding Receipts Account. ' 'In the bank reconciliation widget, they appear as blue lines.\n' 'Bank transactions are then reconciled on the Outstanding Receipts Accounts rather than the Receivable ' @@ -62,13 +61,13 @@ class ResConfigSettings(models.TransientModel): string='Outstanding Payments Account', readonly=False, related='company_id.account_journal_payment_credit_account_id', - domain=lambda self: "[('deprecated', '=', False), ('company_id', '=', company_id), ('user_type_id.type', 'not in', ('receivable', 'payable')), ('user_type_id', '=', %s)]" % self.env.ref('account.data_account_type_current_assets').id, + domain="[('deprecated', '=', False), ('company_id', '=', company_id), ('account_type', 'not in', ('asset_receivable', 'liability_payable')), ('account_type', '=', 'asset_current')]", help='Outgoing Payments are posted on an Outstanding Payments Account. ' 'In the bank reconciliation widget, they appear as blue lines.\n' 'Bank transactions are then reconciled on the Outstanding Payments Account rather the Payable Account.') transfer_account_id = fields.Many2one('account.account', string="Internal Transfer Account", related='company_id.transfer_account_id', readonly=False, - domain=lambda self: [('reconcile', '=', True), ('user_type_id', '=', self.env.ref('account.data_account_type_current_assets').id)], + domain="[('reconcile', '=', True), ('account_type', '=', 'asset_current')]", help="Intermediary account used when moving from a liquidity account to another.") module_account_accountant = fields.Boolean(string='Accounting') group_analytic_tags = fields.Boolean(string='Analytic Tags', implied_group='analytic.group_analytic_tags') diff --git a/addons/account/populate/account_move.py b/addons/account/populate/account_move.py index df43df5200f42..d58a68eca9826 100644 --- a/addons/account/populate/account_move.py +++ b/addons/account/populate/account_move.py @@ -30,7 +30,7 @@ class AccountMove(models.Model): def _populate_factories(self): @lru_cache() - def search_account_ids(company_id, type=None, group=None): + def search_account_ids(company_id, types=None, group=None): """Search all the accounts of a certain type and group for a company. This method is cached, only one search is done per tuple(company_id, type, group). @@ -42,8 +42,8 @@ def search_account_ids(company_id, type=None, group=None): :return (Model): the recordset of accounts found. """ domain = [('company_id', '=', company_id)] - if type: - domain += [('internal_type', '=', type)] + if types: + domain += [('account_type', 'in', types)] if group: domain += [('internal_group', '=', group)] return self.env['account.account'].search(domain) @@ -116,15 +116,31 @@ def get_line(account, label, balance=None, balance_sign=False, exclude_from_invo currency_id = values['currency_id'] partner_id = values['partner_id'] + other_type = ( + 'asset_current', + 'asset_non_current', + 'asset_prepayments', + 'asset_fixed', + 'liability_current', + 'liability_non_current', + 'equity', + 'equity_unaffected', + 'income', + 'income_other', + 'expense', + 'expense_depreciation', + 'expense_direct_cost', + 'off_balance', + ) # Determine the right sets of accounts depending on the move_type if move_type in self.get_sale_types(include_receipts=True): - account_ids = search_account_ids(company_id, 'other', 'income') - balance_account_ids = search_account_ids(company_id, 'receivable', 'asset') + account_ids = search_account_ids(company_id, other_type, 'income') + balance_account_ids = search_account_ids(company_id, ('asset_receivable',), 'asset') elif move_type in self.get_purchase_types(include_receipts=True): - account_ids = search_account_ids(company_id, 'other', 'expense') - balance_account_ids = search_account_ids(company_id, 'payable', 'liability') + account_ids = search_account_ids(company_id, other_type, 'expense') + balance_account_ids = search_account_ids(company_id, ('liability_payable',), 'liability') else: - account_ids = search_account_ids(company_id, 'other', 'asset') + account_ids = search_account_ids(company_id, other_type, 'asset') balance_account_ids = account_ids # Determine the right balance sign depending on the move_type diff --git a/addons/account/populate/account_reconcile_model.py b/addons/account/populate/account_reconcile_model.py index 0c4cebfd03a29..b931cbeb30b36 100644 --- a/addons/account/populate/account_reconcile_model.py +++ b/addons/account/populate/account_reconcile_model.py @@ -64,7 +64,7 @@ def search_account_ids(company_id, type=None, group=None): """ domain = [('company_id', '=', company_id)] if type: - domain += [('internal_type', '=', type)] + domain += [('account_type', '=', type)] if group: domain += [('internal_group', '=', group)] return self.env['account.account'].search(domain) diff --git a/addons/account/report/account_invoice_report.py b/addons/account/report/account_invoice_report.py index 2f4c2ad53db3b..f175d5a63d97f 100644 --- a/addons/account/report/account_invoice_report.py +++ b/addons/account/report/account_invoice_report.py @@ -86,6 +86,7 @@ def _select(self): line.company_id, line.company_currency_id, line.partner_id AS commercial_partner_id, + account.account_type AS user_type, move.state, move.move_type, move.partner_id, @@ -116,7 +117,6 @@ def _from(self): LEFT JOIN res_partner partner ON partner.id = line.partner_id LEFT JOIN product_product product ON product.id = line.product_id LEFT JOIN account_account account ON account.id = line.account_id - LEFT JOIN account_account_type user_type ON user_type.id = account.user_type_id LEFT JOIN product_template template ON template.id = product.product_tmpl_id LEFT JOIN uom_uom uom_line ON uom_line.id = line.product_uom_id LEFT JOIN uom_uom uom_template ON uom_template.id = template.uom_id diff --git a/addons/account/security/ir.model.access.csv b/addons/account/security/ir.model.access.csv index 3b3b28a637026..c50cc1e4e7a0d 100644 --- a/addons/account/security/ir.model.access.csv +++ b/addons/account/security/ir.model.access.csv @@ -74,8 +74,6 @@ access_account_account,account.account.readonly,model_account_account,account.gr access_account_account_user,account.account user,model_account_account,base.group_user,1,0,0,0 access_account_account_partner_manager,account.account partner manager,model_account_account,base.group_partner_manager,1,0,0,0 access_account_account_invoice,account.account invoice,model_account_account,account.group_account_invoice,1,0,0,0 -access_account_account_type_readonly,account.account.type readonly,model_account_account_type,account.group_account_readonly,1,0,0,0 -access_account_account_type_invoice,account.account.type invoice,model_account_account_type,account.group_account_invoice,1,0,0,0 access_account_tax_internal_user,account.tax internal user,model_account_tax,base.group_user,1,0,0,0 access_account_tax_readonly,account.tax,model_account_tax,account.group_account_readonly,1,0,0,0 diff --git a/addons/account/tests/common.py b/addons/account/tests/common.py index 6ae2a249630ca..dbb8d99a9b4b7 100644 --- a/addons/account/tests/common.py +++ b/addons/account/tests/common.py @@ -224,22 +224,22 @@ def search_account(company, chart_template, field_name, domain): 'currency': company.currency_id, 'default_account_revenue': cls.env['account.account'].search([ ('company_id', '=', company.id), - ('user_type_id', '=', cls.env.ref('account.data_account_type_revenue').id) + ('account_type', '=', 'income') ], limit=1), 'default_account_expense': cls.env['account.account'].search([ ('company_id', '=', company.id), - ('user_type_id', '=', cls.env.ref('account.data_account_type_expenses').id) + ('account_type', '=', 'expense') ], limit=1), 'default_account_receivable': search_account(company, chart_template, 'property_account_receivable_id', [ - ('user_type_id.type', '=', 'receivable') + ('account_type', '=', 'asset_receivable') ]), 'default_account_payable': cls.env['account.account'].search([ ('company_id', '=', company.id), - ('user_type_id.type', '=', 'payable') + ('account_type', '=', 'liability_payable') ], limit=1), 'default_account_assets': cls.env['account.account'].search([ ('company_id', '=', company.id), - ('user_type_id', '=', cls.env.ref('account.data_account_type_current_assets').id) + ('account_type', '=', 'asset_current') ], limit=1), 'default_account_tax_sale': company.account_sale_tax_id.mapped('invoice_repartition_line_ids.account_id'), 'default_account_tax_purchase': company.account_purchase_tax_id.mapped('invoice_repartition_line_ids.account_id'), @@ -602,7 +602,7 @@ def setUpClass(cls, chart_template_ref=None): cls.tax_waiting_account = cls.env['account.account'].create({ 'name': 'TAX_WAIT', 'code': 'TWAIT', - 'user_type_id': cls.env.ref('account.data_account_type_current_liabilities').id, + 'account_type': 'liability_current', 'reconcile': True, 'company_id': cls.company.id, }) @@ -610,13 +610,13 @@ def setUpClass(cls, chart_template_ref=None): cls.tax_final_account = cls.env['account.account'].create({ 'name': 'TAX_TO_DEDUCT', 'code': 'TDEDUCT', - 'user_type_id': cls.env.ref('account.data_account_type_current_assets').id, + 'account_type': 'asset_current', 'company_id': cls.company.id, }) cls.tax_base_amount_account = cls.env['account.account'].create({ 'name': 'TAX_BASE', 'code': 'TBASE', - 'user_type_id': cls.env.ref('account.data_account_type_current_assets').id, + 'account_type': 'asset_current', 'company_id': cls.company.id, }) cls.company.account_cash_basis_base_account_id = cls.tax_base_amount_account.id diff --git a/addons/account/tests/test_account_journal.py b/addons/account/tests/test_account_journal.py index fcd909da94345..daff0f410ff9f 100644 --- a/addons/account/tests/test_account_journal.py +++ b/addons/account/tests/test_account_journal.py @@ -60,38 +60,6 @@ def test_account_control_create_journal_entry(self): self.company_data['default_journal_misc'].account_control_ids |= self.company_data['default_account_expense'] self.env['account.move'].create(move_vals) - def test_default_account_type_control_create_journal_entry(self): - move_vals = { - 'line_ids': [ - (0, 0, { - 'name': 'debit', - 'account_id': self.company_data['default_account_revenue'].id, - 'debit': 100.0, - 'credit': 0.0, - }), - (0, 0, { - 'name': 'credit', - 'account_id': self.company_data['default_account_expense'].id, - 'debit': 0.0, - 'credit': 100.0, - }), - ], - } - - # Set the 'default_account_id' on the journal and make sure it will not raise an error, - # even if it is not explicitly included in the 'type_control_ids'. - self.company_data['default_journal_misc'].default_account_id = self.company_data['default_account_expense'].id - - # Should fail because 'default_account_revenue' type is not allowed. - self.company_data['default_journal_misc'].type_control_ids |= self.company_data['default_account_receivable'].user_type_id - with self.assertRaises(UserError), self.cr.savepoint(): - self.env['account.move'].create(move_vals) - - # Should pass because both account types are allowed. - # 'default_account_revenue' explicitly and 'default_account_expense' implicitly. - self.company_data['default_journal_misc'].type_control_ids |= self.company_data['default_account_revenue'].user_type_id - self.env['account.move'].create(move_vals) - def test_account_control_existing_journal_entry(self): self.env['account.move'].create({ 'line_ids': [ diff --git a/addons/account/tests/test_account_journal_dashboard.py b/addons/account/tests/test_account_journal_dashboard.py index 6bb127b672cb2..55cc85fc2d36f 100644 --- a/addons/account/tests/test_account_journal_dashboard.py +++ b/addons/account/tests/test_account_journal_dashboard.py @@ -69,7 +69,6 @@ def test_customer_invoice_dashboard(self): self.assertIn('68.42', dashboard_data['sum_waiting']) # Check partial - receivable_account = refund.line_ids.mapped('account_id').filtered(lambda a: a.internal_type == 'receivable') payment = self.env['account.payment'].create({ 'amount': 10.0, 'payment_type': 'outbound', @@ -79,7 +78,7 @@ def test_customer_invoice_dashboard(self): payment.action_post() (refund + payment.move_id).line_ids\ - .filtered(lambda line: line.account_internal_type == 'receivable')\ + .filtered(lambda line: line.account_type == 'asset_receivable')\ .reconcile() dashboard_data = journal.get_journal_dashboard_datas() diff --git a/addons/account/tests/test_account_move_entry.py b/addons/account/tests/test_account_move_entry.py index 82aba8a5e1068..49f02bd8b03a8 100644 --- a/addons/account/tests/test_account_move_entry.py +++ b/addons/account/tests/test_account_move_entry.py @@ -614,20 +614,20 @@ def test_invoice_like_entry_reverse_caba(self): tax_waiting_account = self.env['account.account'].create({ 'name': 'TAX_WAIT', 'code': 'TWAIT', - 'user_type_id': self.env.ref('account.data_account_type_current_liabilities').id, + 'account_type': 'liability_current', 'reconcile': True, 'company_id': self.company_data['company'].id, }) tax_final_account = self.env['account.account'].create({ 'name': 'TAX_TO_DEDUCT', 'code': 'TDEDUCT', - 'user_type_id': self.env.ref('account.data_account_type_current_assets').id, + 'account_type': 'asset_current', 'company_id': self.company_data['company'].id, }) tax_base_amount_account = self.env['account.account'].create({ 'name': 'TAX_BASE', 'code': 'TBASE', - 'user_type_id': self.env.ref('account.data_account_type_current_assets').id, + 'account_type': 'asset_current', 'company_id': self.company_data['company'].id, }) self.env.company.account_cash_basis_base_account_id = tax_base_amount_account diff --git a/addons/account/tests/test_account_move_in_invoice.py b/addons/account/tests/test_account_move_in_invoice.py index 897e7635c4683..cf6ecd566bb59 100644 --- a/addons/account/tests/test_account_move_in_invoice.py +++ b/addons/account/tests/test_account_move_in_invoice.py @@ -1820,13 +1820,13 @@ def test_in_invoice_change_period_accrual_1(self): 'expense_accrual_account': self.env['account.account'].create({ 'name': 'Accrual Expense Account', 'code': '234567', - 'user_type_id': self.env.ref('account.data_account_type_expenses').id, + 'account_type': 'expense', 'reconcile': True, }).id, 'revenue_accrual_account': self.env['account.account'].create({ 'name': 'Accrual Revenue Account', 'code': '765432', - 'user_type_id': self.env.ref('account.data_account_type_expenses').id, + 'account_type': 'expense', 'reconcile': True, }).id, }) @@ -1891,20 +1891,20 @@ def test_in_invoice_reverse_caba(self): tax_waiting_account = self.env['account.account'].create({ 'name': 'TAX_WAIT', 'code': 'TWAIT', - 'user_type_id': self.env.ref('account.data_account_type_current_liabilities').id, + 'account_type': 'liability_current', 'reconcile': True, 'company_id': self.company_data['company'].id, }) tax_final_account = self.env['account.account'].create({ 'name': 'TAX_TO_DEDUCT', 'code': 'TDEDUCT', - 'user_type_id': self.env.ref('account.data_account_type_current_assets').id, + 'account_type': 'asset_current', 'company_id': self.company_data['company'].id, }) tax_base_amount_account = self.env['account.account'].create({ 'name': 'TAX_BASE', 'code': 'TBASE', - 'user_type_id': self.env.ref('account.data_account_type_current_assets').id, + 'account_type': 'asset_current', 'company_id': self.company_data['company'].id, }) self.env.company.account_cash_basis_base_account_id = tax_base_amount_account diff --git a/addons/account/tests/test_account_move_in_refund.py b/addons/account/tests/test_account_move_in_refund.py index 50bd082f28a3e..081305b78245a 100644 --- a/addons/account/tests/test_account_move_in_refund.py +++ b/addons/account/tests/test_account_move_in_refund.py @@ -1102,20 +1102,20 @@ def test_in_refund_reverse_caba(self): tax_waiting_account = self.env['account.account'].create({ 'name': 'TAX_WAIT', 'code': 'TWAIT', - 'user_type_id': self.env.ref('account.data_account_type_current_liabilities').id, + 'account_type': 'liability_current', 'reconcile': True, 'company_id': self.company_data['company'].id, }) tax_final_account = self.env['account.account'].create({ 'name': 'TAX_TO_DEDUCT', 'code': 'TDEDUCT', - 'user_type_id': self.env.ref('account.data_account_type_current_assets').id, + 'account_type': 'asset_current', 'company_id': self.company_data['company'].id, }) tax_base_amount_account = self.env['account.account'].create({ 'name': 'TAX_BASE', 'code': 'TBASE', - 'user_type_id': self.env.ref('account.data_account_type_current_assets').id, + 'account_type': 'asset_current', 'company_id': self.company_data['company'].id, }) self.env.company.account_cash_basis_base_account_id = tax_base_amount_account diff --git a/addons/account/tests/test_account_move_out_invoice.py b/addons/account/tests/test_account_move_out_invoice.py index 497b3860abddf..07494c7bc9ebb 100644 --- a/addons/account/tests/test_account_move_out_invoice.py +++ b/addons/account/tests/test_account_move_out_invoice.py @@ -2292,7 +2292,7 @@ def test_out_invoice_write_2(self): ] }) - receivable_lines = move.line_ids.filtered(lambda line: line.account_id.user_type_id.type == 'receivable') + receivable_lines = move.line_ids.filtered(lambda line: line.account_id.account_type == 'asset_receivable') not_receivable_lines = move.line_ids - receivable_lines # Write a receivable account on a not-receivable line. @@ -2822,13 +2822,13 @@ def test_out_invoice_change_period_accrual_1(self): 'expense_accrual_account': self.env['account.account'].create({ 'name': 'Accrual Expense Account', 'code': '234567', - 'user_type_id': self.env.ref('account.data_account_type_expenses').id, + 'account_type': 'expense', 'reconcile': True, }).id, 'revenue_accrual_account': self.env['account.account'].create({ 'name': 'Accrual Revenue Account', 'code': '765432', - 'user_type_id': self.env.ref('account.data_account_type_expenses').id, + 'account_type': 'expense', 'reconcile': True, }).id, }) @@ -2936,13 +2936,13 @@ def test_out_invoice_multi_date_change_period_accrual(self): 'expense_accrual_account': self.env['account.account'].create({ 'name': 'Accrual Expense Account', 'code': '234567', - 'user_type_id': self.env.ref('account.data_account_type_expenses').id, + 'account_type': 'expense', 'reconcile': True, }).id, 'revenue_accrual_account': self.env['account.account'].create({ 'name': 'Accrual Revenue Account', 'code': '765432', - 'user_type_id': self.env.ref('account.data_account_type_expenses').id, + 'account_type': 'expense', 'reconcile': True, }).id, }) @@ -3298,20 +3298,20 @@ def test_out_invoice_reverse_caba(self): tax_waiting_account = self.env['account.account'].create({ 'name': 'TAX_WAIT', 'code': 'TWAIT', - 'user_type_id': self.env.ref('account.data_account_type_current_liabilities').id, + 'account_type': 'liability_current', 'reconcile': True, 'company_id': self.company_data['company'].id, }) tax_final_account = self.env['account.account'].create({ 'name': 'TAX_TO_DEDUCT', 'code': 'TDEDUCT', - 'user_type_id': self.env.ref('account.data_account_type_current_assets').id, + 'account_type': 'asset_current', 'company_id': self.company_data['company'].id, }) tax_base_amount_account = self.env['account.account'].create({ 'name': 'TAX_BASE', 'code': 'TBASE', - 'user_type_id': self.env.ref('account.data_account_type_current_assets').id, + 'account_type': 'asset_current', 'company_id': self.company_data['company'].id, }) self.env.company.account_cash_basis_base_account_id = tax_base_amount_account diff --git a/addons/account/tests/test_account_move_out_refund.py b/addons/account/tests/test_account_move_out_refund.py index 95735bc92b2e6..883840fefcb25 100644 --- a/addons/account/tests/test_account_move_out_refund.py +++ b/addons/account/tests/test_account_move_out_refund.py @@ -1067,20 +1067,20 @@ def test_out_refund_reverse_caba(self): tax_waiting_account = self.env['account.account'].create({ 'name': 'TAX_WAIT', 'code': 'TWAIT', - 'user_type_id': self.env.ref('account.data_account_type_current_liabilities').id, + 'account_type': 'liability_current', 'reconcile': True, 'company_id': self.company_data['company'].id, }) tax_final_account = self.env['account.account'].create({ 'name': 'TAX_TO_DEDUCT', 'code': 'TDEDUCT', - 'user_type_id': self.env.ref('account.data_account_type_current_assets').id, + 'account_type': 'asset_current', 'company_id': self.company_data['company'].id, }) tax_base_amount_account = self.env['account.account'].create({ 'name': 'TAX_BASE', 'code': 'TBASE', - 'user_type_id': self.env.ref('account.data_account_type_current_assets').id, + 'account_type': 'asset_current', 'company_id': self.company_data['company'].id, }) self.env.company.account_cash_basis_base_account_id = tax_base_amount_account diff --git a/addons/account/tests/test_account_move_reconcile.py b/addons/account/tests/test_account_move_reconcile.py index 20a82816ba21f..426f5ba6c403e 100644 --- a/addons/account/tests/test_account_move_reconcile.py +++ b/addons/account/tests/test_account_move_reconcile.py @@ -39,7 +39,7 @@ def setUpClass(cls, chart_template_ref=None): cls.cash_basis_base_account = cls.env['account.account'].create({ 'code': 'cash_basis_base_account', 'name': 'cash_basis_base_account', - 'user_type_id': cls.env.ref('account.data_account_type_revenue').id, + 'account_type': 'income', 'company_id': cls.company_data['company'].id, }) cls.company_data['company'].account_cash_basis_base_account_id = cls.cash_basis_base_account @@ -47,21 +47,21 @@ def setUpClass(cls, chart_template_ref=None): cls.cash_basis_transfer_account = cls.env['account.account'].create({ 'code': 'cash_basis_transfer_account', 'name': 'cash_basis_transfer_account', - 'user_type_id': cls.env.ref('account.data_account_type_revenue').id, + 'account_type': 'income', 'company_id': cls.company_data['company'].id, }) cls.tax_account_1 = cls.env['account.account'].create({ 'code': 'tax_account_1', 'name': 'tax_account_1', - 'user_type_id': cls.env.ref('account.data_account_type_revenue').id, + 'account_type': 'income', 'company_id': cls.company_data['company'].id, }) cls.tax_account_2 = cls.env['account.account'].create({ 'code': 'tax_account_2', 'name': 'tax_account_2', - 'user_type_id': cls.env.ref('account.data_account_type_revenue').id, + 'account_type': 'income', 'company_id': cls.company_data['company'].id, }) @@ -1664,7 +1664,7 @@ def test_reverse_with_multiple_lines(self): move.action_post() - lines_to_reconcile = move.line_ids.filtered(lambda x: (x.account_id.reconcile or x.account_id.internal_type == 'liquidity') and not x.reconciled) + lines_to_reconcile = move.line_ids.filtered(lambda x: (x.account_id.reconcile or x.account_id.account_type in ('asset_cash', 'liability_credit_card')) and not x.reconciled) self.assertRecordValues(lines_to_reconcile, [ {'debit': 1200.0, 'credit': 0.0, 'reconciled': False}, @@ -1676,7 +1676,7 @@ def test_reverse_with_multiple_lines(self): reversed_move = move._reverse_moves(cancel=True) reversed_lines = reversed_move.line_ids.filtered(lambda x: ( - x.account_id.reconcile or x.account_id.internal_type == 'liquidity' + x.account_id.reconcile or x.account_id.account_type in ('asset_cash', 'liability_credit_card') )) self.assertRecordValues(reversed_lines, [ @@ -1715,7 +1715,7 @@ def test_reconcile_special_mexican_workflow_1(self): })], }) refund1.action_post() - refund1_rec_line = refund1.line_ids.filtered(lambda x: x.account_id.internal_type == 'receivable') + refund1_rec_line = refund1.line_ids.filtered(lambda x: x.account_id.account_type == 'asset_receivable') inv1 = self.env['account.move'].create({ 'move_type': 'out_invoice', @@ -1729,7 +1729,7 @@ def test_reconcile_special_mexican_workflow_1(self): })], }) inv1.action_post() - inv1_rec_line = inv1.line_ids.filtered(lambda x: x.account_id.internal_type == 'receivable') + inv1_rec_line = inv1.line_ids.filtered(lambda x: x.account_id.account_type == 'asset_receivable') inv2 = self.env['account.move'].create({ 'move_type': 'out_invoice', @@ -1743,7 +1743,7 @@ def test_reconcile_special_mexican_workflow_1(self): })], }) inv2.action_post() - inv2_rec_line = inv2.line_ids.filtered(lambda x: x.account_id.internal_type == 'receivable') + inv2_rec_line = inv2.line_ids.filtered(lambda x: x.account_id.account_type == 'asset_receivable') pay1 = self.env['account.payment'].create({ 'partner_type': 'customer', @@ -1753,8 +1753,8 @@ def test_reconcile_special_mexican_workflow_1(self): 'partner_id': self.partner_a.id, 'currency_id': foreign_curr.id, }) - pay1_liquidity_line = pay1.line_ids.filtered(lambda x: x.account_id.internal_type != 'receivable') - pay1_rec_line = pay1.line_ids.filtered(lambda x: x.account_id.internal_type == 'receivable') + pay1_liquidity_line = pay1.line_ids.filtered(lambda x: x.account_id.account_type != 'asset_receivable') + pay1_rec_line = pay1.line_ids.filtered(lambda x: x.account_id.account_type == 'asset_receivable') pay1.action_post() pay1.write({'line_ids': [ Command.update(pay1_liquidity_line.id, {'debit': 36511.34}), @@ -1770,7 +1770,7 @@ def test_reconcile_special_mexican_workflow_1(self): 'currency_id': foreign_curr.id, }) pay2.action_post() - pay2_rec_line = pay2.line_ids.filtered(lambda x: x.account_id.internal_type == 'receivable') + pay2_rec_line = pay2.line_ids.filtered(lambda x: x.account_id.account_type == 'asset_receivable') # 1st reconciliation refund1 + inv1 self.assert_invoice_outstanding_to_reconcile_widget(refund1, { @@ -1986,7 +1986,7 @@ def test_reconcile_special_mexican_workflow_2(self): })], }) refund1.action_post() - refund1_rec_line = refund1.line_ids.filtered(lambda x: x.account_id.internal_type == 'receivable') + refund1_rec_line = refund1.line_ids.filtered(lambda x: x.account_id.account_type == 'asset_receivable') inv1 = self.env['account.move'].create({ 'move_type': 'out_invoice', @@ -2000,7 +2000,7 @@ def test_reconcile_special_mexican_workflow_2(self): })], }) inv1.action_post() - inv1_rec_line = inv1.line_ids.filtered(lambda x: x.account_id.internal_type == 'receivable') + inv1_rec_line = inv1.line_ids.filtered(lambda x: x.account_id.account_type == 'asset_receivable') inv2 = self.env['account.move'].create({ 'move_type': 'out_invoice', @@ -2014,7 +2014,7 @@ def test_reconcile_special_mexican_workflow_2(self): })], }) inv2.action_post() - inv2_rec_line = inv2.line_ids.filtered(lambda x: x.account_id.internal_type == 'receivable') + inv2_rec_line = inv2.line_ids.filtered(lambda x: x.account_id.account_type == 'asset_receivable') pay1 = self.env['account.payment'].create({ 'partner_type': 'customer', @@ -2024,8 +2024,8 @@ def test_reconcile_special_mexican_workflow_2(self): 'partner_id': self.partner_a.id, 'currency_id': foreign_curr.id, }) - pay1_liquidity_line = pay1.line_ids.filtered(lambda x: x.account_id.internal_type != 'receivable') - pay1_rec_line = pay1.line_ids.filtered(lambda x: x.account_id.internal_type == 'receivable') + pay1_liquidity_line = pay1.line_ids.filtered(lambda x: x.account_id.account_type != 'asset_receivable') + pay1_rec_line = pay1.line_ids.filtered(lambda x: x.account_id.account_type == 'asset_receivable') pay1.action_post() pay1.write({'line_ids': [ Command.update(pay1_liquidity_line.id, {'debit': 36511.34}), @@ -2041,7 +2041,7 @@ def test_reconcile_special_mexican_workflow_2(self): 'currency_id': foreign_curr.id, }) pay2.action_post() - pay2_rec_line = pay2.line_ids.filtered(lambda x: x.account_id.internal_type == 'receivable') + pay2_rec_line = pay2.line_ids.filtered(lambda x: x.account_id.account_type == 'asset_receivable') self.assertRecordValues(refund1_rec_line + inv1_rec_line + inv2_rec_line + pay1_rec_line + pay2_rec_line, [ {'amount_residual': -1385.92, 'amount_residual_currency': -1385.92}, @@ -2974,7 +2974,7 @@ def test_reconcile_cash_basis_exchange_difference_transfer_account_check_entries {'account_id': self.tax_account_1.id, 'debit': 0.0, 'credit': 15.0, 'amount_currency': -10.0, 'tax_ids': [], 'tax_line_id': self.cash_basis_tax_a_third_amount.id}, ]) - receivable_line = caba_inv.line_ids.filtered(lambda x: x.account_id.internal_type == 'receivable') + receivable_line = caba_inv.line_ids.filtered(lambda x: x.account_id.account_type == 'asset_receivable') self.assertTrue(receivable_line.full_reconcile_id, "Invoice should be fully paid") self.assertRecordValues(partial_rec.exchange_move_id.line_ids, [ @@ -3055,7 +3055,7 @@ def test_reconcile_cash_basis_exchange_difference_transfer_account_check_entries })\ ._create_payments() - receivable_line = caba_inv.line_ids.filtered(lambda x: x.account_id.internal_type == 'receivable') + receivable_line = caba_inv.line_ids.filtered(lambda x: x.account_id.account_type == 'asset_receivable') partial_rec = caba_inv.line_ids.matched_credit_ids self.assertTrue(receivable_line.full_reconcile_id, "Invoice should be fully paid") @@ -3094,7 +3094,7 @@ def test_reconcile_cash_basis_exchange_difference_transfer_account_check_entries cash_basis_transition_account = self.env['account.account'].create({ 'code': '209.01.01', 'name': 'Cash Basis Transition Account', - 'user_type_id': self.env.ref('account.data_account_type_current_liabilities').id, + 'account_type': 'liability_current', 'company_id': self.company_data['company'].id, 'reconcile': True, }) diff --git a/addons/account/tests/test_account_payment.py b/addons/account/tests/test_account_payment.py index 115627f427789..974bf858e009d 100644 --- a/addons/account/tests/test_account_payment.py +++ b/addons/account/tests/test_account_payment.py @@ -739,7 +739,7 @@ def test_reconciliation_payment_states(self): payment.action_post() invoice.action_post() - (counterpart_lines + invoice.line_ids.filtered(lambda line: line.account_internal_type == 'receivable')) \ + (counterpart_lines + invoice.line_ids.filtered(lambda line: line.account_type == 'asset_receivable'))\ .reconcile() self.assertRecordValues(payment, [{ diff --git a/addons/account/tests/test_account_payment_register.py b/addons/account/tests/test_account_payment_register.py index f277ffc8f1e0e..1d9ac682071e7 100644 --- a/addons/account/tests/test_account_payment_register.py +++ b/addons/account/tests/test_account_payment_register.py @@ -1050,7 +1050,7 @@ def test_register_payment_invoice_foreign_curr_payment_comp_curr(self): }]) payment = wizard._create_payments() - lines = (invoice + payment.move_id).line_ids.filtered(lambda x: x.account_internal_type == 'receivable') + lines = (invoice + payment.move_id).line_ids.filtered(lambda x: x.account_type == 'asset_receivable') self.assertRecordValues(lines, [ {'amount_residual': 0.0, 'amount_residual_currency': 0.0, 'currency_id': self.currency_data['currency'].id, 'reconciled': True}, {'amount_residual': 0.0, 'amount_residual_currency': 0.0, 'currency_id': self.company_data['currency'].id, 'reconciled': True}, @@ -1084,7 +1084,7 @@ def test_register_payment_invoice_comp_curr_payment_foreign_curr(self): }]) payment = wizard._create_payments() - lines = (invoice + payment.move_id).line_ids.filtered(lambda x: x.account_internal_type == 'receivable') + lines = (invoice + payment.move_id).line_ids.filtered(lambda x: x.account_type == 'asset_receivable') self.assertRecordValues(lines, [ {'amount_residual': 0.0, 'amount_residual_currency': 0.0, 'currency_id': self.company_data['currency'].id, 'reconciled': True}, {'amount_residual': 0.0, 'amount_residual_currency': 0.0, 'currency_id': self.currency_data['currency'].id, 'reconciled': True}, diff --git a/addons/account/tests/test_invoice_taxes.py b/addons/account/tests/test_invoice_taxes.py index 5bd499e3253fb..6fdeec4dc9ea6 100644 --- a/addons/account/tests/test_invoice_taxes.py +++ b/addons/account/tests/test_invoice_taxes.py @@ -185,9 +185,8 @@ def test_tax_repartition(self): ref_base_tag = self._create_tax_tag('refund_base') ref_tax_tag = self._create_tax_tag('refund_tax') - user_type = self.env.ref('account.data_account_type_current_assets') - account_1 = self.env['account.account'].create({'name': 'test1', 'code': 'test1', 'user_type_id': user_type.id}) - account_2 = self.env['account.account'].create({'name': 'test2', 'code': 'test2', 'user_type_id': user_type.id}) + account_1 = self.env['account.account'].create({'name': 'test1', 'code': 'test1', 'account_type': 'asset_current'}) + account_2 = self.env['account.account'].create({'name': 'test2', 'code': 'test2', 'account_type': 'asset_current'}) tax = self.env['account.tax'].create({ 'name': "Tax with account", @@ -242,7 +241,7 @@ def test_tax_repartition(self): invoice.action_post() self.assertEqual(len(invoice.line_ids), 4, "There should be 4 account move lines created for the invoice: payable, base and 2 tax lines") - inv_base_line = invoice.line_ids.filtered(lambda x: not x.tax_repartition_line_id and x.account_id.user_type_id.type != 'receivable') + inv_base_line = invoice.line_ids.filtered(lambda x: not x.tax_repartition_line_id and x.account_id.account_type != 'asset_receivable') self.assertEqual(len(inv_base_line), 1, "There should be only one base line generated") self.assertEqual(abs(inv_base_line.balance), 100, "Base amount should be 100") self.assertEqual(inv_base_line.tax_tag_ids, inv_base_tag, "Base line should have received base tag") @@ -258,7 +257,7 @@ def test_tax_repartition(self): refund.action_post() self.assertEqual(len(refund.line_ids), 4, "There should be 4 account move lines created for the refund: payable, base and 2 tax lines") - ref_base_line = refund.line_ids.filtered(lambda x: not x.tax_repartition_line_id and x.account_id.user_type_id.type != 'receivable') + ref_base_line = refund.line_ids.filtered(lambda x: not x.tax_repartition_line_id and x.account_id.account_type != 'asset_receivable') self.assertEqual(len(ref_base_line), 1, "There should be only one base line generated") self.assertEqual(abs(ref_base_line.balance), 100, "Base amount should be 100") self.assertEqual(ref_base_line.tax_tag_ids, ref_base_tag, "Base line should have received base tag") @@ -710,6 +709,6 @@ def test_tax_calculation_multi_currency(self): 'balance': -119.16, }]) - self.assertRecordValues(invoice.line_ids.filtered(lambda l: l.account_id.internal_type == 'receivable'), [{ + self.assertRecordValues(invoice.line_ids.filtered(lambda l: l.account_id.account_type == 'asset_receivable'), [{ 'balance': 686.54 }]) diff --git a/addons/account/tests/test_reconciliation_matching_rules.py b/addons/account/tests/test_reconciliation_matching_rules.py index 63e18bebf910d..e29fc59043e89 100644 --- a/addons/account/tests/test_reconciliation_matching_rules.py +++ b/addons/account/tests/test_reconciliation_matching_rules.py @@ -28,7 +28,7 @@ def setUpClass(cls, chart_template_ref=None): cls.account_pay = cls.company_data['default_account_payable'] cls.current_assets_account = cls.env['account.account'].search([ - ('user_type_id', '=', cls.env.ref('account.data_account_type_current_assets').id), + ('account_type', '=', 'asset_current'), ('company_id', '=', cls.company.id)], limit=1) cls.bank_journal = cls.env['account.journal'].search([('type', '=', 'bank'), ('company_id', '=', cls.company.id)], limit=1) @@ -181,7 +181,7 @@ def _create_invoice_line(cls, amount, partner, move_type, currency=None, pay_ref invoice = invoice_form.save() invoice.action_post() lines = invoice.line_ids - return lines.filtered(lambda l: l.account_id.user_type_id.type in ('receivable', 'payable')) + return lines.filtered(lambda l: l.account_id.account_type in ('asset_receivable', 'liability_payable')) @classmethod def _create_st_line(cls, amount=1000.0, date='2019-01-01', payment_ref='turlututu', **kwargs): @@ -1034,7 +1034,7 @@ def create_payment_line(amount, memo, partner): }) payment.action_post() - return payment.line_ids.filtered(lambda x: x.account_id.user_type_id.type not in {'receivable', 'payable'}) + return payment.line_ids.filtered(lambda x: x.account_id.account_type not in {'asset_receivable', 'liability_payable'}) payment_partner = self.env['res.partner'].create({ 'name': "Bernard Gagnant", diff --git a/addons/account/tests/test_sequence_mixin.py b/addons/account/tests/test_sequence_mixin.py index 7aa582551b46b..6213877e455b6 100644 --- a/addons/account/tests/test_sequence_mixin.py +++ b/addons/account/tests/test_sequence_mixin.py @@ -458,7 +458,7 @@ def setUp(self): account = env['account.account'].create({ 'code': 'CT', 'name': 'CT', - 'user_type_id': env.ref('account.data_account_type_fixed_assets').id, + 'account_type': 'asset_fixed', }) moves = env['account.move'].create([{ 'journal_id': journal.id, diff --git a/addons/account/tests/test_templates_consistency.py b/addons/account/tests/test_templates_consistency.py index 8cced5e9a528e..8721faec34df6 100644 --- a/addons/account/tests/test_templates_consistency.py +++ b/addons/account/tests/test_templates_consistency.py @@ -40,7 +40,7 @@ def test_account_account_fields(self): self.check_fields_consistency( 'account.account.template', 'account.account', exceptions=['chart_template_id', 'nocreate']) self.check_fields_consistency( - 'account.account', 'account.account.template', exceptions=['company_id', 'deprecated', 'opening_debit', 'opening_credit', 'allowed_journal_ids', 'group_id', 'root_id', 'is_off_balance', 'non_trade']) + 'account.account', 'account.account.template', exceptions=['company_id', 'deprecated', 'opening_debit', 'opening_credit', 'allowed_journal_ids', 'group_id', 'root_id', 'is_off_balance', 'non_trade', 'include_initial_balance']) def test_account_tax_fields(self): '''Test fields consistency for ('account.tax', 'account.tax.template') diff --git a/addons/account/tests/test_transfer_wizard.py b/addons/account/tests/test_transfer_wizard.py index da0bfc6e8aa48..821c269956a47 100644 --- a/addons/account/tests/test_transfer_wizard.py +++ b/addons/account/tests/test_transfer_wizard.py @@ -61,7 +61,7 @@ def setUpClass(cls, chart_template_ref=None): cls.test_currency_account = cls.env['account.account'].create({ 'name': 'test destination account', 'code': 'test_dest_acc', - 'user_type_id': cls.env['ir.model.data']._xmlid_to_res_id('account.data_account_type_current_assets'), + 'account_type': 'asset_current', 'currency_id': cls.test_currency_3.id, }) @@ -192,7 +192,7 @@ def setUpClass(cls, chart_template_ref=None): def test_transfer_wizard_reconcile(self): """ Tests reconciliation when doing a transfer with the wizard """ - active_move_lines = (self.move_1 + self.move_2).mapped('line_ids').filtered(lambda x: x.account_id.user_type_id.type in ('receivable', 'payable')) + active_move_lines = (self.move_1 + self.move_2).mapped('line_ids').filtered(lambda x: x.account_id.account_type in ('asset_receivable', 'liability_payable')) # We use a form to pass the context properly to the depends_context move_line_ids field context = {'active_model': 'account.move.line', 'active_ids': active_move_lines.ids} diff --git a/addons/account/views/account_account_type_views.xml b/addons/account/views/account_account_type_views.xml deleted file mode 100644 index 286263b31ba0e..0000000000000 --- a/addons/account/views/account_account_type_views.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - account.account.type.search - account.account.type - - - - - - - - - account.account.type.tree - account.account.type - - - - - - - - - - account.account.type.form - account.account.type - -
- - - - - - - - - - - - - -
- - - Account Types - account.account.type - tree,form - - -

- Define a new account type -

- An account type is used to determine how an account is used in - each journal. The deferral method of an account type determines - the process for the annual closing. Reports such as the Balance - Sheet and the Profit and Loss report use the category - (profit/loss or balance sheet). -

-
-
- -
-
diff --git a/addons/account/views/account_account_views.xml b/addons/account/views/account_account_views.xml index be70ce6fe6cf9..5885394cc4586 100644 --- a/addons/account/views/account_account_views.xml +++ b/addons/account/views/account_account_views.xml @@ -59,13 +59,13 @@ - + - + @@ -92,12 +92,12 @@ - + - + - - + + @@ -115,7 +115,7 @@ - +
@@ -128,7 +128,7 @@
- Type: + Type:
@@ -143,8 +143,8 @@ - - + + @@ -154,9 +154,9 @@ - + - +
diff --git a/addons/account/views/account_chart_template_views.xml b/addons/account/views/account_chart_template_views.xml index f2fac4df0f912..d3f5ea04e14c3 100644 --- a/addons/account/views/account_chart_template_views.xml +++ b/addons/account/views/account_chart_template_views.xml @@ -83,7 +83,7 @@ - + @@ -104,7 +104,7 @@ - + @@ -115,9 +115,9 @@ - + - + diff --git a/addons/account/views/account_journal_views.xml b/addons/account/views/account_journal_views.xml index 37b6b40619a73..428359a87080c 100644 --- a/addons/account/views/account_journal_views.xml +++ b/addons/account/views/account_journal_views.xml @@ -128,7 +128,6 @@
Keep empty for no control
-
diff --git a/addons/account/views/account_move_views.xml b/addons/account/views/account_move_views.xml index a0fc2ad1defec..e0d53afbc3471 100644 --- a/addons/account/views/account_move_views.xml +++ b/addons/account/views/account_move_views.xml @@ -156,7 +156,7 @@ - + @@ -172,17 +172,16 @@ - - + + - + -