From 576a69e29e98532aa5de78eb3fcbff0b94cea32d Mon Sep 17 00:00:00 2001 From: wan Date: Mon, 24 Feb 2020 13:47:51 +0000 Subject: [PATCH] [REF] account: remove unused actions Task 2201948 *These actions were either unused or only used in enterprise modules. The first ones have been deleted, and the second ones have been move to the corresponding enterprise modules. * account.fiscal.year: the whole model has been moved to enterprise closes odoo/odoo#46110 Related: odoo/enterprise#8706 Related: odoo/upgrade#1083 Signed-off-by: Quentin De Paoli (qdp) --- addons/account/__manifest__.py | 1 - addons/account/models/__init__.py | 1 - addons/account/models/account_fiscal_year.py | 55 -------- addons/account/models/company.py | 58 +------- addons/account/models/res_config_settings.py | 1 - addons/account/security/account_security.xml | 5 - addons/account/security/ir.model.access.csv | 3 - addons/account/tests/__init__.py | 1 - .../account/tests/test_account_fiscal_year.py | 131 ------------------ .../views/account_account_tag_views.xml | 11 -- .../views/account_analytic_default_view.xml | 7 +- .../views/account_bank_statement_views.xml | 8 -- .../views/account_chart_template_views.xml | 19 --- .../views/account_fiscal_year_view.xml | 55 -------- addons/account/views/account_group_views.xml | 12 -- addons/account/views/account_menuitem.xml | 1 + addons/account/views/account_move_views.xml | 31 ----- addons/account/views/account_tax_views.xml | 8 -- .../wizard/account_report_common_view.xml | 8 -- 19 files changed, 3 insertions(+), 413 deletions(-) delete mode 100644 addons/account/models/account_fiscal_year.py delete mode 100644 addons/account/tests/test_account_fiscal_year.py delete mode 100644 addons/account/views/account_fiscal_year_view.xml diff --git a/addons/account/__manifest__.py b/addons/account/__manifest__.py index 0a75522a30e..1ec5bdde556 100644 --- a/addons/account/__manifest__.py +++ b/addons/account/__manifest__.py @@ -68,7 +68,6 @@ You could use this simplified accounting in case you work with an (external) acc 'data/payment_receipt_data.xml', 'views/account_onboarding_templates.xml', 'data/service_cron.xml', - 'views/account_fiscal_year_view.xml', 'views/account_incoterms_view.xml', 'data/account_incoterms_data.xml', 'views/digest_views.xml', diff --git a/addons/account/models/__init__.py b/addons/account/models/__init__.py index c4cd7e70fa2..951796b3282 100644 --- a/addons/account/models/__init__.py +++ b/addons/account/models/__init__.py @@ -18,7 +18,6 @@ from . import chart_template from . import account_analytic_line from . import account_journal_dashboard from . import product -from . import account_fiscal_year from . import company from . import res_config_settings from . import account_cash_rounding diff --git a/addons/account/models/account_fiscal_year.py b/addons/account/models/account_fiscal_year.py deleted file mode 100644 index 633388559e9..00000000000 --- a/addons/account/models/account_fiscal_year.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- - -from odoo.exceptions import ValidationError -from odoo import api, fields, models, _ - - -from datetime import datetime - - -class AccountFiscalYear(models.Model): - _name = 'account.fiscal.year' - _description = 'Fiscal Year' - - name = fields.Char(string='Name', required=True) - date_from = fields.Date(string='Start Date', required=True, - help='Start Date, included in the fiscal year.') - date_to = fields.Date(string='End Date', required=True, - help='Ending Date, included in the fiscal year.') - company_id = fields.Many2one('res.company', string='Company', required=True, - default=lambda self: self.env.company) - - @api.constrains('date_from', 'date_to', 'company_id') - def _check_dates(self): - ''' - Check interleaving between fiscal years. - There are 3 cases to consider: - - s1 s2 e1 e2 - ( [----)----] - - s2 s1 e2 e1 - [----(----] ) - - s1 s2 e2 e1 - ( [----] ) - ''' - for fy in self: - # Starting date must be prior to the ending date - date_from = fy.date_from - date_to = fy.date_to - if date_to < date_from: - raise ValidationError(_('The ending date must not be prior to the starting date.')) - - - domain = [ - ('id', '!=', fy.id), - ('company_id', '=', fy.company_id.id), - '|', '|', - '&', ('date_from', '<=', fy.date_from), ('date_to', '>=', fy.date_from), - '&', ('date_from', '<=', fy.date_to), ('date_to', '>=', fy.date_to), - '&', ('date_from', '<=', fy.date_from), ('date_to', '>=', fy.date_to), - ] - - if self.search_count(domain) > 0: - raise ValidationError(_('You can not have an overlap between two fiscal years, please correct the start and/or end dates of your fiscal years.')) diff --git a/addons/account/models/company.py b/addons/account/models/company.py index f817927cf93..9841de22c83 100644 --- a/addons/account/models/company.py +++ b/addons/account/models/company.py @@ -6,9 +6,8 @@ from dateutil.relativedelta import relativedelta from odoo import fields, models, api, _ from odoo.exceptions import ValidationError, UserError, RedirectWarning -from odoo.tools.misc import DEFAULT_SERVER_DATE_FORMAT, format_date +from odoo.tools.misc import format_date from odoo.tools.float_utils import float_round, float_is_zero -from odoo.tools import date_utils from odoo.tests.common import Form @@ -165,61 +164,6 @@ class ResCompany(models.Model): 'account_setup_coa_state', ] - def compute_fiscalyear_dates(self, current_date): - '''Computes the start and end dates of the fiscal year where the given 'date' belongs to. - - :param current_date: A datetime.date/datetime.datetime object. - :return: A dictionary containing: - * date_from - * date_to - * [Optionally] record: The fiscal year record. - ''' - self.ensure_one() - date_str = current_date.strftime(DEFAULT_SERVER_DATE_FORMAT) - - # Search a fiscal year record containing the date. - # If a record is found, then no need further computation, we get the dates range directly. - fiscalyear = self.env['account.fiscal.year'].search([ - ('company_id', '=', self.id), - ('date_from', '<=', date_str), - ('date_to', '>=', date_str), - ], limit=1) - if fiscalyear: - return { - 'date_from': fiscalyear.date_from, - 'date_to': fiscalyear.date_to, - 'record': fiscalyear, - } - - date_from, date_to = date_utils.get_fiscal_year( - current_date, day=self.fiscalyear_last_day, month=int(self.fiscalyear_last_month)) - - date_from_str = date_from.strftime(DEFAULT_SERVER_DATE_FORMAT) - date_to_str = date_to.strftime(DEFAULT_SERVER_DATE_FORMAT) - - # Search for fiscal year records reducing the delta between the date_from/date_to. - # This case could happen if there is a gap between two fiscal year records. - # E.g. two fiscal year records: 2017-01-01 -> 2017-02-01 and 2017-03-01 -> 2017-12-31. - # => The period 2017-02-02 - 2017-02-30 is not covered by a fiscal year record. - - fiscalyear_from = self.env['account.fiscal.year'].search([ - ('company_id', '=', self.id), - ('date_from', '<=', date_from_str), - ('date_to', '>=', date_from_str), - ], limit=1) - if fiscalyear_from: - date_from = fiscalyear_from.date_to + timedelta(days=1) - - fiscalyear_to = self.env['account.fiscal.year'].search([ - ('company_id', '=', self.id), - ('date_from', '<=', date_to_str), - ('date_to', '>=', date_to_str), - ], limit=1) - if fiscalyear_to: - date_to = fiscalyear_to.date_from - timedelta(days=1) - - return {'date_from': date_from, 'date_to': date_to} - def get_new_account_code(self, current_code, old_prefix, new_prefix): digits = len(current_code) return new_prefix + current_code.replace(old_prefix, '', 1).lstrip('0').rjust(digits-len(new_prefix), '0') diff --git a/addons/account/models/res_config_settings.py b/addons/account/models/res_config_settings.py index d29ad24ea1a..eb05b59737f 100644 --- a/addons/account/models/res_config_settings.py +++ b/addons/account/models/res_config_settings.py @@ -29,7 +29,6 @@ class ResConfigSettings(models.TransientModel): group_analytic_tags = fields.Boolean(string='Analytic Tags', implied_group='analytic.group_analytic_tags') group_warning_account = fields.Boolean(string="Warnings in Invoices", implied_group='account.group_warning_account') group_cash_rounding = fields.Boolean(string="Cash Rounding", implied_group='account.group_cash_rounding') - group_fiscal_year = fields.Boolean(string='Fiscal Years', implied_group='account.group_fiscal_year') # group_show_line_subtotals_tax_excluded and group_show_line_subtotals_tax_included are opposite, # so we can assume exactly one of them will be set, and not the other. # We need both of them to coexist so we can take advantage of automatic group assignation. diff --git a/addons/account/security/account_security.xml b/addons/account/security/account_security.xml index 6576f1b6d45..8a55998f811 100644 --- a/addons/account/security/account_security.xml +++ b/addons/account/security/account_security.xml @@ -61,11 +61,6 @@ - - Allow to define fiscal years of more or less than a year - - - Sale Receipt diff --git a/addons/account/security/ir.model.access.csv b/addons/account/security/ir.model.access.csv index c517ce82561..d95559d7270 100644 --- a/addons/account/security/ir.model.access.csv +++ b/addons/account/security/ir.model.access.csv @@ -25,9 +25,6 @@ access_account_invoice_report,account.invoice.report,model_account_invoice_repor access_account_incoterms_all,account.incoterms all,model_account_incoterms,,1,0,0,0 access_account_incoterms_manager,account.incoterms manager,model_account_incoterms,account.group_account_manager,1,1,1,1 -access_account_fiscal_year_readonly,account.fiscal.year.user,model_account_fiscal_year,account.group_account_readonly,1,0,0,0 -access_account_fiscal_year_manager,account.fiscal.year.manager,model_account_fiscal_year,account.group_account_manager,1,1,1,1 - access_account_fiscal_position_product_manager,account.fiscal.position account.manager,model_account_fiscal_position,account.group_account_manager,1,1,1,1 access_account_fiscal_position_tax_product_manager,account.fiscal.position.tax account.manager,model_account_fiscal_position_tax,account.group_account_manager,1,1,1,1 access_account_fiscal_position_account_product_manager,account.fiscal.position account.manager,model_account_fiscal_position_account,account.group_account_manager,1,1,1,1 diff --git a/addons/account/tests/__init__.py b/addons/account/tests/__init__.py index 0be7b9511b9..b6e8b294a63 100644 --- a/addons/account/tests/__init__.py +++ b/addons/account/tests/__init__.py @@ -23,7 +23,6 @@ from . import test_settings from . import test_tax from . import test_invoice_taxes from . import test_templates_consistency -from . import test_account_fiscal_year from . import test_account_all_l10n from . import test_reconciliation_matching_rules from . import test_account_onboarding diff --git a/addons/account/tests/test_account_fiscal_year.py b/addons/account/tests/test_account_fiscal_year.py deleted file mode 100644 index 8ab006bbf6d..00000000000 --- a/addons/account/tests/test_account_fiscal_year.py +++ /dev/null @@ -1,131 +0,0 @@ -# -*- coding: utf-8 -*- -from odoo.addons.account.tests.common import AccountTestCommon - -import odoo.tests -from odoo import fields - -from datetime import datetime - - -@odoo.tests.tagged('post_install', '-at_install') -class TestFiscalPosition(AccountTestCommon): - - def check_compute_fiscal_year(self, company, date, expected_date_from, expected_date_to): - '''Compute the fiscal year at a certain date for the company passed as parameter. - Then, check if the result matches the 'expected_date_from'/'expected_date_to' dates. - - :param company: The company. - :param date: The date belonging to the fiscal year. - :param expected_date_from: The expected date_from after computation. - :param expected_date_to: The expected date_to after computation. - ''' - current_date = fields.Date.from_string(date) - res = company.compute_fiscalyear_dates(current_date) - self.assertEqual(res['date_from'], fields.Date.from_string(expected_date_from)) - self.assertEqual(res['date_to'], fields.Date.from_string(expected_date_to)) - - def test_default_fiscal_year(self): - '''Basic case with a fiscal year xxxx-01-01 - xxxx-12-31.''' - company = self.env.ref('base.main_company') - company.fiscalyear_last_day = 31 - company.fiscalyear_last_month = '12' - - self.check_compute_fiscal_year( - company, - '2017-12-31', - '2017-01-01', - '2017-12-31', - ) - - self.check_compute_fiscal_year( - company, - '2017-01-01', - '2017-01-01', - '2017-12-31', - ) - - def test_leap_fiscal_year_1(self): - '''Case with a leap year ending the 29 February.''' - company = self.env.ref('base.main_company') - company.fiscalyear_last_day = 29 - company.fiscalyear_last_month = '2' - - self.check_compute_fiscal_year( - company, - '2016-02-29', - '2015-03-01', - '2016-02-29', - ) - - self.check_compute_fiscal_year( - company, - '2015-03-01', - '2015-03-01', - '2016-02-29', - ) - - def test_leap_fiscal_year_2(self): - '''Case with a leap year ending the 28 February.''' - company = self.env.ref('base.main_company') - company.fiscalyear_last_day = 28 - company.fiscalyear_last_month = '2' - - self.check_compute_fiscal_year( - company, - '2016-02-29', - '2015-03-01', - '2016-02-29', - ) - - self.check_compute_fiscal_year( - company, - '2016-03-01', - '2016-03-01', - '2017-02-28', - ) - - def test_custom_fiscal_year(self): - '''Case with custom fiscal years.''' - company = self.env.ref('base.main_company') - company.fiscalyear_last_day = 31 - company.fiscalyear_last_month = '12' - - # Create custom fiscal year covering the 6 first months of 2017. - self.env['account.fiscal.year'].create({ - 'name': '6 month 2017', - 'date_from': '2017-01-01', - 'date_to': '2017-05-31', - 'company_id': company.id, - }) - - # Check before the custom fiscal year). - self.check_compute_fiscal_year( - company, - '2017-02-01', - '2017-01-01', - '2017-05-31', - ) - - # Check after the custom fiscal year. - self.check_compute_fiscal_year( - company, - '2017-11-01', - '2017-06-01', - '2017-12-31', - ) - - # Create custom fiscal year covering the 3 last months of 2017. - self.env['account.fiscal.year'].create({ - 'name': 'last 3 month 2017', - 'date_from': '2017-10-01', - 'date_to': '2017-12-31', - 'company_id': company.id, - }) - - # Check inside the custom fiscal years. - self.check_compute_fiscal_year( - company, - '2017-07-01', - '2017-06-01', - '2017-09-30', - ) diff --git a/addons/account/views/account_account_tag_views.xml b/addons/account/views/account_account_tag_views.xml index e5268c8d1f1..a459284ea77 100644 --- a/addons/account/views/account_account_tag_views.xml +++ b/addons/account/views/account_account_tag_views.xml @@ -45,16 +45,5 @@ - - Account Tags - account.account.tag - - -

- Add a new tag -

-
-
- diff --git a/addons/account/views/account_analytic_default_view.xml b/addons/account/views/account_analytic_default_view.xml index b628d2bb466..3a4368682d5 100644 --- a/addons/account/views/account_analytic_default_view.xml +++ b/addons/account/views/account_analytic_default_view.xml @@ -103,13 +103,8 @@ {"search_default_current":1} - - Analytic Rules - account.analytic.default - {'search_default_product_id': [active_id], 'default_product_id': active_id} - - diff --git a/addons/account/views/account_bank_statement_views.xml b/addons/account/views/account_bank_statement_views.xml index c7cc42ec033..b979060a26b 100644 --- a/addons/account/views/account_bank_statement_views.xml +++ b/addons/account/views/account_bank_statement_views.xml @@ -355,14 +355,6 @@
- - Draft statements - account.bank.statement - tree,form - [('state','=','draft')] - - - account.bank.statement.pivot account.bank.statement diff --git a/addons/account/views/account_chart_template_views.xml b/addons/account/views/account_chart_template_views.xml index db0c38a360f..87ee1d4bcf8 100644 --- a/addons/account/views/account_chart_template_views.xml +++ b/addons/account/views/account_chart_template_views.xml @@ -124,13 +124,6 @@ - - Account Templates - account.account.template - tree,form - - - @@ -282,17 +275,5 @@ - - Fiscal Position - account.fiscal.position.template - tree,form - - -

- Create a new fiscal position -

-
-
- diff --git a/addons/account/views/account_fiscal_year_view.xml b/addons/account/views/account_fiscal_year_view.xml deleted file mode 100644 index e98ef5169e3..00000000000 --- a/addons/account/views/account_fiscal_year_view.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - Fiscal Years - account.fiscal.year - tree,form - -

- Click here to create a new fiscal year. -

-
-
- - - account.fiscal.year.form - account.fiscal.year - -
- - - - - - - - -
-
-
- - - account.fiscal.year.search - account.fiscal.year - - - - - - - - - account.fiscal.year.tree - account.fiscal.year - - - - - - - - - -
-
diff --git a/addons/account/views/account_group_views.xml b/addons/account/views/account_group_views.xml index 0e5579d21b6..b2e9f04aa01 100644 --- a/addons/account/views/account_group_views.xml +++ b/addons/account/views/account_group_views.xml @@ -46,17 +46,5 @@ - - Account Groups - account.group - tree,form - - -

- Create a new account group -

-
-
- diff --git a/addons/account/views/account_menuitem.xml b/addons/account/views/account_menuitem.xml index 8375abc214e..35f1c5ee5ef 100644 --- a/addons/account/views/account_menuitem.xml +++ b/addons/account/views/account_menuitem.xml @@ -61,6 +61,7 @@ + diff --git a/addons/account/views/account_move_views.xml b/addons/account/views/account_move_views.xml index c5c6c2628f4..ec2099ce835 100644 --- a/addons/account/views/account_move_views.xml +++ b/addons/account/views/account_move_views.xml @@ -1151,12 +1151,6 @@ context="{'search_default_account_id': [active_id]}" res_model="account.move.line"/> - - Create Accrual Entries @@ -1166,13 +1160,6 @@ action = records.action_accrual_entry() - - {'journal_type':'general', 'search_default_group_by_move': 1, 'search_default_posted':1, 'name_groupby':1, 'create':0} Journal Items @@ -1255,24 +1242,6 @@ tree,pivot,graph,form,kanban - - Journal Items - graph,pivot - - [('display_type', 'not in', ('line_section', 'line_note'))] - {'search_default_account_id': [active_id]} - account.move.line - - - - Journal Items - graph,pivot - - [('display_type', 'not in', ('line_section', 'line_note'))] - {'search_default_account_id': [active_id], 'search_default_posted': 1} - account.move.line - - diff --git a/addons/account/views/account_tax_views.xml b/addons/account/views/account_tax_views.xml index b335fe296bc..8cf2da53e9e 100644 --- a/addons/account/views/account_tax_views.xml +++ b/addons/account/views/account_tax_views.xml @@ -194,13 +194,5 @@ - - Tax Groups - account.tax.group - tree - - - - diff --git a/addons/account/wizard/account_report_common_view.xml b/addons/account/wizard/account_report_common_view.xml index 2223d7eeed4..6333f125430 100644 --- a/addons/account/wizard/account_report_common_view.xml +++ b/addons/account/wizard/account_report_common_view.xml @@ -23,12 +23,4 @@ - - Common Report - account.common.report - form - - new - -